Study/RenderMonkey - 2019년 백업
[RenderMonkey] Specular, ambient
김성인
2023. 12. 6. 23:14
[RenderMonkey] Specular, Ambient
// Pixel Shader
struct PS_INPUT
{
float3 mDiffuse : TEXCOORD1;
float3 mViewDir: TEXCOORD2;
float3 mReflection: TEXCOORD3;
};
float4 ps_main(PS_INPUT Input) : COLOR
{
float3 diffuse = saturate(Input.mDiffuse);
float3 reflection = normalize(Input.mReflection);
float3 viewDir = normalize(Input.mViewDir);
float3 specular = 0;
if (diffuse.x > 0)
{
specular = saturate(dot(reflection, -viewDir));
specular = pow(specular, 20.0f);
}
float3 ambient = float3(0.1f, 0.1f, 0.1f);
return float4(specular, 1); // 이 부분에서 스펙큘러 값만 반환 // 원하는 값만 반환 하면 됨.
}