만세.
드디어 퍼 픽셀 라이팅
(Per Pixel Lighting:하이라이트 부분이 폴리곤 라인이 보이지 않고 동그란걸 보세요)
을 성공했다.
아직 얼떨떨.
어떤 것이 넘어가야 하고
어떤 것이 안넘어가도 되는지는
한번 설명을 들어야 하겠다.

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};
int n
<
string UIName = “Specularpower”;
string UIType = “IntSpinner”;
float UIMin = 0;
float UIMax = 100;
;
void VS
(
in float4 iPos : POSITION,
in float3 iNormal : NORMAL,
out float4 oPos : POSITION,
out float4 iPosWorld : TEXCOORD1,
out float3 oNormal : TEXCOORD2
)
{
oPos = mul( iPos , WorldViewproj );
iPosWorld = mul( iPos, World );
oNormal = iNormal;
}
void PS
(
in float4 iPosWorld : TEXCOORD1,
in float3 iNormal : TEXCOORD2,
out float4 oColor : COLOR
)
{
float3 ViewVector = normalize ( ViewI[3].xyz - iPosWorld.xyz);
float3 oNormal = normalize ( mul (iNormal,(float3x3)World ) );
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();
}
}