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
2cb8fca0
Commit
2cb8fca0
authored
Jan 19, 2011
by
Sebastian Eichelbaum
Browse files
[CHANGE] - ported surface animator to new texturing mechanism
parent
94e7ca9a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
38 deletions
+19
-38
src/modules/surfaceParameterAnimator/WMSurfaceParameterAnimator.cpp
...s/surfaceParameterAnimator/WMSurfaceParameterAnimator.cpp
+5
-16
src/modules/surfaceParameterAnimator/shaders/WMSurfaceParameterAnimator-Beams-fragment.glsl
...or/shaders/WMSurfaceParameterAnimator-Beams-fragment.glsl
+14
-16
src/modules/surfaceParameterAnimator/shaders/WMSurfaceParameterAnimator-Beams-vertex.glsl
...ator/shaders/WMSurfaceParameterAnimator-Beams-vertex.glsl
+0
-6
No files found.
src/modules/surfaceParameterAnimator/WMSurfaceParameterAnimator.cpp
View file @
2cb8fca0
...
...
@@ -34,7 +34,7 @@
#include <osg/Projection>
#include "../../kernel/WKernel.h"
#include "../../dataHandler/WDataTexture3D.h"
#include "../../dataHandler/WDataTexture3D
_2
.h"
#include "../../common/WColor.h"
#include "../../common/WBoundingBox.h"
#include "../../graphicsEngine/WGEUtils.h"
...
...
@@ -144,14 +144,12 @@ osg::ref_ptr< osg::Node > WMSurfaceParameterAnimator::renderSurface( const WBoun
m_shader
->
apply
(
cube
);
// bind the texture to the node
osg
::
ref_ptr
<
osg
::
Texture3D
>
texture3D
=
m_dataSet
->
getTexture
()
->
getTexture
();
osg
::
ref_ptr
<
osg
::
Texture3D
>
tracesTexture3D
=
m_tracesDataSet
->
getTexture
()
->
getTexture
();
osg
::
StateSet
*
rootState
=
cube
->
getOrCreateStateSet
();
rootState
->
setTextureAttributeAndModes
(
0
,
texture3D
,
osg
::
StateAttribute
::
ON
);
rootState
->
setTextureAttributeAndModes
(
1
,
tracesTexture3D
,
osg
::
StateAttribute
::
ON
);
//tracesTexture3D->setFilter( osg::Texture::MIN_FILTER, osg::Texture::NEAREST );
//tracesTexture3D->setFilter( osg::Texture::MAG_FILTER, osg::Texture::NEAREST );
osg
::
ref_ptr
<
WGETexture3D
>
texture3D
=
m_dataSet
->
getTexture2
();
osg
::
ref_ptr
<
WGETexture3D
>
tracesTexture3D
=
m_tracesDataSet
->
getTexture2
();
texture3D
->
bind
(
cube
,
0
);
tracesTexture3D
->
bind
(
cube
,
1
);
// enable transparency
rootState
->
setMode
(
GL_BLEND
,
osg
::
StateAttribute
::
ON
);
...
...
@@ -160,15 +158,6 @@ osg::ref_ptr< osg::Node > WMSurfaceParameterAnimator::renderSurface( const WBoun
// setup all those uniforms
////////////////////////////////////////////////////////////////////////////////////////////////////
// for the texture, also bind the appropriate uniforms
rootState
->
addUniform
(
new
osg
::
Uniform
(
"tex0"
,
0
)
);
rootState
->
addUniform
(
new
osg
::
Uniform
(
"tex1"
,
1
)
);
// we need to specify the texture scaling parameters to the shader
rootState
->
addUniform
(
new
osg
::
Uniform
(
"u_tex1Scale"
,
m_tracesDataSet
->
getTexture
()
->
getMinMaxScale
()
)
);
rootState
->
addUniform
(
new
osg
::
Uniform
(
"u_tex1Min"
,
m_tracesDataSet
->
getTexture
()
->
getMinValue
()
)
);
rootState
->
addUniform
(
new
osg
::
Uniform
(
"u_tex1Max"
,
m_tracesDataSet
->
getTexture
()
->
getMaxValue
()
)
);
osg
::
ref_ptr
<
osg
::
Uniform
>
isovalue
=
new
osg
::
Uniform
(
"u_isovalue"
,
static_cast
<
float
>
(
m_isoValue
->
get
()
/
100.0
)
);
isovalue
->
setUpdateCallback
(
new
SafeUniformCallback
(
this
)
);
...
...
src/modules/surfaceParameterAnimator/shaders/WMSurfaceParameterAnimator-Beams-fragment.glsl
View file @
2cb8fca0
...
...
@@ -43,19 +43,16 @@
// **************************************************************************
// texture containing the data
uniform
sampler3D
tex
0
;
uniform
sampler3D
u_
tex
ture0Sampler
;
// texture containing the tracing data
uniform
sampler3D
tex
1
;
uniform
sampler3D
u_
tex
ture1Sampler
;
// texture containing the tracing data -> the scaling factor of the values in the texture
uniform
float
u_tex1Scale
;
uniform
float
u_tex
ture
1Scale
;
// texture containing the tracing data -> the min value of the values in the texture
uniform
float
u_tex1Min
;
// texture containing the tracing data -> the max value of the values in the texture
uniform
float
u_tex1Max
;
uniform
float
u_texture1Min
;
// **************************************************************************
// Uniforms for the isosurface mode
...
...
@@ -230,7 +227,7 @@ void main()
while
(
i
<
u_steps
)
// we do not need to ch
{
// get current value
value
=
texture3D
(
tex
0
,
curPoint
).
r
;
value
=
texture3D
(
u_
tex
ture0Sampler
,
curPoint
).
r
;
// is it the isovalue?
if
(
abs
(
value
-
u_isovalue
)
<
0
.
1
)
...
...
@@ -246,12 +243,12 @@ void main()
// 3: find a proper normal for a headlight
float
s
=
0
.
005
;
float
valueXP
=
texture3D
(
tex
0
,
curPoint
+
vec3
(
s
,
0
.
0
,
0
.
0
)
).
r
;
float
valueXM
=
texture3D
(
tex
0
,
curPoint
-
vec3
(
s
,
0
.
0
,
0
.
0
)
).
r
;
float
valueYP
=
texture3D
(
tex
0
,
curPoint
+
vec3
(
0
.
0
,
s
,
0
.
0
)
).
r
;
float
valueYM
=
texture3D
(
tex
0
,
curPoint
-
vec3
(
0
.
0
,
s
,
0
.
0
)
).
r
;
float
valueZP
=
texture3D
(
tex
0
,
curPoint
+
vec3
(
0
.
0
,
0
.
0
,
s
)
).
r
;
float
valueZM
=
texture3D
(
tex
0
,
curPoint
-
vec3
(
0
.
0
,
0
.
0
,
s
)
).
r
;
float
valueXP
=
texture3D
(
u_
tex
ture0Sampler
,
curPoint
+
vec3
(
s
,
0
.
0
,
0
.
0
)
).
r
;
float
valueXM
=
texture3D
(
u_
tex
ture0Sampler
,
curPoint
-
vec3
(
s
,
0
.
0
,
0
.
0
)
).
r
;
float
valueYP
=
texture3D
(
u_
tex
ture0Sampler
,
curPoint
+
vec3
(
0
.
0
,
s
,
0
.
0
)
).
r
;
float
valueYM
=
texture3D
(
u_
tex
ture0Sampler
,
curPoint
-
vec3
(
0
.
0
,
s
,
0
.
0
)
).
r
;
float
valueZP
=
texture3D
(
u_
tex
ture0Sampler
,
curPoint
+
vec3
(
0
.
0
,
0
.
0
,
s
)
).
r
;
float
valueZM
=
texture3D
(
u_
tex
ture0Sampler
,
curPoint
-
vec3
(
0
.
0
,
0
.
0
,
s
)
).
r
;
vec3
dir
=
v_ray
;
dir
+=
vec3
(
valueXP
,
0
.
0
,
0
.
0
);
...
...
@@ -279,13 +276,14 @@ void main()
float
minSize
=
(
paramSpaceSize
*
0
.
05
);
// the minimum size of 1% of the parameter space size
float
maxSize
=
(
paramSpaceSize
*
0
.
30
);
// the maximum size -> 30% of parameter space size
float
trace
=
texture3D
(
tex
1
,
curPoint
).
r
*
(
paramSpaceSize
);
float
traceInv
=
(
1
.
0
-
texture3D
(
tex
1
,
curPoint
).
r
)
*
(
paramSpaceSize
);
float
trace
=
texture3D
(
u_
tex
ture1Sampler
,
curPoint
).
r
*
(
paramSpaceSize
);
float
traceInv
=
(
1
.
0
-
texture3D
(
u_
tex
ture1Sampler
,
curPoint
).
r
)
*
(
paramSpaceSize
);
// 4: prepare animation
// the current time step:
float
timeStep
=
u_animationTime
/
4
.
0
;
// scale 100th of a second to 25 times per second
//timeStep = 25;
// create a triangle function increasing time in 1/100 steps
float
relativeSpeed1
=
float
(
u_speed1
)
/
2
.
0
;
float
relativeSpeed2
=
float
(
u_speed2
)
/
2
.
0
;
...
...
src/modules/surfaceParameterAnimator/shaders/WMSurfaceParameterAnimator-Beams-vertex.glsl
View file @
2cb8fca0
...
...
@@ -36,12 +36,6 @@
// Uniforms
/////////////////////////////////////////////////////////////////////////////
// texture containing the data
uniform
sampler3D
tex0
;
// texture containing the directional data
uniform
sampler3D
tex1
;
/////////////////////////////////////////////////////////////////////////////
// Attributes
/////////////////////////////////////////////////////////////////////////////
...
...
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