forked from LeenkxTeam/LNXSDK
Converted rendering engine to reverse-z
This commit is contained in:
@ -23,8 +23,8 @@ void main() {
|
||||
// fullscreen triangle: http://de.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau
|
||||
// gl_Position = vec4((gl_VertexID % 2) * 4.0 - 1.0, (gl_VertexID / 2) * 4.0 - 1.0, 0.0, 1.0);
|
||||
|
||||
// NDC (at the back of cube)
|
||||
vec4 v = vec4(pos.x, pos.y, 1.0, 1.0);
|
||||
// For reverse-Z, the “far” plane lives at NDC z = 0
|
||||
vec4 v = vec4(pos.x, pos.y, 0.0, 1.0);
|
||||
v = vec4(invVP * v);
|
||||
v.xyz /= v.w;
|
||||
viewRay = v.xyz - eye;
|
||||
|
@ -19,8 +19,9 @@ void main() {
|
||||
|
||||
gl_Position = vec4(pos.xy, 0.0, 1.0);
|
||||
|
||||
// NDC (at the back of cube)
|
||||
vec4 v = vec4(pos.x, pos.y, 1.0, 1.0);
|
||||
v = vec4(invP * v);
|
||||
// For reverse-Z, far plane sits at NDC z = 0
|
||||
vec4 clip = vec4(pos.x, pos.y, 0.0, 1.0);
|
||||
vec4 v = invP * clip;
|
||||
// reconstruct a view‐space direction
|
||||
viewRay = vec3(v.xy / v.z, 1.0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user