Merge branch 'master' into master

This commit is contained in:
Jon Daniel 2025-04-13 23:59:57 +02:00 • committed by GitHub
commit db4efbce74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 113 additions and 81 deletions

View file

@ -10,12 +10,6 @@ uniform bool flipY;
float nearPlane = 0.1;
float farPlane = 100.0;
// Function to linearize depth from non-linear depth buffer
float linearizeDepth(float depth)
{
return (2.0 * nearPlane) / (farPlane + nearPlane - depth * (farPlane - nearPlane));
}
void main()
{
// Handle potential Y-flipping
@ -27,7 +21,7 @@ void main()
float depth = texture2D(depthTexture, texCoord).r;
// Linearize depth
float linearDepth = linearizeDepth(depth);
float linearDepth = (2.0*nearPlane)/(farPlane + nearPlane - depth*(farPlane - nearPlane));
// Output final color
gl_FragColor = vec4(vec3(linearDepth), 1.0);

View file

@ -13,24 +13,17 @@ const float farPlane = 100.0;
// Output fragment color
out vec4 finalColor;
// Linearizes the depth buffer value
float linearizeDepth(float depth)
{
return (2.0 * nearPlane) / (farPlane + nearPlane - depth * (farPlane - nearPlane));
}
void main()
{
// Handle potential Y-flipping
vec2 texCoord = fragTexCoord;
if (flipY)
texCoord.y = 1.0 - texCoord.y;
if (flipY) texCoord.y = 1.0 - texCoord.y;
// Sample depth
float depth = texture(depthTexture, texCoord).r;
// Linearize depth value
float linearDepth = linearizeDepth(depth);
float linearDepth = (2.0*nearPlane)/(farPlane + nearPlane - depth*(farPlane - nearPlane));
// Output final color
finalColor = vec4(vec3(linearDepth), 1.0);