Revert "Minor - Start Shadow Map - V10.5.0"
This reverts commit d6b7626446
.
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
};
|
||||
|
||||
float4 DepthPixelShader(PS_INPUT input) : SV_TARGET
|
||||
{
|
||||
// Pas de couleur, juste la profondeur
|
||||
return float4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
cbuffer MatrixBuffer : register(b0)
|
||||
{
|
||||
matrix world;
|
||||
matrix view;
|
||||
matrix projection;
|
||||
};
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
float3 position : POSITION;
|
||||
};
|
||||
|
||||
struct VS_OUTPUT
|
||||
{
|
||||
float4 position : SV_POSITION;
|
||||
};
|
||||
|
||||
VS_OUTPUT DepthVertexShader(VS_INPUT input)
|
||||
{
|
||||
VS_OUTPUT output;
|
||||
float4 worldPosition = mul(float4(input.position, 1.0f), world);
|
||||
float4 viewPosition = mul(worldPosition, view);
|
||||
output.position = mul(viewPosition, projection);
|
||||
return output;
|
||||
}
|
@@ -3,9 +3,6 @@
|
||||
/////////////
|
||||
Texture2D shaderTexture : register(t0);
|
||||
SamplerState SampleType : register(s0);
|
||||
Texture2D shadowMap : register(t1);
|
||||
SamplerState shadowSampleType : register(s1);
|
||||
|
||||
cbuffer SunLightBuffer
|
||||
{
|
||||
float4 ambientColor;
|
||||
@@ -27,7 +24,6 @@ struct PixelInputType
|
||||
float4 position : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
float3 normal : NORMAL;
|
||||
float4 lightPosition : TEXCOORD1;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -35,47 +31,23 @@ struct PixelInputType
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
float4 SunLightPixelShader(PixelInputType input) : SV_TARGET
|
||||
{
|
||||
|
||||
// temp return to check if the shader is working
|
||||
return float4(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
float4 textureColor;
|
||||
float4 color;
|
||||
float lightIntensity;
|
||||
float4 colorArray;
|
||||
float4 colorSum;
|
||||
float bias = 0.001f;
|
||||
float shadowFactor = 1.0f;
|
||||
|
||||
// Sample the pixel color from the texture using the sampler at this coordinate
|
||||
// Sample the pixel color from the texture using the sampler at this texture coordinate location.
|
||||
textureColor = shaderTexture.Sample(SampleType, input.tex);
|
||||
|
||||
// Calculate shadow factor
|
||||
// Projection division to normalize coordinates
|
||||
float2 projectTexCoord;
|
||||
projectTexCoord.x = input.lightPosition.x / input.lightPosition.w / 2.0f + 0.5f;
|
||||
projectTexCoord.y = -input.lightPosition.y / input.lightPosition.w / 2.0f + 0.5f;
|
||||
|
||||
if((saturate(projectTexCoord.x) == projectTexCoord.x) && (saturate(projectTexCoord.y) == projectTexCoord.y))
|
||||
{
|
||||
float depthValue = input.lightPosition.z / input.lightPosition.w;
|
||||
float shadowDepth = shadowMap.Sample(shadowSampleType, projectTexCoord).r;
|
||||
|
||||
if(depthValue - bias > shadowDepth)
|
||||
{
|
||||
// Pixel est dans l'ombre
|
||||
shadowFactor = 0.3f; // Ombre non totale pour un effet plus r<EFBFBD>aliste
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the different amounts of light on this pixel based on the direction of the light.
|
||||
lightIntensity = saturate(dot(input.normal, -lightDirection));
|
||||
|
||||
// Determine the diffuse color amount of the light.
|
||||
colorArray = (diffuseColor * lightIntensity) * intensity * shadowFactor;
|
||||
|
||||
colorArray = (diffuseColor * lightIntensity) * intensity;
|
||||
|
||||
// Initialize the sum of colors.
|
||||
colorSum = ambientColor; // Conserver l'<27>clairage ambiant m<EFBFBD>me dans l'ombre
|
||||
colorSum = float4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
// Add the light color.
|
||||
colorSum.r += colorArray.r;
|
||||
@@ -86,4 +58,4 @@ float4 SunLightPixelShader(PixelInputType input) : SV_TARGET
|
||||
color = saturate(colorSum) * textureColor;
|
||||
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
@@ -22,12 +22,6 @@ cbuffer SunLightBuffer
|
||||
float intensity;
|
||||
};
|
||||
|
||||
cbuffer LightViewMatrixBuffer : register(b2)
|
||||
{
|
||||
matrix lightViewMatrix;
|
||||
matrix lightProjectionMatrix;
|
||||
};
|
||||
|
||||
//////////////
|
||||
// TYPEDEFS //
|
||||
//////////////
|
||||
@@ -43,7 +37,6 @@ struct PixelInputType
|
||||
float4 position : SV_POSITION;
|
||||
float2 tex : TEXCOORD0;
|
||||
float3 normal : NORMAL;
|
||||
float4 lightPosition : TEXCOORD1;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -52,30 +45,23 @@ struct PixelInputType
|
||||
PixelInputType SunLightVertexShader(VertexInputType input)
|
||||
{
|
||||
PixelInputType output;
|
||||
float4 worldPosition; // D<>claration de la variable manquante
|
||||
|
||||
// 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 matrix
|
||||
worldPosition = mul(input.position, worldMatrix);
|
||||
|
||||
// Calculate position in light view space.
|
||||
output.lightPosition = mul(worldPosition, lightViewMatrix);
|
||||
output.lightPosition = mul(output.lightPosition, lightProjectionMatrix);
|
||||
|
||||
// Standard position calculation
|
||||
output.position = mul(worldPosition, viewMatrix);
|
||||
// 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;
|
||||
|
||||
// Calculate the normal vector against the world matrix only.
|
||||
output.normal = mul(input.normal, (float3x3)worldMatrix);
|
||||
output.normal = mul(input.normal, (float3x3) worldMatrix);
|
||||
|
||||
// Normalize the normal vector.
|
||||
output.normal = normalize(output.normal);
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user