Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
cc4f8c3d
Commit
cc4f8c3d
authored
Feb 21, 2013
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD
#222
] added postproc to isosurface
parent
e23f1d38
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
19 deletions
+49
-19
src/modules/isosurface/WMIsosurface.cpp
src/modules/isosurface/WMIsosurface.cpp
+24
-17
src/modules/isosurface/WMIsosurface.h
src/modules/isosurface/WMIsosurface.h
+5
-0
src/modules/isosurface/shaders/WMIsosurface-fragment.glsl
src/modules/isosurface/shaders/WMIsosurface-fragment.glsl
+13
-2
src/modules/isosurface/shaders/WMIsosurface-vertex.glsl
src/modules/isosurface/shaders/WMIsosurface-vertex.glsl
+7
-0
No files found.
src/modules/isosurface/WMIsosurface.cpp
View file @
cc4f8c3d
...
...
@@ -52,6 +52,7 @@
#include "core/graphicsEngine/shaders/WGEPropertyUniform.h"
#include "core/graphicsEngine/shaders/WGEShaderPropertyDefineOptions.h"
#include "core/graphicsEngine/shaders/WGEShaderPropertyDefine.h"
#include "core/graphicsEngine/postprocessing/WGEPostprocessingNode.h"
#include "core/graphicsEngine/WGEColormapping.h"
#include "core/graphicsEngine/WGEUtils.h"
#include "core/kernel/WKernel.h"
...
...
@@ -109,10 +110,30 @@ void WMIsosurface::moduleMain()
m_moduleState
.
add
(
m_input
->
getDataChangedCondition
()
);
m_moduleState
.
add
(
m_recompute
);
// create the post-processing node which actually does the nice stuff to the rendered image
osg
::
ref_ptr
<
WGEPostprocessingNode
>
postNode
=
new
WGEPostprocessingNode
(
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getViewer
()
->
getCamera
()
);
// provide the properties of the post-processor to the user
m_properties
->
addProperty
(
postNode
->
getProperties
()
);
// add to scene
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getScene
()
->
insert
(
postNode
);
// signal ready state
ready
();
// create shader
m_shader
=
osg
::
ref_ptr
<
WGEShader
>
(
new
WGEShader
(
"WMIsosurface"
,
m_localPath
)
);
m_shader
->
addPreprocessor
(
WGEShaderPreprocessor
::
SPtr
(
new
WGEShaderPropertyDefineOptions
<
WPropBool
>
(
m_useTextureProp
,
"COLORMAPPING_DISABLED"
,
"COLORMAPPING_ENABLED"
)
)
);
m_moduleNode
=
new
WGEManagedGroupNode
(
m_active
);
m_moduleNode
->
getOrCreateStateSet
()
->
addUniform
(
new
WGEPropertyUniform
<
WPropInt
>
(
"u_opacity"
,
m_opacityProp
)
);
// add it to postproc node and register shader
postNode
->
insert
(
m_moduleNode
,
m_shader
);
// loop until the module container requests the module to quit
while
(
!
m_shutdownFlag
()
)
...
...
@@ -177,7 +198,7 @@ void WMIsosurface::moduleMain()
progress
->
finish
();
}
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getViewer
()
->
getScene
()
->
remove
(
m_module
Node
);
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getViewer
()
->
getScene
()
->
remove
(
post
Node
);
}
void
WMIsosurface
::
connectors
()
...
...
@@ -431,29 +452,15 @@ void WMIsosurface::renderMesh()
surfaceGeometry
->
setUseDisplayList
(
false
);
surfaceGeometry
->
setUseVertexBufferObjects
(
true
);
// ------------------------------------------------
// Shader stuff
osg
::
ref_ptr
<
WGEShader
>
shader
=
osg
::
ref_ptr
<
WGEShader
>
(
new
WGEShader
(
"WMIsosurface"
,
m_localPath
)
);
shader
->
addPreprocessor
(
WGEShaderPreprocessor
::
SPtr
(
new
WGEShaderPropertyDefineOptions
<
WPropBool
>
(
m_useTextureProp
,
"COLORMAPPING_DISABLED"
,
"COLORMAPPING_ENABLED"
)
)
);
state
->
addUniform
(
new
WGEPropertyUniform
<
WPropInt
>
(
"u_opacity"
,
m_opacityProp
)
);
shader
->
apply
(
m_surfaceGeode
);
m_shader
->
apply
(
m_surfaceGeode
);
// enable transparency
wge
::
enableTransparency
(
m_surfaceGeode
);
// Colormapping
WGEColormapping
::
apply
(
m_surfaceGeode
,
shader
);
WGEColormapping
::
apply
(
m_surfaceGeode
,
m_
shader
);
m_moduleNode
->
insert
(
m_surfaceGeode
);
if
(
!
m_moduleNodeInserted
)
{
WKernel
::
getRunningKernel
()
->
getGraphicsEngine
()
->
getScene
()
->
insert
(
m_moduleNode
);
m_moduleNodeInserted
=
true
;
}
m_moduleNode
->
addUpdateCallback
(
new
WGEFunctorCallback
<
osg
::
Node
>
(
boost
::
bind
(
&
WMIsosurface
::
updateGraphicsCallback
,
this
)
)
);
}
...
...
src/modules/isosurface/WMIsosurface.h
View file @
cc4f8c3d
...
...
@@ -158,6 +158,11 @@ private:
bool
m_moduleNodeInserted
;
//!< ensures that the above module node gets inserted once the first triangle mesh has been calculated.
osg
::
ref_ptr
<
osg
::
Geode
>
m_surfaceGeode
;
//!< Pointer to geode containing the surface.
/**
* The shader
*/
osg
::
ref_ptr
<
WGEShader
>
m_shader
;
};
#endif // WMISOSURFACE_H
src/modules/isosurface/shaders/WMIsosurface-fragment.glsl
View file @
cc4f8c3d
...
...
@@ -25,7 +25,8 @@
#version 120
#include "WGEColormapping-fragment.glsl"
#include "WGETextureTools.glsl"
#include "WGEPostprocessing.glsl"
#include "WGEShadingTools.glsl"
// opacity in percent
...
...
@@ -34,6 +35,9 @@ uniform int u_opacity;
// The surface normal
varying
vec3
v_normal
;
// modelview matrix' scaling factor
varying
float
v_worldScale
;
void
main
()
{
vec4
col
=
gl_Color
;
...
...
@@ -48,5 +52,12 @@ void main()
// opacity of the surface
col
.
rgb
=
light
*
col
.
rgb
;
col
.
a
=
float
(
u_opacity
)
*
0
.
01
;
gl_FragColor
=
col
;
// finally set the color and depth
wgeInitGBuffer
();
wge_FragColor
=
col
;
wge_FragNormal
=
textureNormalize
(
normalize
(
v_normal
)
);
wge_FragZoom
=
v_worldScale
;
wge_FragTangent
=
textureNormalize
(
v_normal
);
}
src/modules/isosurface/shaders/WMIsosurface-vertex.glsl
View file @
cc4f8c3d
...
...
@@ -25,10 +25,14 @@
#version 120
#include "WGEColormapping-vertex.glsl"
#include "WGETransformationTools.glsl"
// The surface normal
varying
vec3
v_normal
;
// modelview matrix' scaling factor
varying
float
v_worldScale
;
void
main
()
{
// prepare colormapping
...
...
@@ -37,6 +41,9 @@ void main()
// prepare light
v_normal
=
gl_NormalMatrix
*
gl_Normal
;
// Calc the scaling factor in the MV matrix
v_worldScale
=
getModelViewScale
();
gl_FrontColor
=
gl_Color
;
gl_Position
=
ftransform
();
}
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