HDR: Use gl_VertexID instead of the MVP matrix in fullscreen passes
This commit is contained in:
parent
68997879d3
commit
3459e7ddfe
19 changed files with 80 additions and 73 deletions
|
@ -1301,7 +1301,7 @@
|
||||||
</pass>
|
</pass>
|
||||||
<pass include="debug-pass.xml">
|
<pass include="debug-pass.xml">
|
||||||
<name>debug-depth</name>
|
<name>debug-depth</name>
|
||||||
<effect>Effects/HDR/visualize-depth</effect>
|
<effect>Effects/HDR/gbuffer-debug-depth</effect>
|
||||||
<geometry>
|
<geometry>
|
||||||
<left>0.8</left>
|
<left>0.8</left>
|
||||||
<bottom>0.8</bottom>
|
<bottom>0.8</bottom>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<technique n="1">
|
<technique n="1">
|
||||||
<pass>
|
<pass>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/adapt-luminance.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/trivial-notexcoord.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/adapt-luminance.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/adapt-luminance.frag</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
<uniform>
|
<uniform>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<technique n="1">
|
<technique n="1">
|
||||||
<pass>
|
<pass>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/adapt-luminance.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/trivial-notexcoord.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/copy-prev-luminance.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/copy-prev-luminance.frag</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
<uniform>
|
<uniform>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<technique n="1">
|
<technique n="1">
|
||||||
<pass>
|
<pass>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/trivial.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/trivial-quad.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer-debug-color.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer-debug-color.frag</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
<uniform>
|
<uniform>
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PropertyList>
|
<PropertyList>
|
||||||
<name>Effects/HDR/visualize-depth</name>
|
<name>Effects/HDR/gbuffer-debug-depth</name>
|
||||||
<technique n="1">
|
<technique n="1">
|
||||||
<pass>
|
<pass>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/trivial.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/trivial-quad.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/visualize-depth.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer-debug-depth.frag</fragment-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer-include.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer-include.frag</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>tex</name>
|
<name>depth_tex</name>
|
||||||
<type>sampler-2d</type>
|
<type>sampler-2d</type>
|
||||||
<value type="int">0</value>
|
<value type="int">0</value>
|
||||||
</uniform>
|
</uniform>
|
|
@ -4,7 +4,7 @@
|
||||||
<technique n="1">
|
<technique n="1">
|
||||||
<pass>
|
<pass>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/trivial.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/trivial-quad.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer-debug-matid.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer-debug-matid.frag</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
<uniform>
|
<uniform>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<technique n="1">
|
<technique n="1">
|
||||||
<pass>
|
<pass>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/trivial.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/trivial-quad.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer-debug-normal.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer-debug-normal.frag</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
<uniform>
|
<uniform>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<technique n="1">
|
<technique n="1">
|
||||||
<pass>
|
<pass>
|
||||||
<program>
|
<program>
|
||||||
<vertex-shader>Shaders/HDR/trivial.vert</vertex-shader>
|
<vertex-shader>Shaders/HDR/trivial-quad.vert</vertex-shader>
|
||||||
<fragment-shader>Shaders/HDR/gbuffer-debug-orm.frag</fragment-shader>
|
<fragment-shader>Shaders/HDR/gbuffer-debug-orm.frag</fragment-shader>
|
||||||
</program>
|
</program>
|
||||||
<uniform>
|
<uniform>
|
||||||
|
|
|
@ -89,4 +89,20 @@
|
||||||
</program>
|
</program>
|
||||||
</pass>
|
</pass>
|
||||||
</technique>
|
</technique>
|
||||||
|
<technique n="119">
|
||||||
|
<scheme>hdr-shadow</scheme>
|
||||||
|
<pass>
|
||||||
|
<color-mask type="vec4d">0 0 0 0</color-mask>
|
||||||
|
<cull-face>back</cull-face>
|
||||||
|
<blend>0</blend>
|
||||||
|
<polygon-offset>
|
||||||
|
<factor>1.1</factor>
|
||||||
|
<units>4.0</units>
|
||||||
|
</polygon-offset>
|
||||||
|
<program>
|
||||||
|
<vertex-shader>Shaders/HDR/geometry-shadow.vert</vertex-shader>
|
||||||
|
<fragment-shader>Shaders/HDR/geometry-shadow.frag</fragment-shader>
|
||||||
|
</program>
|
||||||
|
</pass>
|
||||||
|
</technique>
|
||||||
</PropertyList>
|
</PropertyList>
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
layout(location = 0) in vec4 pos;
|
|
||||||
layout(location = 3) in vec4 multiTexCoord0;
|
|
||||||
|
|
||||||
out vec3 cubemapCoord0;
|
out vec3 cubemapCoord0;
|
||||||
out vec3 cubemapCoord1;
|
out vec3 cubemapCoord1;
|
||||||
out vec3 cubemapCoord2;
|
out vec3 cubemapCoord2;
|
||||||
|
@ -10,20 +7,18 @@ out vec3 cubemapCoord3;
|
||||||
out vec3 cubemapCoord4;
|
out vec3 cubemapCoord4;
|
||||||
out vec3 cubemapCoord5;
|
out vec3 cubemapCoord5;
|
||||||
|
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0;
|
||||||
vec2 texCoord = multiTexCoord0.xy * 2.0 - 1.0;
|
gl_Position = vec4(pos, 0.0, 1.0);
|
||||||
// Map the quad texture coordinates to a direction vector to sample
|
// Map the quad texture coordinates to a direction vector to sample
|
||||||
// the cubemap. This assumes that we are using the weird left-handed
|
// the cubemap. This assumes that we are using the weird left-handed
|
||||||
// orientations given by the OpenGL spec.
|
// orientations given by the OpenGL spec.
|
||||||
// See https://www.khronos.org/opengl/wiki/Cubemap_Texture#Upload_and_orientation
|
// See https://www.khronos.org/opengl/wiki/Cubemap_Texture#Upload_and_orientation
|
||||||
cubemapCoord0 = vec3(1.0, -texCoord.y, -texCoord.x);
|
cubemapCoord0 = vec3(1.0, -pos.y, -pos.x);
|
||||||
cubemapCoord1 = vec3(-1.0, -texCoord.y, texCoord.x);
|
cubemapCoord1 = vec3(-1.0, -pos.y, pos.x);
|
||||||
cubemapCoord2 = vec3(texCoord.x, 1.0, texCoord.y);
|
cubemapCoord2 = vec3(pos.x, 1.0, pos.y);
|
||||||
cubemapCoord3 = vec3(texCoord.x, -1.0, -texCoord.y);
|
cubemapCoord3 = vec3(pos.x, -1.0, -pos.y);
|
||||||
cubemapCoord4 = vec3(texCoord.x, -texCoord.y, 1.0);
|
cubemapCoord4 = vec3(pos.x, -pos.y, 1.0);
|
||||||
cubemapCoord5 = vec3(-texCoord.x, -texCoord.y, -1.0);
|
cubemapCoord5 = vec3(-pos.x, -pos.y, -1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
layout(location = 0) in vec4 pos;
|
|
||||||
layout(location = 3) in vec4 multiTexCoord0;
|
|
||||||
|
|
||||||
out vec2 texCoord;
|
out vec2 texCoord;
|
||||||
out vec4 posPos;
|
out vec4 posPos;
|
||||||
|
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
|
||||||
|
|
||||||
uniform sampler2D color_tex;
|
uniform sampler2D color_tex;
|
||||||
|
|
||||||
const float FXAA_SUBPIX_SHIFT = 1.0/4.0;
|
const float FXAA_SUBPIX_SHIFT = 1.0/4.0;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0;
|
||||||
texCoord = multiTexCoord0.st;
|
texCoord = pos * 0.5 + 0.5;
|
||||||
|
|
||||||
vec2 rcpFrame = 1.0 / textureSize(color_tex, 0);
|
vec2 rcpFrame = 1.0 / textureSize(color_tex, 0);
|
||||||
posPos.xy = multiTexCoord0.xy;
|
posPos.xy = texCoord;
|
||||||
posPos.zw = multiTexCoord0.xy - (rcpFrame * (0.5 + FXAA_SUBPIX_SHIFT));
|
posPos.zw = texCoord - (rcpFrame * (0.5 + FXAA_SUBPIX_SHIFT));
|
||||||
|
|
||||||
|
gl_Position = vec4(pos, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
15
Shaders/HDR/gbuffer-debug-depth.frag
Normal file
15
Shaders/HDR/gbuffer-debug-depth.frag
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
in vec2 texCoord;
|
||||||
|
|
||||||
|
uniform sampler2D depth_tex;
|
||||||
|
|
||||||
|
float linearizeDepth(float depth);
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
float depth = texture(depth_tex, texCoord).r;
|
||||||
|
fragColor = vec4(vec3(linearizeDepth(depth)), 1.0);
|
||||||
|
}
|
|
@ -39,23 +39,19 @@
|
||||||
|
|
||||||
#define mad(a, b, c) (a * b + c)
|
#define mad(a, b, c) (a * b + c)
|
||||||
|
|
||||||
layout(location = 0) in vec4 pos;
|
|
||||||
layout(location = 3) in vec4 multiTexCoord0;
|
|
||||||
|
|
||||||
out vec2 texCoord;
|
out vec2 texCoord;
|
||||||
out vec2 pixCoord;
|
out vec2 pixCoord;
|
||||||
out vec4 vOffset[3];
|
out vec4 vOffset[3];
|
||||||
|
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
|
||||||
|
|
||||||
uniform vec4 fg_Viewport;
|
uniform vec4 fg_Viewport;
|
||||||
|
|
||||||
#define SMAA_RT_METRICS vec4(1.0 / fg_Viewport.z, 1.0 / fg_Viewport.w, fg_Viewport.z, fg_Viewport.w)
|
#define SMAA_RT_METRICS vec4(1.0 / fg_Viewport.z, 1.0 / fg_Viewport.w, fg_Viewport.z, fg_Viewport.w)
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0;
|
||||||
texCoord = multiTexCoord0.st;
|
texCoord = pos * 0.5 + 0.5;
|
||||||
|
gl_Position = vec4(pos, 0.0, 1.0);
|
||||||
|
|
||||||
pixCoord = texCoord * SMAA_RT_METRICS.zw;
|
pixCoord = texCoord * SMAA_RT_METRICS.zw;
|
||||||
|
|
||||||
|
|
|
@ -37,21 +37,18 @@
|
||||||
|
|
||||||
#define mad(a, b, c) (a * b + c)
|
#define mad(a, b, c) (a * b + c)
|
||||||
|
|
||||||
layout(location = 0) in vec4 pos;
|
|
||||||
layout(location = 3) in vec4 multiTexCoord0;
|
|
||||||
|
|
||||||
out vec2 texCoord;
|
out vec2 texCoord;
|
||||||
out vec4 vOffset[3];
|
out vec4 vOffset[3];
|
||||||
|
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
|
||||||
uniform vec4 fg_Viewport;
|
uniform vec4 fg_Viewport;
|
||||||
|
|
||||||
#define SMAA_RT_METRICS vec4(1.0 / fg_Viewport.z, 1.0 / fg_Viewport.w, fg_Viewport.z, fg_Viewport.w)
|
#define SMAA_RT_METRICS vec4(1.0 / fg_Viewport.z, 1.0 / fg_Viewport.w, fg_Viewport.z, fg_Viewport.w)
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0;
|
||||||
texCoord = multiTexCoord0.st;
|
texCoord = pos * 0.5 + 0.5;
|
||||||
|
gl_Position = vec4(pos, 0.0, 1.0);
|
||||||
|
|
||||||
vOffset[0] = mad(SMAA_RT_METRICS.xyxy, vec4(-1.0, 0.0, 0.0, -1.0), texCoord.xyxy);
|
vOffset[0] = mad(SMAA_RT_METRICS.xyxy, vec4(-1.0, 0.0, 0.0, -1.0), texCoord.xyxy);
|
||||||
vOffset[1] = mad(SMAA_RT_METRICS.xyxy, vec4( 1.0, 0.0, 0.0, 1.0), texCoord.xyxy);
|
vOffset[1] = mad(SMAA_RT_METRICS.xyxy, vec4( 1.0, 0.0, 0.0, 1.0), texCoord.xyxy);
|
||||||
|
|
|
@ -37,21 +37,18 @@
|
||||||
|
|
||||||
#define mad(a, b, c) (a * b + c)
|
#define mad(a, b, c) (a * b + c)
|
||||||
|
|
||||||
layout(location = 0) in vec4 pos;
|
|
||||||
layout(location = 3) in vec4 multiTexCoord0;
|
|
||||||
|
|
||||||
out vec2 texCoord;
|
out vec2 texCoord;
|
||||||
out vec4 vOffset;
|
out vec4 vOffset;
|
||||||
|
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
|
||||||
uniform vec4 fg_Viewport;
|
uniform vec4 fg_Viewport;
|
||||||
|
|
||||||
#define SMAA_RT_METRICS vec4(1.0 / fg_Viewport.z, 1.0 / fg_Viewport.w, fg_Viewport.z, fg_Viewport.w)
|
#define SMAA_RT_METRICS vec4(1.0 / fg_Viewport.z, 1.0 / fg_Viewport.w, fg_Viewport.z, fg_Viewport.w)
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0;
|
||||||
texCoord = multiTexCoord0.st;
|
texCoord = pos * 0.5 + 0.5;
|
||||||
|
gl_Position = vec4(pos, 0.0, 1.0);
|
||||||
|
|
||||||
vOffset = mad(SMAA_RT_METRICS.xyxy, vec4(1.0, 0.0, 0.0, 1.0), texCoord.xyxy);
|
vOffset = mad(SMAA_RT_METRICS.xyxy, vec4(1.0, 0.0, 0.0, 1.0), texCoord.xyxy);
|
||||||
}
|
}
|
||||||
|
|
7
Shaders/HDR/trivial-notexcoord.vert
Normal file
7
Shaders/HDR/trivial-notexcoord.vert
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#version 330 core
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0;
|
||||||
|
gl_Position = vec4(pos, 0.0, 1.0);
|
||||||
|
}
|
|
@ -1,10 +1,14 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
layout(location = 0) in vec4 pos;
|
layout(location = 0) in vec4 pos;
|
||||||
|
layout(location = 3) in vec4 multiTexCoord0;
|
||||||
|
|
||||||
|
out vec2 texCoord;
|
||||||
|
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
uniform mat4 osg_ModelViewProjectionMatrix;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
||||||
|
texCoord = multiTexCoord0.st;
|
||||||
}
|
}
|
|
@ -1,14 +1,10 @@
|
||||||
#version 330 core
|
#version 330 core
|
||||||
|
|
||||||
layout(location = 0) in vec4 pos;
|
|
||||||
layout(location = 3) in vec4 multiTexCoord0;
|
|
||||||
|
|
||||||
out vec2 texCoord;
|
out vec2 texCoord;
|
||||||
|
|
||||||
uniform mat4 osg_ModelViewProjectionMatrix;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = osg_ModelViewProjectionMatrix * pos;
|
vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0;
|
||||||
texCoord = multiTexCoord0.st;
|
texCoord = pos * 0.5 + 0.5;
|
||||||
|
gl_Position = vec4(pos, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
#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…
Reference in a new issue