Home › Forums › Games202-高质量实时渲染 › 关于VSSM
Tagged: VSSM
- This topic has 1 reply, 2 voices, and was last updated 1 year, 5 months ago by brendan87.
Viewing 1 reply thread
-
AuthorPosts
-
-
minisparksParticipant
我在自己试图实现VSSM的时候发现阴影上有很多不自然的条纹,检查glsl代码后发现在计算blocker平均深度Zocc的时候Zocc这一项有时会为负数,请问有人遇到过这种问题吗,怎么规避这一点呢?
关键glsl代码我贴在下边了,恳请大家帮忙指正。" vec4 brightFragColor = ambient+diffuse+specular;\n" " float lightDepth = texture(depthMap, vec2(LightSpaceCoord.x/2+0.5, LightSpaceCoord.y/2+0.5)).r;\n" " float shadingPointDepth = LightSpaceCoord.z/2+0.5;\n" " if(lightDepth+0.0005<shadingPointDepth){\n" " float lightDepth2 = texture(depth2Map, vec2(LightSpaceCoord.x/2+0.5, LightSpaceCoord.y/2+0.5)).r;\n" " float meanSquareErr = lightDepth2-(lightDepth*lightDepth);\n" " float RatioZunocc = meanSquareErr/(meanSquareErr+(shadingPointDepth-lightDepth)*(shadingPointDepth-lightDepth));\n"//切比雪夫1 " float Zocc = (lightDepth-shadingPointDepth*RatioZunocc)/(1-RatioZunocc);\n" " float mipLevel = 5.0*shadingPointDepth/Zocc;\n" " float vlightDepth = textureLod(depthMap, vec2(LightSpaceCoord.x/2+0.5, LightSpaceCoord.y/2+0.5), mipLevel).r;\n" " float vlightDepth2 = textureLod(depth2Map, vec2(LightSpaceCoord.x/2+0.5, LightSpaceCoord.y/2+0.5), mipLevel).r;\n" " float vmeanSquareErr = vlightDepth2-(vlightDepth*vlightDepth);\n" " float vRatioZunocc = vmeanSquareErr/(vmeanSquareErr+(shadingPointDepth-vlightDepth)*(shadingPointDepth-vlightDepth));\n"//切比雪夫2 " if(Zocc<0) FragColor = vec4(0.1,0.6,0.3,1.0);\n" " else FragColor = brightFragColor*vRatioZunocc*0.8+brightFragColor*0.2;\n"//brightFragColor*vRatioZunocc*0.8+brightFragColor*0.2; " }else{\n" " FragColor = brightFragColor;\n"//vec4(0.5,0.5,0.5,1.0f) vec4(vec3(texture(skybox, TexCoord)),1.0f)//深度cubemap测试中 " }\n"
其中depthMap为深度图,depthMap2为其平方版本。LightSpaceCoord为光照空间下着色点坐标。
Attachments:
You must be logged in to view attached files. -
brendan87Participant
¿No puedes conseguir todo lo que quieres porque no te lo puedes permitir? Puedo ayudarte con eso. Un día encontré este sitio web juegging. Entra y gana mucho dinero. Con este sitio te olvidarás de cómo contar cada céntimo. ¡Date prisa y no pospongas tu oportunidad de ganar dinero!
-
-
AuthorPosts
Viewing 1 reply thread
- You must be logged in to reply to this topic.