Avancement Limière
This commit is contained in:
@@ -12,11 +12,7 @@ cbuffer MatrixBuffer
|
||||
matrix viewMatrix;
|
||||
matrix projectionMatrix;
|
||||
};
|
||||
cbuffer CameraBuffer
|
||||
{
|
||||
float3 cameraPosition;
|
||||
float padding;
|
||||
};
|
||||
|
||||
//////////////
|
||||
// TYPEDEFS //
|
||||
//////////////
|
||||
@@ -26,22 +22,22 @@ struct VertexInputType
|
||||
float2 tex : TEXCOORD0;
|
||||
float3 normal : NORMAL;
|
||||
};
|
||||
|
||||
struct PixelInputType
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
float3 normal : NORMAL;
|
||||
float3 viewDirection : TEXCOORD1;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Vertex Shader
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
PixelInputType LightVertexShader(VertexInputType input)
|
||||
{
|
||||
PixelInputType output;
|
||||
float4 worldPosition;
|
||||
|
||||
|
||||
|
||||
// Change the position vector to be 4 units for proper matrix calculations.
|
||||
input.position.w = 1.0f;
|
||||
@@ -53,21 +49,12 @@ PixelInputType LightVertexShader(VertexInputType input)
|
||||
|
||||
// Store the texture coordinates for the pixel shader.
|
||||
output.tex = input.tex;
|
||||
|
||||
|
||||
// Calculate the normal vector against the world matrix only.
|
||||
output.normal = mul(input.normal, (float3x3)worldMatrix);
|
||||
|
||||
// Normalize the normal vector.
|
||||
output.normal = normalize(output.normal);
|
||||
|
||||
// Calculate the position of the vertex in the world.
|
||||
worldPosition = mul(input.position, worldMatrix);
|
||||
|
||||
// Determine the viewing direction based on the position of the camera and the position of the vertex in the world.
|
||||
output.viewDirection = cameraPosition.xyz - worldPosition.xyz;
|
||||
|
||||
// Normalize the viewing direction vector.
|
||||
output.viewDirection = normalize(output.viewDirection);
|
||||
|
||||
return output;
|
||||
}
|
||||
Reference in New Issue
Block a user