Cel shading Update

This commit is contained in:
2024-09-25 12:40:02 +02:00
parent 1b8b25ce2a
commit 71403c614d
10 changed files with 128 additions and 71 deletions

View File

@@ -1,4 +1,3 @@
// celshading.vs
cbuffer MatrixBuffer
{
matrix worldMatrix;
@@ -9,13 +8,16 @@ cbuffer MatrixBuffer
struct VertexInputType
{
float4 position : POSITION;
float3 normal : NORMAL;
float2 tex : TEXCOORD0;
};
struct PixelInputType
{
float4 position : SV_POSITION;
float3 normal : NORMAL;
float2 tex : TEXCOORD0;
float3 worldPos : TEXCOORD1; // Add world position
};
PixelInputType CelShadingVertexShader(VertexInputType input)
@@ -30,8 +32,14 @@ PixelInputType CelShadingVertexShader(VertexInputType input)
output.position = mul(output.position, viewMatrix);
output.position = mul(output.position, projectionMatrix);
// Pass the normal to the pixel shader
output.normal = mul(input.normal, (float3x3)worldMatrix);
// Pass the world position to the pixel shader
output.worldPos = mul(input.position, worldMatrix).xyz;
// Store the texture coordinates for the pixel shader.
output.tex = input.tex;
return output;
}
}