主页 Forums Games202-高质量实时渲染 作业一PCF的问题

Viewing 3 reply threads
  • Author
    Posts
    • #8415 Score: 0
      DIDCJS
      Participant

      我渲染出来的阴影边缘感觉怪怪(图片在附件),像是一层一层的,不像是模糊渐变出来。感觉是我随机种子写死导致序列固定,但是我有用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.
    • #8417 Score: 0
      DIDCJS
      Participant

      随机采样改成poissonDiskSamples(coords.xy);
      结果太多躁点 附件

      Attachments:
      You must be logged in to view attached files.
    • #8419 Score: 0
      小夜子
      Participant

      我随机种子用的0,0。而且应该固定种子吧。另外,你返回的比例值是个和采样数相关的。而你每次block只增加1,我感觉这个变化太小了。我是直接将每次采样完后,对比完结果进行均值。。我以0,0为种子,然后将泊松采样大小,控制在poissonDisk[i]/ vec2(80.0)就很明显了。

    • #9196 Score: 0
      coli
      Participant

      楼主,是你shadowmap精度太低的原因
      float compareDepth = texture2D(shadowMap, shadowCoord.xy).r;
      shadowmap深度存在rgba 4个通道里面,你只取了r,精度太低变马赛克了
      应该用unpack解码出真正深度

Viewing 3 reply threads
  • You must be logged in to reply to this topic.