[RenderMonkey] ToonShading

// Vertex Shader
struct VS_INPUT
{
float4 mPosition : POSITION;
float3 mNormal : NORMAL;
};
struct VS_OUTPUT
{
float4 mPosition : POSITION;
float3 mDiffuse : TEXCOORD1;
};
float4x4 gWorldViewProjectionMatrix;
float4x4 gInvWorldMatrix;
float4 gWorldLightPosition;
VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output;
Output.mPosition = mul(Input.mPosition, gWorldViewProjectionMatrix);
float3 objectLightPosition = mul(gWorldLightPosition, gInvWorldMatrix);
float3 lightDir = normalize(Input.mPosition.xyz - objectLightPosition);
Output.mDiffuse = dot(-lightDir, normalize(Input.mNormal));
return(Output);
}
// Pixel Shader
float3 gSurfaceColor;
struct PS_INPUT
{
float3 mDiffuse : TEXCOORD1;
};
float4 ps_main(PS_INPUT Input) : COLOR
{
float3 diffuse = saturate(Input.mDiffuse);
diffuse = ceil(diffuse * 5) / 5.0f;
return float4(gSurfaceColor * diffuse.xyz, 1);
}
// Stream Mapping
// NORMAL, FLOAT3
// COLOR, COLOR
//
// gsurfaceColor : float3
//
// gWorldLightPostion : float4
//
// gWorldViewProjectionMatrix : matrix4
//
// gInvWorldMartix : matrix4
'Study > RenderMonkey - 2019년 백업' 카테고리의 다른 글
[RenderMonkey] Environment Sampler / Cube Map (0) | 2023.12.06 |
---|---|
[RenderMonkey] Normal Mapping (1) | 2023.12.06 |
[RenderMonkey] Mapping (1) | 2023.12.06 |
[RenderMonkey] Specular, ambient (1) | 2023.12.06 |
[Render Monkey] Phong (1) | 2023.12.06 |