Ambient lightning + Multitexture (Les shaders ne se superposent pas)

This commit is contained in:
GolfOcean334
2024-03-27 11:19:34 +01:00
parent 35876a05a5
commit 6f08684972
18 changed files with 675 additions and 63 deletions

View File

@@ -8,9 +8,9 @@
/////////////
cbuffer MatrixBuffer
{
matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;
matrix worldMatrix;
matrix viewMatrix;
matrix projectionMatrix;
};
@@ -21,14 +21,14 @@ struct VertexInputType
{
float4 position : POSITION;
float2 tex : TEXCOORD0;
float3 normal : NORMAL;
float3 normal : NORMAL;
};
struct PixelInputType
{
float4 position : SV_POSITION;
float2 tex : TEXCOORD0;
float3 normal : NORMAL;
float3 normal : NORMAL;
};
@@ -40,18 +40,18 @@ PixelInputType LightVertexShader(VertexInputType input)
PixelInputType output;
// Change the position vector to be 4 units for proper matrix calculations.
// Change the position vector to be 4 units for proper matrix calculations.
input.position.w = 1.0f;
// Calculate the position of the vertex against the world, view, and projection matrices.
// Calculate the position of the vertex against the world, view, and projection matrices.
output.position = mul(input.position, worldMatrix);
output.position = mul(output.position, viewMatrix);
output.position = mul(output.position, projectionMatrix);
// Store the texture coordinates for the pixel shader.
output.tex = input.tex;
// Store the texture coordinates for the pixel shader.
output.tex = input.tex;
// Calculate the normal vector against the world matrix only.
// Calculate the normal vector against the world matrix only.
output.normal = mul(input.normal, (float3x3)worldMatrix);
// Normalize the normal vector.