HDR: miscellaneous changes
- Add an utility linearizeDepth function to help visualize the depth buffer for debug purposes. - Use 'color0' instead of 'color' for all color attachments. - Do not write to the HDR buffer if a fragment doesn't need shading (depth = 1).
This commit is contained in:
parent
760db3ba6d
commit
af29642423
6 changed files with 67 additions and 22 deletions
|
@ -239,7 +239,7 @@
|
|||
<type>quad</type>
|
||||
<effect>Effects/HDR/atmos-transmittance</effect>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>transmittance</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -252,7 +252,7 @@
|
|||
<buffer>transmittance</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>multiple-scattering</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -269,7 +269,7 @@
|
|||
<buffer>multiple-scattering</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>sky-view</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -286,7 +286,7 @@
|
|||
<buffer>multiple-scattering</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>aerial-perspective</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -702,7 +702,7 @@
|
|||
<buffer>transmittance</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>hdr-result</buffer>
|
||||
</attachment>
|
||||
<attachment>
|
||||
|
@ -731,7 +731,7 @@
|
|||
<buffer>hdr-result</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>luminance</buffer>
|
||||
<mipmap-generation>true</mipmap-generation>
|
||||
</attachment>
|
||||
|
@ -749,7 +749,7 @@
|
|||
<buffer>luminance</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>adapted-luminance</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -762,7 +762,7 @@
|
|||
<buffer>adapted-luminance</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>prev-luminance</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -787,7 +787,7 @@
|
|||
<buffer>adapted-luminance</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom0</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -799,7 +799,7 @@
|
|||
<buffer>bloom0</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom1</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -810,7 +810,7 @@
|
|||
<buffer>bloom1</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom2</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -821,7 +821,7 @@
|
|||
<buffer>bloom2</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom3</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -833,7 +833,7 @@
|
|||
<buffer>bloom3</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom3-tmp</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -844,7 +844,7 @@
|
|||
<buffer>bloom3-tmp</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom3</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -860,7 +860,7 @@
|
|||
<buffer>bloom3</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom2-tmp</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -871,7 +871,7 @@
|
|||
<buffer>bloom2-tmp</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom2</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -887,7 +887,7 @@
|
|||
<buffer>bloom2</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom1-tmp</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -898,7 +898,7 @@
|
|||
<buffer>bloom1-tmp</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom1</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -914,7 +914,7 @@
|
|||
<buffer>bloom1</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom0-tmp</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -925,7 +925,7 @@
|
|||
<buffer>bloom0-tmp</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>bloom0</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
@ -953,7 +953,7 @@
|
|||
<buffer>bloom0</buffer>
|
||||
</binding>
|
||||
<attachment>
|
||||
<component>color</component>
|
||||
<component>color0</component>
|
||||
<buffer>final</buffer>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
|
18
Effects/HDR/visualize-depth.eff
Normal file
18
Effects/HDR/visualize-depth.eff
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PropertyList>
|
||||
<name>Effects/HDR/visualize-depth</name>
|
||||
<technique n="1">
|
||||
<pass>
|
||||
<program>
|
||||
<vertex-shader>Shaders/HDR/trivial.vert</vertex-shader>
|
||||
<fragment-shader>Shaders/HDR/visualize-depth.frag</fragment-shader>
|
||||
<fragment-shader>Shaders/HDR/gbuffer-include.frag</fragment-shader>
|
||||
</program>
|
||||
<uniform>
|
||||
<name>tex</name>
|
||||
<type>sampler-2d</type>
|
||||
<value type="int">0</value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
|
@ -1,6 +1,7 @@
|
|||
#version 330 core
|
||||
|
||||
uniform mat4 fg_ProjectionMatrixInverse;
|
||||
uniform vec2 fg_NearFar;
|
||||
|
||||
// https://aras-p.info/texts/CompactNormalStorage.html
|
||||
// Method #4: Spheremap Transform
|
||||
|
@ -30,3 +31,10 @@ vec3 positionFromDepth(vec2 pos, float depth)
|
|||
p.xyz /= p.w;
|
||||
return p.xyz;
|
||||
}
|
||||
|
||||
// http://www.geeks3d.com/20091216/geexlab-how-to-visualize-the-depth-buffer-in-glsl/
|
||||
float linearizeDepth(float depth)
|
||||
{
|
||||
return (2.0 * fg_NearFar.x) / (
|
||||
fg_NearFar.y + fg_NearFar.x - depth * (fg_NearFar.y - fg_NearFar.x));
|
||||
}
|
||||
|
|
|
@ -364,6 +364,11 @@ vec4 sampleAerialPerspective(float depth)
|
|||
void main()
|
||||
{
|
||||
float depth = texture(depth_tex, texCoord).r;
|
||||
if (depth == 1.0) {
|
||||
fragHdrColor = vec3(0.0);
|
||||
return;
|
||||
}
|
||||
|
||||
vec4 gbuffer0 = texture(gbuffer0_tex, texCoord);
|
||||
vec2 gbuffer1 = texture(gbuffer1_tex, texCoord).rg;
|
||||
vec4 gbuffer2 = texture(gbuffer2_tex, texCoord);
|
||||
|
|
14
Shaders/HDR/visualize-depth.frag
Normal file
14
Shaders/HDR/visualize-depth.frag
Normal file
|
@ -0,0 +1,14 @@
|
|||
#version 330 core
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
in vec2 texCoord;
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
float linearizeDepth(float depth);
|
||||
|
||||
void main()
|
||||
{
|
||||
fragColor = vec4(linearizeDepth(texture(tex, texCoord).r));
|
||||
}
|
Loading…
Add table
Reference in a new issue