Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
9.2.2023: Due to updates GitLab will be unavailable for some minutes between 9:00 and 11:00.
Open sidebar
CAMP
campvis-public
Commits
19e69bc7
Commit
19e69bc7
authored
Dec 06, 2013
by
Christian Schulte zu Berge
Browse files
fixing depth texture access in GLSL shaders
parent
e2128a34
Changes
5
Hide whitespace changes
Inline
Side-by-side
core/glsl/copyimage.frag
View file @
19e69bc7
...
...
@@ -45,6 +45,6 @@ void main() {
out_Color
=
getElement2DNormalized
(
_colorTexture
,
_texParams
,
fragCoord
);
#ifndef NO_DEPTH
gl_FragDepth
=
getElement2DNormalized
(
_depthTexture
,
_texParams
,
fragCoord
).
z
;
gl_FragDepth
=
getElement2DNormalized
(
_depthTexture
,
_texParams
,
fragCoord
).
r
;
#endif
}
modules/vis/glsl/depthdarkening.frag
View file @
19e69bc7
...
...
@@ -89,7 +89,7 @@ float applyDepthGaussFilter(in vec2 texCoord) {
for
(
int
i
=
-
_halfKernelDimension
;
i
<=
_halfKernelDimension
;
++
i
)
{
// TODO: why the fuck does abs(i) not work here?!?
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
/=
_norm
;
...
...
@@ -110,7 +110,7 @@ void main() {
gl_FragDepth
=
filteredDepth
;
}
else
{
// 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
);
// apply depth darkening
...
...
modules/vis/glsl/quadview.frag
View file @
19e69bc7
...
...
@@ -38,5 +38,5 @@ uniform TextureParameters2D _texParams;
void
main
()
{
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
;
}
modules/vis/glsl/rendertargetcompositor.frag
View file @
19e69bc7
...
...
@@ -48,19 +48,19 @@ void main() {
if
(
_compositingMethod
==
0
)
{
// only first
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
)
{
// only second
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
)
{
// alpha blending
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
);
float
secondDepth
=
getElement2DNormalized
(
_secondDepth
,
_secondTexParams
,
ex_TexCoord
.
xy
).
z
;
float
secondDepth
=
getElement2DNormalized
(
_secondDepth
,
_secondTexParams
,
ex_TexCoord
.
xy
).
r
;
out_Color
=
mix
(
firstColor
,
secondColor
,
_alpha
);
gl_FragDepth
=
min
(
firstDepth
,
secondDepth
);
...
...
@@ -68,17 +68,17 @@ void main() {
else
if
(
_compositingMethod
==
3
)
{
// difference
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
);
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
));
gl_FragDepth
=
min
(
firstDepth
,
secondDepth
);
}
else
if
(
_compositingMethod
==
4
)
{
// depth test
float
firstDepth
=
getElement2DNormalized
(
_firstDepth
,
_firstTexParams
,
ex_TexCoord
.
xy
).
z
;
float
secondDepth
=
getElement2DNormalized
(
_secondDepth
,
_secondTexParams
,
ex_TexCoord
.
xy
).
z
;
float
firstDepth
=
getElement2DNormalized
(
_firstDepth
,
_firstTexParams
,
ex_TexCoord
.
xy
).
r
;
float
secondDepth
=
getElement2DNormalized
(
_secondDepth
,
_secondTexParams
,
ex_TexCoord
.
xy
).
r
;
if
(
firstDepth
>
secondDepth
)
{
out_Color
=
getElement2DNormalized
(
_secondColor
,
_secondTexParams
,
ex_TexCoord
.
xy
);
...
...
modules/vis/glsl/virtualmirrorcombine.frag
View file @
19e69bc7
...
...
@@ -45,8 +45,8 @@ uniform sampler2D _mirrorRenderedDepth;
uniform
TextureParameters2D
_mirrorRenderedTexParams
;
void
main
()
{
float
normalDepth
=
getElement2DNormalized
(
_normalDepth
,
_normalTexParams
,
ex_TexCoord
.
xy
).
z
;
float
mirrorRenderedDepth
=
getElement2DNormalized
(
_mirrorRenderedDepth
,
_mirrorRenderedTexParams
,
ex_TexCoord
.
xy
).
z
;
float
normalDepth
=
getElement2DNormalized
(
_normalDepth
,
_normalTexParams
,
ex_TexCoord
.
xy
).
r
;
float
mirrorRenderedDepth
=
getElement2DNormalized
(
_mirrorRenderedDepth
,
_mirrorRenderedTexParams
,
ex_TexCoord
.
xy
).
r
;
if
(
normalDepth
<=
mirrorRenderedDepth
)
{
out_Color
=
getElement2DNormalized
(
_normalColor
,
_normalTexParams
,
ex_TexCoord
.
xy
);
...
...
@@ -54,7 +54,7 @@ void main() {
}
else
{
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
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment