The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 19e69bc7 authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

fixing depth texture access in GLSL shaders

parent e2128a34
...@@ -45,6 +45,6 @@ void main() { ...@@ -45,6 +45,6 @@ void main() {
out_Color = getElement2DNormalized(_colorTexture, _texParams, fragCoord); out_Color = getElement2DNormalized(_colorTexture, _texParams, fragCoord);
#ifndef NO_DEPTH #ifndef NO_DEPTH
gl_FragDepth = getElement2DNormalized(_depthTexture, _texParams, fragCoord).z; gl_FragDepth = getElement2DNormalized(_depthTexture, _texParams, fragCoord).r;
#endif #endif
} }
...@@ -89,7 +89,7 @@ float applyDepthGaussFilter(in vec2 texCoord) { ...@@ -89,7 +89,7 @@ float applyDepthGaussFilter(in vec2 texCoord) {
for (int i = -_halfKernelDimension; i <= _halfKernelDimension; ++i) { for (int i = -_halfKernelDimension; i <= _halfKernelDimension; ++i) {
// TODO: why the fuck does abs(i) not work here?!? // TODO: why the fuck does abs(i) not work here?!?
int absi = (i < 0) ? -i : i; int absi = (i < 0) ? -i : i;
float curDepth = getElement2DNormalized(_depthPass2Texture, _pass2TexParams, texCoord + (_direction * _viewportSizeRCP * i)).z; float curDepth = getElement2DNormalized(_depthPass2Texture, _pass2TexParams, texCoord + (_direction * _viewportSizeRCP * i)).r;
result += curDepth * _gaussKernel[absi]; result += curDepth * _gaussKernel[absi];
} }
result /= _norm; result /= _norm;
...@@ -110,7 +110,7 @@ void main() { ...@@ -110,7 +110,7 @@ void main() {
gl_FragDepth = filteredDepth; gl_FragDepth = filteredDepth;
} else { } else {
// we are in the second vertical pass and have to modulate the color // we are in the second vertical pass and have to modulate the color
float curDepth = getElement2DNormalized(_depthTexture, _texParams, texCoord).z; float curDepth = getElement2DNormalized(_depthTexture, _texParams, texCoord).r;
float deltaD = normalizeDepth(filteredDepth) - normalizeDepth(curDepth); float deltaD = normalizeDepth(filteredDepth) - normalizeDepth(curDepth);
// apply depth darkening // apply depth darkening
......
...@@ -38,5 +38,5 @@ uniform TextureParameters2D _texParams; ...@@ -38,5 +38,5 @@ uniform TextureParameters2D _texParams;
void main() { void main() {
out_Color = getElement2DNormalized(_colorTexture, _texParams, ex_TexCoord.xy); out_Color = getElement2DNormalized(_colorTexture, _texParams, ex_TexCoord.xy);
gl_FragDepth = getElement2DNormalized(_depthTexture, _texParams, ex_TexCoord.xy).z; gl_FragDepth = getElement2DNormalized(_depthTexture, _texParams, ex_TexCoord.xy).r;
} }
...@@ -48,19 +48,19 @@ void main() { ...@@ -48,19 +48,19 @@ void main() {
if (_compositingMethod == 0) { if (_compositingMethod == 0) {
// only first // only first
out_Color = getElement2DNormalized(_firstColor, _firstTexParams, ex_TexCoord.xy); out_Color = getElement2DNormalized(_firstColor, _firstTexParams, ex_TexCoord.xy);
gl_FragDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).z; gl_FragDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).r;
} }
else if (_compositingMethod == 1) { else if (_compositingMethod == 1) {
// only second // only second
out_Color = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy); out_Color = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy);
gl_FragDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).z; gl_FragDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).r;
} }
else if (_compositingMethod == 2) { else if (_compositingMethod == 2) {
// alpha blending // alpha blending
vec4 firstColor = getElement2DNormalized(_firstColor, _firstTexParams, ex_TexCoord.xy); vec4 firstColor = getElement2DNormalized(_firstColor, _firstTexParams, ex_TexCoord.xy);
float firstDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).z; float firstDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).r;
vec4 secondColor = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy); vec4 secondColor = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy);
float secondDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).z; float secondDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).r;
out_Color = mix(firstColor, secondColor, _alpha); out_Color = mix(firstColor, secondColor, _alpha);
gl_FragDepth = min(firstDepth, secondDepth); gl_FragDepth = min(firstDepth, secondDepth);
...@@ -68,17 +68,17 @@ void main() { ...@@ -68,17 +68,17 @@ void main() {
else if (_compositingMethod == 3) { else if (_compositingMethod == 3) {
// difference // difference
vec4 firstColor = getElement2DNormalized(_firstColor, _firstTexParams, ex_TexCoord.xy); vec4 firstColor = getElement2DNormalized(_firstColor, _firstTexParams, ex_TexCoord.xy);
float firstDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).z; float firstDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).r;
vec4 secondColor = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy); vec4 secondColor = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy);
float secondDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).z; float secondDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).r;
out_Color = vec4(vec3(1.0) - abs(firstColor - secondColor).xyz, max(firstColor.w, secondColor.w)); out_Color = vec4(vec3(1.0) - abs(firstColor - secondColor).xyz, max(firstColor.w, secondColor.w));
gl_FragDepth = min(firstDepth, secondDepth); gl_FragDepth = min(firstDepth, secondDepth);
} }
else if (_compositingMethod == 4) { else if (_compositingMethod == 4) {
// depth test // depth test
float firstDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).z; float firstDepth = getElement2DNormalized(_firstDepth, _firstTexParams, ex_TexCoord.xy).r;
float secondDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).z; float secondDepth = getElement2DNormalized(_secondDepth, _secondTexParams, ex_TexCoord.xy).r;
if (firstDepth > secondDepth) { if (firstDepth > secondDepth) {
out_Color = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy); out_Color = getElement2DNormalized(_secondColor, _secondTexParams, ex_TexCoord.xy);
......
...@@ -45,8 +45,8 @@ uniform sampler2D _mirrorRenderedDepth; ...@@ -45,8 +45,8 @@ uniform sampler2D _mirrorRenderedDepth;
uniform TextureParameters2D _mirrorRenderedTexParams; uniform TextureParameters2D _mirrorRenderedTexParams;
void main() { void main() {
float normalDepth = getElement2DNormalized(_normalDepth, _normalTexParams, ex_TexCoord.xy).z; float normalDepth = getElement2DNormalized(_normalDepth, _normalTexParams, ex_TexCoord.xy).r;
float mirrorRenderedDepth = getElement2DNormalized(_mirrorRenderedDepth, _mirrorRenderedTexParams, ex_TexCoord.xy).z; float mirrorRenderedDepth = getElement2DNormalized(_mirrorRenderedDepth, _mirrorRenderedTexParams, ex_TexCoord.xy).r;
if (normalDepth <= mirrorRenderedDepth) { if (normalDepth <= mirrorRenderedDepth) {
out_Color = getElement2DNormalized(_normalColor, _normalTexParams, ex_TexCoord.xy); out_Color = getElement2DNormalized(_normalColor, _normalTexParams, ex_TexCoord.xy);
...@@ -54,7 +54,7 @@ void main() { ...@@ -54,7 +54,7 @@ void main() {
} }
else { else {
out_Color = getElement2DNormalized(_mirrorColor, _mirrorTexParams, ex_TexCoord.xy); out_Color = getElement2DNormalized(_mirrorColor, _mirrorTexParams, ex_TexCoord.xy);
gl_FragDepth = getElement2DNormalized(_mirrorDepth, _mirrorTexParams, ex_TexCoord.xy).z; gl_FragDepth = getElement2DNormalized(_mirrorDepth, _mirrorTexParams, ex_TexCoord.xy).r;
} }
if (out_Color.a == 0) { if (out_Color.a == 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment