Changes to shadowpass
This commit is contained in:
@@ -46,12 +46,12 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
|
||||
{
|
||||
uint cascadeIndex = 0;
|
||||
for (uint c = 0; c < NUM_CASCADES - 1; ++c) {
|
||||
if (params.position_VS.z < pShadowMapping.cascadeSplits[c]) {
|
||||
if (params.position_VS.z > pShadowMapping.cascadeSplits[c]) {
|
||||
cascadeIndex = c + 1;
|
||||
}
|
||||
}
|
||||
float4 lightSpacePos = mul(pShadowMapping.lightSpaceMatrices[cascadeIndex][i], float4(params.position_WS, 1));
|
||||
lightSpacePos = mul(biasMat, lightSpacePos);
|
||||
lightSpacePos = float4(lightSpacePos.xy * 0.5 + 0.5, lightSpacePos.zw);
|
||||
float4 shadowCoord = lightSpacePos;
|
||||
int3 texDim;
|
||||
pShadowMapping.shadowMaps[cascadeIndex].GetDimensions(texDim.x, texDim.y, texDim.z);
|
||||
@@ -62,12 +62,12 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
|
||||
float shadowFactor = 0.0f;
|
||||
int count = 0;
|
||||
int range = 1;
|
||||
for (int x = -range; x <= range; ++x) {
|
||||
for (int y = -range; y <= range; ++y) {
|
||||
//for (int x = -range; x <= range; ++x) {
|
||||
// for (int y = -range; y <= range; ++y) {
|
||||
float shadow = 1.0f;
|
||||
if (shadowCoord.z > 0.0 && shadowCoord.z < 1.0)
|
||||
{
|
||||
float dist = pShadowMapping.shadowMaps[cascadeIndex].Sample(pShadowMapping.shadowSampler, float3(shadowCoord.xy + float2(dx * x, dy * y), i)).r;
|
||||
float dist = pShadowMapping.shadowMaps[cascadeIndex].Sample(pShadowMapping.shadowSampler, float3(shadowCoord.xy, i)).r;
|
||||
if (shadowCoord.w > 0 && dist < shadowCoord.z)
|
||||
{
|
||||
shadow = 0;
|
||||
@@ -75,8 +75,8 @@ float4 fragmentMain(in FragmentParameter params) : SV_Target
|
||||
}
|
||||
shadowFactor += shadow;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
// }
|
||||
//}
|
||||
|
||||
result = (shadowFactor / count) * pLightEnv.directionalLights[i].illuminate(lightingParams, brdf);
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ VertexShaderOutput vertexMain(
|
||||
float4 worldPos = float4(mul(cameraRotation, vertices[vertexIndex]), 1.0f);
|
||||
//clip(dot(worldPos, clipPlane));
|
||||
output.clipPos = mul(pViewParams.projectionMatrix, worldPos);
|
||||
output.clipPos.z = output.clipPos.w - 0.0001f; // Push to far plane
|
||||
output.texCoords = normalize(vertices[vertexIndex]);
|
||||
return output;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user