디퓨즈/스페큘러의 퍼픽셀 라이팅 전환작업중.
이런 제길.
스페큘러와 디퓨즈까지 픽셀쉐이더로 뺐다고 생각했는데
왜 퍼 픽셀 라이팅이 안나타나는 것이냐.
그렇다고 position 값을 픽셀로 넘길수는 없는걸로 아는데,
더 넘길 수 있는게 없잖아 OTL
뭐가 문제냐 도데체.
아 궁금해. 내일 선생님에게 물어봐야지.
float4x4 WorldViewproj : WORLDVIEWPROJ;
float4x4 World : WORLD;
float4x4 ViewI : ViewI;
float3 L_a = (1.0f, 1.0f, 1.0f);//엠비언트
float3 L_d = (1.0f, 1.0f, 1.0f);//디퓨즈
float3 L_s= (1.0f, 1.0f, 1.0f);//스페큘러
float3 LightDirection : DIRECTION
<
string UIName = “라이트 디렉션”;
string Object = “Directionallight”;
string Space = “WORLD”;
int RefID = 0;
;
float3 AmbientColor
<
string UIName = “AmbientColor”;
= {0.5f, 0.5f, 0.5f};
float3 DiffuseColor
<
string UIName = “DiffuseColor”;
= {0.5f, 0.5f, 0.5f};
float3 SpecularColor
<
string UIName = “DiffuseColor”;
= {1.0f, 1.0f, 1.0f};
float n
<
string UIName = “Specularpower”;
string UIType = “IntSpinner”;
float UIMin = 0.0f;
float UIMax = 100.0f;
;
void VS
(
in float4 iPos : POSITION,
in float3 iNormal : NORMAL,
out float4 oPos : POSITION,
out float3 oNormal : TEXCOORD2,
out float3 ViewVector : TEXCOORD3
)
{
oPos = mul( iPos , WorldViewproj );
ViewVector = normalize ( ViewI[3].xyz - mul( iPos, World ).xyz);
oNormal = normalize ( mul (iNormal,(float3x3)World ) );
}
void PS
(
in float3 oNormal : TEXCOORD2,
in float3 ViewVector : TEXCOORD3,
out float4 oColor : COLOR
)
{
float3 HalfVector = normalize ( ViewVector + LightDirection );
float3 iSpecular = L_s * SpecularColor * pow( max ( 0, dot( oNormal, HalfVector )) , n );
float3 iDiffuse = L_a * AmbientColor + L_d * DiffuseColor * max( 0, dot ( oNormal, LightDirection ));
oColor = float4(( iDiffuse + iSpecular),1) ;
}
technique jp4
{
pass p0
{
VertexShader = compile vs_2_0 VS();
PixelShader = compile ps_2_0 PS();
}
}