Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
3f8f883d
Commit
3f8f883d
authored
Nov 30, 2010
by
Sebastian Eichelbaum
Browse files
[CHANGE] - switched to front to back compositing with alpha test
parent
4d038036
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
26 deletions
+18
-26
src/modules/directVolumeRendering/WMDirectVolumeRendering.cpp
...modules/directVolumeRendering/WMDirectVolumeRendering.cpp
+1
-0
src/modules/directVolumeRendering/shaders/WMDirectVolumeRendering-fragment.glsl
...meRendering/shaders/WMDirectVolumeRendering-fragment.glsl
+17
-26
No files found.
src/modules/directVolumeRendering/WMDirectVolumeRendering.cpp
View file @
3f8f883d
...
...
@@ -242,6 +242,7 @@ void WMDirectVolumeRendering::moduleMain()
{
warnLog
()
<<
"Transfer function texture could not be loaded from "
<<
m_tfLoaderFile
->
get
(
true
).
file_string
()
<<
"."
;
}
m_tfLoaderTrigger
->
get
(
true
);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
...
...
src/modules/directVolumeRendering/shaders/WMDirectVolumeRendering-fragment.glsl
View file @
3f8f883d
...
...
@@ -44,10 +44,6 @@
uniform
sampler3D
tex0
;
uniform
sampler1D
TRANSFERFUNCTION_SAMPLER
;
// The isovalue to use.
uniform
float
u_isovalue1
=
0
.
33
;
uniform
float
u_isovalue2
=
0
.
80
;
/////////////////////////////////////////////////////////////////////////////
// Attributes
/////////////////////////////////////////////////////////////////////////////
...
...
@@ -117,12 +113,12 @@ vec3 getGradient( in vec3 position )
*
* \return the color.
*/
vec4
transferFunction
(
in
float
value
)
vec4
transferFunction
(
float
value
)
{
#ifdef TRANSFERFUNCTION_ENABLED
return
texture1D
(
TRANSFERFUNCTION_SAMPLER
,
value
);
#else
if
(
isZero
(
value
-
0
.
5
,
0
.
1
)
)
// if not TF has been specified, at least show something
if
(
isZero
(
value
-
0
.
5
,
0
.
0
1
)
)
// if not TF has been specified, at least show something
{
return
vec4
(
1
.
0
,
0
.
0
,
0
.
0
,
0
.
1
);
}
...
...
@@ -175,39 +171,34 @@ void main()
vec3
rayEnd
=
findRayEnd
(
totalDistance
);
// walk along the ray
vec4
accumColor
=
vec4
(
vec3
(
0
.
0
),
1
.
0
);
// the composited color
float
accumAlpha
=
1
.
0
;
// accumulated transparency of the volume.
float
depth
=
gl_FragCoord
.
z
;
// the depth of the last hit
float
value
;
// the current value inside the data
float
hit
=
0
.
0
;
// this value will be != 0.0 if something has been hit
vec4
dst
=
vec4
(
0
.
0
);
while
(
currentDistance
<=
totalDistance
)
{
// get current value
vec3
rayPoint
=
rayEnd
-
(
currentDistance
*
v_ray
);
value
=
texture3D
(
tex0
,
rayPoint
).
r
;
// get current value, classify and illuminate
vec3
rayPoint
=
v_rayStart
+
(
currentDistance
*
v_ray
);
vec4
src
=
localIllumination
(
rayPoint
,
transferFunction
(
texture3D
(
tex0
,
rayPoint
).
r
)
);
// go to next value
currentDistance
+=
v_stepDistance
;
//
classify point in volume and evaluate local illumination model at this
positi
o
n
vec4
color
=
localIllumination
(
rayPoint
,
transferFunction
(
value
)
)
;
//
apply front-to-back com
positin
g
dst
=
(
1
.
0
-
dst
.
a
)
*
src
+
dst
;
// has there ever been something we hit?
hit
=
max
(
hit
,
color
.
a
);
accumColor
.
rgba
=
mix
(
accumColor
.
rgba
,
color
.
rgba
,
color
.
a
);
// compositing
accumAlpha
*=
(
1
.
0
-
color
.
a
);
// compositing: keep track of final alpha value of the background
if
(
dst
.
a
>=
0
.
95
)
break
;
}
/*
// have we hit something which was classified not to be transparent?
// This is, visually, not needed but useful if volume rendere is used in conjunction with other geometry.
if
(
isZero
(
hit
)
)
if ( isZero(
dst.a
) )
{
discard;
}
}
*/
// set final color
accumColor
.
a
=
1
.
0
-
accumAlpha
;
gl_FragColor
=
accumColor
;
gl_FragDepth
=
depth
;
float
depth
=
gl_FragCoord
.
z
;
gl_FragColor
=
dst
;
gl_FragDepth
=
depth
;
// the depth of the last hit
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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