diff --git a/Compositor/HDR/hdr.xml b/Compositor/HDR/hdr.xml index 9a790fa06..f8b39e725 100644 --- a/Compositor/HDR/hdr.xml +++ b/Compositor/HDR/hdr.xml @@ -1301,7 +1301,7 @@ debug-depth - Effects/HDR/visualize-depth + Effects/HDR/gbuffer-debug-depth 0.8 0.8 diff --git a/Effects/HDR/adapt-luminance.eff b/Effects/HDR/adapt-luminance.eff index 8b3e01767..e1ecc952e 100644 --- a/Effects/HDR/adapt-luminance.eff +++ b/Effects/HDR/adapt-luminance.eff @@ -4,7 +4,7 @@ - Shaders/HDR/adapt-luminance.vert + Shaders/HDR/trivial-notexcoord.vert Shaders/HDR/adapt-luminance.frag diff --git a/Effects/HDR/copy-prev-luminance.eff b/Effects/HDR/copy-prev-luminance.eff index 38dfd49ae..cb30811cd 100644 --- a/Effects/HDR/copy-prev-luminance.eff +++ b/Effects/HDR/copy-prev-luminance.eff @@ -4,7 +4,7 @@ - Shaders/HDR/adapt-luminance.vert + Shaders/HDR/trivial-notexcoord.vert Shaders/HDR/copy-prev-luminance.frag diff --git a/Effects/HDR/gbuffer-debug-color.eff b/Effects/HDR/gbuffer-debug-color.eff index 871244348..e4dd653b7 100644 --- a/Effects/HDR/gbuffer-debug-color.eff +++ b/Effects/HDR/gbuffer-debug-color.eff @@ -4,7 +4,7 @@ - Shaders/HDR/trivial.vert + Shaders/HDR/trivial-quad.vert Shaders/HDR/gbuffer-debug-color.frag diff --git a/Effects/HDR/visualize-depth.eff b/Effects/HDR/gbuffer-debug-depth.eff similarity index 59% rename from Effects/HDR/visualize-depth.eff rename to Effects/HDR/gbuffer-debug-depth.eff index 2395f13db..a59338a3e 100644 --- a/Effects/HDR/visualize-depth.eff +++ b/Effects/HDR/gbuffer-debug-depth.eff @@ -1,15 +1,15 @@ - Effects/HDR/visualize-depth + Effects/HDR/gbuffer-debug-depth - Shaders/HDR/trivial.vert - Shaders/HDR/visualize-depth.frag + Shaders/HDR/trivial-quad.vert + Shaders/HDR/gbuffer-debug-depth.frag Shaders/HDR/gbuffer-include.frag - tex + depth_tex sampler-2d 0 diff --git a/Effects/HDR/gbuffer-debug-matid.eff b/Effects/HDR/gbuffer-debug-matid.eff index 8df7ebe07..3b9b4aea5 100644 --- a/Effects/HDR/gbuffer-debug-matid.eff +++ b/Effects/HDR/gbuffer-debug-matid.eff @@ -4,7 +4,7 @@ - Shaders/HDR/trivial.vert + Shaders/HDR/trivial-quad.vert Shaders/HDR/gbuffer-debug-matid.frag diff --git a/Effects/HDR/gbuffer-debug-normal.eff b/Effects/HDR/gbuffer-debug-normal.eff index 804f18830..3a4a786e8 100644 --- a/Effects/HDR/gbuffer-debug-normal.eff +++ b/Effects/HDR/gbuffer-debug-normal.eff @@ -4,7 +4,7 @@ - Shaders/HDR/trivial.vert + Shaders/HDR/trivial-quad.vert Shaders/HDR/gbuffer-debug-normal.frag diff --git a/Effects/HDR/gbuffer-debug-orm.eff b/Effects/HDR/gbuffer-debug-orm.eff index 88efaf252..72a56ab91 100644 --- a/Effects/HDR/gbuffer-debug-orm.eff +++ b/Effects/HDR/gbuffer-debug-orm.eff @@ -4,7 +4,7 @@ - Shaders/HDR/trivial.vert + Shaders/HDR/trivial-quad.vert Shaders/HDR/gbuffer-debug-orm.frag diff --git a/Effects/chrome.eff b/Effects/chrome.eff index 86f321afc..c27164d73 100644 --- a/Effects/chrome.eff +++ b/Effects/chrome.eff @@ -89,4 +89,20 @@ + + hdr-shadow + + 0 0 0 0 + back + 0 + + 1.1 + 4.0 + + + Shaders/HDR/geometry-shadow.vert + Shaders/HDR/geometry-shadow.frag + + + diff --git a/Shaders/HDR/envmap-prefilter.vert b/Shaders/HDR/envmap-prefilter.vert index 039ccba2d..d5ca21245 100644 --- a/Shaders/HDR/envmap-prefilter.vert +++ b/Shaders/HDR/envmap-prefilter.vert @@ -1,8 +1,5 @@ #version 330 core -layout(location = 0) in vec4 pos; -layout(location = 3) in vec4 multiTexCoord0; - out vec3 cubemapCoord0; out vec3 cubemapCoord1; out vec3 cubemapCoord2; @@ -10,20 +7,18 @@ out vec3 cubemapCoord3; out vec3 cubemapCoord4; out vec3 cubemapCoord5; -uniform mat4 osg_ModelViewProjectionMatrix; - void main() { - gl_Position = osg_ModelViewProjectionMatrix * pos; - vec2 texCoord = multiTexCoord0.xy * 2.0 - 1.0; + vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0; + gl_Position = vec4(pos, 0.0, 1.0); // Map the quad texture coordinates to a direction vector to sample // the cubemap. This assumes that we are using the weird left-handed // orientations given by the OpenGL spec. // See https://www.khronos.org/opengl/wiki/Cubemap_Texture#Upload_and_orientation - cubemapCoord0 = vec3(1.0, -texCoord.y, -texCoord.x); - cubemapCoord1 = vec3(-1.0, -texCoord.y, texCoord.x); - cubemapCoord2 = vec3(texCoord.x, 1.0, texCoord.y); - cubemapCoord3 = vec3(texCoord.x, -1.0, -texCoord.y); - cubemapCoord4 = vec3(texCoord.x, -texCoord.y, 1.0); - cubemapCoord5 = vec3(-texCoord.x, -texCoord.y, -1.0); + cubemapCoord0 = vec3(1.0, -pos.y, -pos.x); + cubemapCoord1 = vec3(-1.0, -pos.y, pos.x); + cubemapCoord2 = vec3(pos.x, 1.0, pos.y); + cubemapCoord3 = vec3(pos.x, -1.0, -pos.y); + cubemapCoord4 = vec3(pos.x, -pos.y, 1.0); + cubemapCoord5 = vec3(-pos.x, -pos.y, -1.0); } diff --git a/Shaders/HDR/fxaa.vert b/Shaders/HDR/fxaa.vert index 8fa6357b8..436fe6837 100644 --- a/Shaders/HDR/fxaa.vert +++ b/Shaders/HDR/fxaa.vert @@ -1,22 +1,20 @@ #version 330 core -layout(location = 0) in vec4 pos; -layout(location = 3) in vec4 multiTexCoord0; - out vec2 texCoord; out vec4 posPos; -uniform mat4 osg_ModelViewProjectionMatrix; - uniform sampler2D color_tex; const float FXAA_SUBPIX_SHIFT = 1.0/4.0; void main() { - gl_Position = osg_ModelViewProjectionMatrix * pos; - texCoord = multiTexCoord0.st; + vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0; + texCoord = pos * 0.5 + 0.5; + vec2 rcpFrame = 1.0 / textureSize(color_tex, 0); - posPos.xy = multiTexCoord0.xy; - posPos.zw = multiTexCoord0.xy - (rcpFrame * (0.5 + FXAA_SUBPIX_SHIFT)); + posPos.xy = texCoord; + posPos.zw = texCoord - (rcpFrame * (0.5 + FXAA_SUBPIX_SHIFT)); + + gl_Position = vec4(pos, 0.0, 1.0); } diff --git a/Shaders/HDR/gbuffer-debug-depth.frag b/Shaders/HDR/gbuffer-debug-depth.frag new file mode 100644 index 000000000..bf2173eda --- /dev/null +++ b/Shaders/HDR/gbuffer-debug-depth.frag @@ -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); +} diff --git a/Shaders/HDR/smaa-blending-weight-calculation.vert b/Shaders/HDR/smaa-blending-weight-calculation.vert index 5c098859a..22493925c 100644 --- a/Shaders/HDR/smaa-blending-weight-calculation.vert +++ b/Shaders/HDR/smaa-blending-weight-calculation.vert @@ -39,23 +39,19 @@ #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 pixCoord; out vec4 vOffset[3]; -uniform mat4 osg_ModelViewProjectionMatrix; - 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) void main() { - gl_Position = osg_ModelViewProjectionMatrix * pos; - texCoord = multiTexCoord0.st; + vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0; + texCoord = pos * 0.5 + 0.5; + gl_Position = vec4(pos, 0.0, 1.0); pixCoord = texCoord * SMAA_RT_METRICS.zw; diff --git a/Shaders/HDR/smaa-edge-detection.vert b/Shaders/HDR/smaa-edge-detection.vert index 745511c95..bc5c5d3a2 100644 --- a/Shaders/HDR/smaa-edge-detection.vert +++ b/Shaders/HDR/smaa-edge-detection.vert @@ -37,21 +37,18 @@ #define mad(a, b, c) (a * b + c) -layout(location = 0) in vec4 pos; -layout(location = 3) in vec4 multiTexCoord0; - out vec2 texCoord; out vec4 vOffset[3]; -uniform mat4 osg_ModelViewProjectionMatrix; 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) void main() { - gl_Position = osg_ModelViewProjectionMatrix * pos; - texCoord = multiTexCoord0.st; + vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0; + 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[1] = mad(SMAA_RT_METRICS.xyxy, vec4( 1.0, 0.0, 0.0, 1.0), texCoord.xyxy); diff --git a/Shaders/HDR/smaa-neighborhood-blending.vert b/Shaders/HDR/smaa-neighborhood-blending.vert index 75b334023..0ce4ee56b 100644 --- a/Shaders/HDR/smaa-neighborhood-blending.vert +++ b/Shaders/HDR/smaa-neighborhood-blending.vert @@ -37,21 +37,18 @@ #define mad(a, b, c) (a * b + c) -layout(location = 0) in vec4 pos; -layout(location = 3) in vec4 multiTexCoord0; - out vec2 texCoord; out vec4 vOffset; -uniform mat4 osg_ModelViewProjectionMatrix; 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) void main() { - gl_Position = osg_ModelViewProjectionMatrix * pos; - texCoord = multiTexCoord0.st; + vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0; + 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); } diff --git a/Shaders/HDR/trivial-notexcoord.vert b/Shaders/HDR/trivial-notexcoord.vert new file mode 100644 index 000000000..94bbc6d8b --- /dev/null +++ b/Shaders/HDR/trivial-notexcoord.vert @@ -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); +} diff --git a/Shaders/HDR/adapt-luminance.vert b/Shaders/HDR/trivial-quad.vert similarity index 63% rename from Shaders/HDR/adapt-luminance.vert rename to Shaders/HDR/trivial-quad.vert index 3cc1a3edb..518a8d13f 100644 --- a/Shaders/HDR/adapt-luminance.vert +++ b/Shaders/HDR/trivial-quad.vert @@ -1,10 +1,14 @@ #version 330 core layout(location = 0) in vec4 pos; +layout(location = 3) in vec4 multiTexCoord0; + +out vec2 texCoord; uniform mat4 osg_ModelViewProjectionMatrix; void main() { gl_Position = osg_ModelViewProjectionMatrix * pos; + texCoord = multiTexCoord0.st; } diff --git a/Shaders/HDR/trivial.vert b/Shaders/HDR/trivial.vert index 518a8d13f..3c89260eb 100644 --- a/Shaders/HDR/trivial.vert +++ b/Shaders/HDR/trivial.vert @@ -1,14 +1,10 @@ #version 330 core -layout(location = 0) in vec4 pos; -layout(location = 3) in vec4 multiTexCoord0; - out vec2 texCoord; -uniform mat4 osg_ModelViewProjectionMatrix; - void main() { - gl_Position = osg_ModelViewProjectionMatrix * pos; - texCoord = multiTexCoord0.st; + vec2 pos = vec2(gl_VertexID % 2, gl_VertexID / 2) * 4.0 - 1.0; + texCoord = pos * 0.5 + 0.5; + gl_Position = vec4(pos, 0.0, 1.0); } diff --git a/Shaders/HDR/visualize-depth.frag b/Shaders/HDR/visualize-depth.frag deleted file mode 100644 index bd72047bf..000000000 --- a/Shaders/HDR/visualize-depth.frag +++ /dev/null @@ -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)); -}