REVIEWED: Some PRs formating
This commit is contained in:
parent
cb111ad15e
commit
cc5739a6d7
11 changed files with 111 additions and 79 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue