123 lines
3.8 KiB
HLSL
123 lines
3.8 KiB
HLSL
|
|
#include "def_effect.fx"
|
|
|
|
|
|
//=============================================================================
|
|
//캐릭터 Specular 포함
|
|
VS_SPECULAR_OUTPUT Specular_VS( VS_INPUT In )
|
|
{
|
|
VS_SPECULAR_OUTPUT Out = (VS_SPECULAR_OUTPUT)0;
|
|
|
|
float4 pos = In.position;
|
|
float3 normal = In.normal;
|
|
float4 tex = 0;
|
|
float4 output_pos, pos_world;
|
|
|
|
pos_world = SkinPoint( pos , blendMatrices, In.indices, In.weights); // pos is changed.
|
|
float3 N = SkinVector( normal, blendMatrices, In.indices, In.weights); // normal is changed.
|
|
|
|
// transform position to screen space before changing it.
|
|
output_pos = mul( pos_world, view_proj_matrix );
|
|
Out.position = output_pos;
|
|
|
|
//apply fog
|
|
float distfog = saturate((fFogDistEnd - output_pos.z)/(fFogDistEnd - fFogDistStart));
|
|
float heightfog = saturate((fFogHeightEnd - pos_world.z)/(fFogHeightEnd - fFogHeightStart));
|
|
Out.fog = min(distfog, heightfog);
|
|
|
|
|
|
float nLength = length(Light_position - pos_world);
|
|
float3 L = normalize(Light_position - pos_world);
|
|
|
|
float Atten = 1/(1+(Light_ambient.a*nLength));
|
|
|
|
// eye-base의 half-way 벡터
|
|
float3 light_vector = -Light_direction_forsp;
|
|
float3 eye_vector = Camera_position - pos_world;
|
|
float3 halfway = normalize(normalize(light_vector) + normalize(eye_vector));
|
|
|
|
float ddot = saturate(dot(N, L));
|
|
float sdot = saturate(dot(N, halfway));
|
|
|
|
Out.diffuse = Light_ambient + max(Light_diffuse * ddot * Atten, Light_specular * pow(sdot, 7)); // specular + diffuse + ambient
|
|
Out.diffuse.a = fVisibility;
|
|
|
|
tex = fUVAnimation.w*In.texCoord + fUVAnimation;
|
|
|
|
Out.specular = Light_specular;
|
|
Out.texCoord0 = tex;
|
|
Out.texCoord1 = tex;
|
|
Out.texCoord2.xy = saturate(dot(N, Light_halfway));
|
|
Out.texCoord3 = tex;
|
|
|
|
return Out;
|
|
}
|
|
|
|
|
|
//=============================================================================
|
|
//본 캐릭터
|
|
VS_OUTPUT Default_VS( VS_INPUT In )
|
|
{
|
|
VS_OUTPUT Out = (VS_OUTPUT) 0;
|
|
float4 pos = In.position;
|
|
float3 normal = In.normal;
|
|
float4 output_pos, pos_world;
|
|
|
|
pos_world = SkinPoint( pos , blendMatrices, In.indices, In.weights); // pos is changed.
|
|
float3 N = SkinVector( normal, blendMatrices, In.indices, In.weights); // normal is changed.
|
|
|
|
// transform position to screen space before changing it.
|
|
output_pos = mul( pos_world, view_proj_matrix );
|
|
Out.position = output_pos;
|
|
|
|
//apply fog
|
|
float distfog = saturate((fFogDistEnd - output_pos.z)/(fFogDistEnd - fFogDistStart));
|
|
float heightfog = saturate((fFogHeightEnd - pos_world.z)/(fFogHeightEnd - fFogHeightStart));
|
|
Out.fog = min(distfog, heightfog);
|
|
|
|
|
|
float nLength = length(Light_position - pos_world);
|
|
float3 L = normalize(Light_position - pos_world);
|
|
|
|
float Atten = 1/(1+Light_ambient.a*nLength);
|
|
|
|
// eye-base의 half-way 벡터
|
|
float3 light_vector = -Light_direction_forsp;
|
|
float3 eye_vector = Camera_position - pos_world;
|
|
float3 halfway = normalize(normalize(light_vector) + normalize(eye_vector));
|
|
|
|
float ddot = saturate(dot(N, L));
|
|
float sdot = saturate(dot(N, halfway));
|
|
|
|
Out.diffuse = Light_ambient + max(Light_diffuse * ddot * Atten, Light_specular * pow(sdot, 7)); // diffuse + ambient
|
|
Out.diffuse.a = fVisibility;
|
|
|
|
Out.texCoord = fUVAnimation.w*In.texCoord + fUVAnimation;
|
|
|
|
return Out;
|
|
}
|
|
|
|
//=============================================================================
|
|
//캐릭터 테크닉
|
|
technique DefaultTech_2x
|
|
{
|
|
pass P0
|
|
{
|
|
VertexShader = compile vs_2_0 Default_VS();
|
|
PixelShader = NULL;
|
|
// PixelShader = compile ps_1_4 Default_PS();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
//Specular 테크닉
|
|
technique SpecularTech_2x
|
|
{
|
|
pass P0
|
|
{
|
|
VertexShader = compile vs_2_0 Specular_VS();
|
|
PixelShader = NULL;
|
|
}
|
|
} |