267 lines
7.4 KiB
HLSL
267 lines
7.4 KiB
HLSL
|
|
#define BONE_NUM 57
|
|
|
|
//float4x4 world_matrix : WORLDMATRIX;
|
|
float4x4 view_matrix : VIEWMATRIX;
|
|
float4x4 view_proj_matrix : VIEWPROJECTIONMATRIX;
|
|
//float4x4 world_view_matrix : WORLDVIEWMATRIX;
|
|
//float4x4 world_view_proj_matrix : WORLDVIEWPROJECTION;
|
|
|
|
// Light intensity
|
|
float4 Light_ambient = { 0.5f, 0.5f, 0.5f, 1.0f }; // ambient , alpha 는 Attenuation 사용
|
|
float4 Light_diffuse = { 0.2f, 0.2f, 0.2f, 1.0f }; // diffuse
|
|
float4 Light_specular = { 1.0f, 1.0f, 1.0f, 1.0f }; // specular
|
|
|
|
// Light direction (view space)
|
|
float4 Light_halfway = { -0.4, -0.5, 0.7, 1.0 };
|
|
float3 Light_position = { 5000, 5000, 5000 };
|
|
float3 Camera_position = { 5000, 5000, 5000 };
|
|
float3 Light_direction_forsp = { -1, 0, 0 };
|
|
|
|
// Fog Setting
|
|
float fFogDistStart = 800.f;
|
|
float fFogDistEnd = 2000.f;
|
|
float fFogHeightStart = 100.f;
|
|
float fFogHeightEnd = 10000.f;
|
|
|
|
// UV Animation
|
|
float4 fUVAnimation = 0;
|
|
|
|
float fVisibility = 1.f;
|
|
|
|
//Sky Setting
|
|
float fSky_Max_height = 2000.f;
|
|
float fSky_Min_height = -300.f;
|
|
float4 Sky_Light_High = { .3f, .5f, 1.0f, 1.0f };
|
|
float4 Sky_Light_Low = { .7f, .7f, .7f, 1.0f };
|
|
|
|
// Cloud Spread - setting
|
|
float4 CloudSpread_Center = 0;
|
|
float CloudSpread_CornerDistance = 6000;
|
|
float CloudSpread_BalanceHeight = 800;
|
|
|
|
float4x4 blendMatrices[BONE_NUM];
|
|
|
|
|
|
|
|
// 렌더링에 사용하는 텍스처 리스트
|
|
sampler DiffTexture : register(s0) = sampler_state
|
|
{
|
|
MinFilter = LINEAR;
|
|
MagFilter = LINEAR;
|
|
MipFilter = LINEAR;
|
|
AddressU = Wrap;
|
|
AddressV = Wrap;
|
|
};
|
|
sampler BumpTexture : register(s1) = sampler_state
|
|
{
|
|
MinFilter = LINEAR;
|
|
MagFilter = LINEAR;
|
|
MipFilter = LINEAR;
|
|
AddressU = Wrap;
|
|
AddressV = Wrap;
|
|
};
|
|
sampler IllumTexture : register(s2) = sampler_state
|
|
{
|
|
MinFilter = LINEAR;
|
|
MagFilter = LINEAR;
|
|
MipFilter = LINEAR;
|
|
AddressU = Wrap;
|
|
AddressV = Wrap;
|
|
};
|
|
|
|
//Default=======================================================================
|
|
struct VS_INPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float3 normal :NORMAL;
|
|
float4 texCoord :TEXCOORD0;
|
|
int4 indices :BLENDINDICES;
|
|
float2 weights :BLENDWEIGHT;
|
|
};
|
|
|
|
struct VS_OUTPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float4 diffuse :COLOR0;
|
|
float4 specular :COLOR1;
|
|
float4 texCoord :TEXCOORD0;
|
|
float fog :FOG;
|
|
};
|
|
//=============================================================================
|
|
|
|
//Bump=======================================================================
|
|
struct VS_BUMP_INPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float3 normal :NORMAL;
|
|
float4 texCoord :TEXCOORD0;
|
|
float4 tangent :TANGENT;
|
|
int4 indices :BLENDINDICES;
|
|
float2 weights :BLENDWEIGHT;
|
|
};
|
|
struct VS_BUMP_OUTPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float4 texCoord0 :TEXCOORD0; // diffuse texture
|
|
float4 texCoord1 :TEXCOORD1; // bump texture
|
|
float4 texCoord2 :TEXCOORD2; // light vector - in tagent space
|
|
float4 texCoord3 :TEXCOORD3; // half-way vector - in tagent space
|
|
float fog :FOG;
|
|
};
|
|
|
|
struct PS_BUMP_INPUT
|
|
{
|
|
float4 texCoord0 :TEXCOORD0; // diffuse texture
|
|
float4 texCoord1 :TEXCOORD1; // bump texture
|
|
float4 texCoord2 :TEXCOORD2; // light vector - in tagent space
|
|
float4 texCoord3 :TEXCOORD3; // half-way vector - in tagent space
|
|
};
|
|
|
|
//Specular=======================================================================
|
|
struct VS_SPECULAR_OUTPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float4 diffuse :COLOR0;
|
|
float4 specular :COLOR1;
|
|
float4 texCoord0 :TEXCOORD0;
|
|
float4 texCoord1 :TEXCOORD1;
|
|
float4 texCoord2 :TEXCOORD2;
|
|
float4 texCoord3 :TEXCOORD3;
|
|
float fog :FOG;
|
|
};
|
|
|
|
/*struct PS_INPUT
|
|
{
|
|
float4 diffuse :COLOR;
|
|
float4 texCoord :TEXCOORD0;
|
|
float3 normal :TEXCOORD1;
|
|
float3 normalWS :TEXCOORD4;
|
|
float4 positionWS :TEXCOORD5;
|
|
};*/
|
|
|
|
|
|
//=======================================================================
|
|
//Normal Mesh Structures
|
|
struct VSOBJ_INPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float3 normal :NORMAL;
|
|
float4 diffuse :COLOR0;
|
|
float4 texCoord :TEXCOORD0;
|
|
int4 indices :BLENDINDICES;
|
|
};
|
|
|
|
struct VSOBJ_OUTPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float4 diffuse :COLOR0;
|
|
float4 specular :COLOR1;
|
|
float4 texCoord1 :TEXCOORD0;
|
|
float4 texCoord2 :TEXCOORD1;
|
|
float4 texCoord3 :TEXCOORD2;
|
|
float fog :FOG;
|
|
};
|
|
|
|
struct VSOBJ_NOLIGHT_OUTPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float4 diffuse :COLOR0;
|
|
float4 specular :COLOR1;
|
|
float4 texCoord :TEXCOORD0;
|
|
float fog :FOG;
|
|
};
|
|
|
|
//=======================================================================
|
|
// [sonador] Cloud Structures
|
|
struct VSCLOUD_INPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float3 normal :NORMAL;
|
|
float4 diffuse :COLOR0;
|
|
float4 texCoord1 :TEXCOORD0;
|
|
//float4 texCoord2 :TEXCOORD1;
|
|
int4 indices :BLENDINDICES;
|
|
};
|
|
|
|
struct VSCLOUD_OUTPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float4 diffuse :COLOR0;
|
|
float4 specular :COLOR1;
|
|
float4 texCoord1 :TEXCOORD0;
|
|
//float4 texCoord2 :TEXCOORD1;
|
|
float fog :FOG;
|
|
};
|
|
|
|
//=======================================================================
|
|
//Terrain Structures
|
|
float4 fTerrainTextureInterpolationByHeight = 0;
|
|
float4 fTerrainTextureCenter = 0;
|
|
float4 fTerrainTextureCenterDusk = 0;
|
|
float fTerrain1stTextureScale = 1.f;
|
|
float fTerrain2ndTextureScale = 1.f;
|
|
float fTerrain3thTextureScale = 1.f;
|
|
float fTerrain4thTextureScale = 1.f;
|
|
|
|
struct VSTERRAIN_INPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float3 normal :NORMAL;
|
|
float4 color :COLOR0;
|
|
};
|
|
|
|
struct VSTERRAIN_OUTPUT
|
|
{
|
|
float4 position :POSITION;
|
|
float4 diffuse :COLOR0;
|
|
float4 specular :COLOR1;
|
|
float4 texCoord1 :TEXCOORD0;
|
|
float4 texCoord2 :TEXCOORD1;
|
|
float4 texCoord3 :TEXCOORD2;
|
|
float4 texCoord4 :TEXCOORD3;
|
|
float fog :FOG;
|
|
};
|
|
|
|
|
|
|
|
//===========================================================================================
|
|
// SkinPoint
|
|
// Applies 4 matrix skinning to a single point. The point passed in is changed as well as returned.
|
|
//
|
|
float4 SkinPoint( inout float4 io_value, float4x4 blendMats[BONE_NUM], int4 indices, float2 weights)
|
|
{
|
|
int i;
|
|
float4 incoming_io_value = io_value;
|
|
|
|
if(weights[0] != -1 )
|
|
{
|
|
io_value = 0;
|
|
// skin
|
|
io_value += mul( incoming_io_value, blendMats[indices[0]]) * weights[0];
|
|
io_value += mul( incoming_io_value, blendMats[indices[1]]) * weights[1];
|
|
}
|
|
return io_value;
|
|
}
|
|
//===========================================================================================
|
|
// SkinVector
|
|
// Applies 4 matrix skinning to a vector. The vector passed in is changed as well as returned.
|
|
//
|
|
float3 SkinVector( inout float3 io_value, float4x4 blendMats[BONE_NUM], int4 indices, float2 weights)
|
|
{
|
|
int i;
|
|
float3 incoming_io_value = io_value;
|
|
|
|
if(weights[0] != -1 )
|
|
{
|
|
io_value = 0;
|
|
|
|
io_value += mul( incoming_io_value, blendMats[indices[0]]) * weights[0];
|
|
io_value += mul( incoming_io_value, blendMats[indices[1]]) * weights[1];
|
|
|
|
io_value = normalize(io_value);
|
|
}
|
|
|
|
return io_value;
|
|
}
|