【发布时间】:2018-11-03 13:56:42
【问题描述】:
我正在使用延迟着色编写阴影映射。
这是我的定向光深度图(正交投影):
下面是我的全屏四边形着色器,用于在光照视图空间中渲染像素的深度:
#version 330
in vec2 texCoord;
out vec3 fragColor;
uniform mat4 lightViewProjMat; // lightView * lightProj
uniform sampler2D sceneTexture;
uniform sampler2D shadowMapTexture;
uniform sampler2D scenePosTexture;
void main() {
vec4 fragPos = texture(scenePosTexture, texCoord);
vec4 fragPosLightSpace = lightViewProjMat * fragPos;
vec3 coord = fragPosLightSpace.xyz / fragPosLightSpace.w;
coord = coord * 0.5 + 0.5;
float lightViewDepth = texture(shadowMapTexture, coord.xy).x;
fragColor = vec3(lightViewDepth);
}
渲染大小为 1280x720,深度图大小为 512x512,看起来它在我的场景中重复深度图。我认为我对坐标的预测不正确。我想看看从像素到光的深度是否正确。有人能给我一些建议吗?
【问题讨论】:
-
scenePosTexture中的值存储在哪个空间?您是否检查过问题不是因为texCoord错误而重复scenePosTexture? -
我用世界空间位置存储了 scenePosTexture。我认为坐标在某种程度上是错误的。
-
这可能与我的问题有关,正在测试它:stackoverflow.com/questions/22880206/…
标签: opengl projection opengl-3 deferred-rendering deferred-shading