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
b7c89451
Commit
b7c89451
authored
Nov 26, 2012
by
Sebastian Eichelbaum
Browse files
[CHANGE
#221
] added property to control point size.
parent
0cc71ced
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
35 deletions
+26
-35
src/modules/pointRenderer/WMPointRenderer.cpp
src/modules/pointRenderer/WMPointRenderer.cpp
+11
-34
src/modules/pointRenderer/WMPointRenderer.h
src/modules/pointRenderer/WMPointRenderer.h
+10
-0
src/modules/pointRenderer/shaders/WMPointRenderer-fragment.glsl
...dules/pointRenderer/shaders/WMPointRenderer-fragment.glsl
+4
-0
src/modules/pointRenderer/shaders/WMPointRenderer-geometry.glsl
...dules/pointRenderer/shaders/WMPointRenderer-geometry.glsl
+1
-1
No files found.
src/modules/pointRenderer/WMPointRenderer.cpp
View file @
b7c89451
...
...
@@ -90,42 +90,14 @@ void WMPointRenderer::properties()
// some properties need to trigger an update
m_propCondition
=
boost
::
shared_ptr
<
WCondition
>
(
new
WCondition
()
);
/* m_nbTriangles = m_infoProperties->addProperty( "Triangles", "The number of triangles in the mesh.", 0 );
m_nbTriangles->setMax( std::numeric_limits< int >::max() );
// setup all the properties. See header file for their meaning and purpose.
m_size
=
m_properties
->
addProperty
(
"Point Size"
,
"The size of the points."
,
0.25
);
m_size
->
setMin
(
0.0001
);
m_size
->
setMax
(
10.0
);
m_
nbVertices = m_infoP
roperties->addProperty( "
Vertices", "The number of vertices in the mesh.", 0 );
m_nbVertices->setMax( std::numeric_limits< int >::max()
);
m_
useCorrectDepth
=
m_p
roperties
->
addProperty
(
"
Correct Depth"
,
"If set, the depths of the sprites are calculated correctly. You can disable "
"this to get higher framerates at the cost of visual correctness."
,
true
);
// setup all the properties. See header file for their meaning and purpose.
m_showOutline = m_properties->addProperty( "Outline", "Show all edges of the trinagulation as lines.", false, m_propCondition );
m_mainComponentOnly = m_properties->addProperty( "Main component", "Main component only", false, m_propCondition );
m_showCoordinateSystem = m_properties->addProperty( "Coordinate system", "If enabled, the coordinate system of the mesh will be shown.",
false, m_propCondition );
m_coloringGroup = m_properties->addPropertyGroup( "Coloring", "Coloring options and colormap options." );
m_opacity = m_coloringGroup->addProperty( "Opacity %", "Opaqueness of surface.", 100.0 );
m_opacity->setMin( 0.0 );
m_opacity->setMax( 100.0 );
// Allow the user to select different colormodes
boost::shared_ptr< WItemSelection > colorModes( boost::shared_ptr< WItemSelection >( new WItemSelection() ) );
colorModes->addItem( "Single Color", "The whole surface is colored using the default color." );
colorModes->addItem( "From Mesh", "The surface is colored according to the mesh." );
colorModes->addItem( "From colormap connector", "The surface is colored using the colormap on colorMap connector." );
m_colorMode = m_coloringGroup->addProperty( "Color mode", "Choose one of the available colorings.", colorModes->getSelectorFirst(),
m_propCondition );
WPropertyHelper::PC_SELECTONLYONE::addTo( m_colorMode );
// this is the color used if single color is selected
m_color = m_coloringGroup->addProperty( "Default color", "The color of of the surface.",
WColor( .9f, .9f, 0.9f, 1.0f ), m_propCondition );
m_colormap = m_coloringGroup->addProperty( "Enable colormapping", "Turn colormapping on", false );
m_colormapRatio = m_coloringGroup->addProperty( "Colormap ratio", "Set the colormap Ratio", 0.5 );
m_colormapRatio->setMin( 0.0 );
m_colormapRatio->setMax( 1.0 );
*/
// call WModule's initialization
WModule
::
properties
();
}
...
...
@@ -160,6 +132,11 @@ void WMPointRenderer::moduleMain()
m_shader
->
setParameter
(
GL_GEOMETRY_INPUT_TYPE_EXT
,
GL_POINTS
);
m_shader
->
setParameter
(
GL_GEOMETRY_OUTPUT_TYPE_EXT
,
GL_TRIANGLE_STRIP
);
// insert some uniforms and defines
postNode
->
getOrCreateStateSet
()
->
addUniform
(
new
WGEPropertyUniform
<
WPropDouble
>
(
"u_pointSize"
,
m_size
)
);
m_shader
->
addPreprocessor
(
WGEShaderPreprocessor
::
SPtr
(
new
WGEShaderPropertyDefineOptions
<
WPropBool
>
(
m_useCorrectDepth
,
"DEPTHWRITE_DISABLED"
,
"DEPTHWRITE_ENABLED"
)
)
);
// loop until the module container requests the module to quit
while
(
!
m_shutdownFlag
()
)
...
...
src/modules/pointRenderer/WMPointRenderer.h
View file @
b7c89451
...
...
@@ -111,6 +111,16 @@ private:
* The shader for the points
*/
osg
::
ref_ptr
<
WGEShader
>
m_shader
;
/**
* The size of a point on screen.
*/
WPropDouble
m_size
;
/**
* Slower but correct depth calculation.
*/
WPropBool
m_useCorrectDepth
;
};
#endif // WMPOINTRENDERER_H
src/modules/pointRenderer/shaders/WMPointRenderer-fragment.glsl
View file @
b7c89451
...
...
@@ -110,6 +110,7 @@ void main()
sphereSurf
=
normalize
(
sphereSurf
);
// lighting
// NOTE: this is disabled as usually, we use a headlight, causing a specular highlight in the middle of each splat.
// float light = blinnPhongIlluminationIntensity( wge_DefaultLightIntensity, sphereSurf );
// finally set the color and depth
...
...
@@ -118,6 +119,9 @@ void main()
wge_FragNormal
=
textureNormalize
(
sphereSurf
);
wge_FragZoom
=
0
.
1
*
v_worldScale
;
wge_FragTangent
=
textureNormalize
(
vec3
(
0
.
0
,
1
.
0
,
0
.
0
)
);
#ifdef DEPTHWRITE_ENABLED
// we allow to disable depth write. This allows the GPU to disacard pixels before applying the fragment shader -> speedup
gl_FragDepth
=
(
r
*
v_vertexDepthDiff
)
+
v_centerVertexDepth
;
#endif
}
src/modules/pointRenderer/shaders/WMPointRenderer-geometry.glsl
View file @
b7c89451
...
...
@@ -35,7 +35,7 @@
/**
* The size of the sprite
*/
uniform
float
u_pointSize
=
0
.
0
5
;
uniform
float
u_pointSize
=
1
.
0
;
/////////////////////////////////////////////////////////////////////////////
// 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