我试图通过将屏幕空间点投影回视图空间以与照明一起使用来避免使用位置缓冲区。我试过乘以逆投影矩阵,但这并没有返回视图空间点。添加矩阵乘法以避免位置缓冲区是否值得?
最终通道着色器:
vec3 ScreenSpace = vec3(0.0,0.0,0.0);
ScreenSpace.xy = (texcoord.xy * 2.0) - 1.0;
ScreenSpace.z = texture2D(depthtex, texcoord.xy);
vec4 ViewSpace = InvProjectionMatrix * vec3(ScreenSpace, 1.0);
ViewSpace.xyz = ViewSpace.w;