我渲染出来的阴影边缘感觉怪怪(图片在附件),像是一层一层的,不像是模糊渐变出来。感觉是我随机种子写死导致序列固定,但是我有用coords作为随机去试,结果太随机了,导致边缘全是躁点
代码如下,我
float PCF(sampler2D shadowMap, vec4 coords) {
poissonDiskSamples(vec2(1234.2,3456.4));
// uniformDiskSamples(coords.xy*vec2(1234.2,3456.4));
float sumBlock = 0.0;
for(int i = 0; i< NUM_SAMPLES; i++){
vec2 shadowCoord = coords.xy + poissonDisk[i]/ vec2(200.0);
float compareDepth = texture2D(shadowMap, shadowCoord.xy).r;
if(coords.z > compareDepth + 0.05){
// return 0.0;
sumBlock += 1.0;
}else{
// return 1.0;
}
}
float fNumSamples = float(NUM_SAMPLES);
return ((fNumSamples - sumBlock) / fNumSamples);
return 1.0;
}
Attachments:
You must be
logged in to view attached files.