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
c9808d6d
Commit
c9808d6d
authored
Jan 04, 2013
by
Sebastian Eichelbaum
Browse files
[CHANGE] you can now force fixed size render targets in offscreen nodes and postprocessors
parent
4b86ba83
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
109 additions
and
11 deletions
+109
-11
src/core/graphicsEngine/callbacks/WGEViewportCallback.h
src/core/graphicsEngine/callbacks/WGEViewportCallback.h
+40
-5
src/core/graphicsEngine/offscreen/WGEOffscreenRenderNode.cpp
src/core/graphicsEngine/offscreen/WGEOffscreenRenderNode.cpp
+13
-1
src/core/graphicsEngine/offscreen/WGEOffscreenRenderNode.h
src/core/graphicsEngine/offscreen/WGEOffscreenRenderNode.h
+28
-1
src/core/graphicsEngine/postprocessing/WGEPostprocessingNode.cpp
...e/graphicsEngine/postprocessing/WGEPostprocessingNode.cpp
+3
-0
src/core/graphicsEngine/postprocessing/WGEPostprocessor.cpp
src/core/graphicsEngine/postprocessing/WGEPostprocessor.cpp
+4
-0
src/core/graphicsEngine/postprocessing/WGEPostprocessor.h
src/core/graphicsEngine/postprocessing/WGEPostprocessor.h
+11
-0
src/modules/fiberDisplaySimple/WMFiberDisplaySimple.cpp
src/modules/fiberDisplaySimple/WMFiberDisplaySimple.cpp
+7
-2
src/modules/fiberDisplaySimple/WMFiberDisplaySimple.h
src/modules/fiberDisplaySimple/WMFiberDisplaySimple.h
+3
-2
No files found.
src/core/graphicsEngine/callbacks/WGEViewportCallback.h
View file @
c9808d6d
...
...
@@ -41,12 +41,20 @@ class WGEViewportCallback: public osg::NodeCallback
{
public:
/**
* Creates new instance of viewport callback
.
* Creates new instance of viewport callback
and sets the viewport size to the reference camera size
*
* \param reference set the viewport to the one of the reference camera.
*/
explicit
WGEViewportCallback
(
osg
::
ref_ptr
<
Source
>
reference
);
/**
* Creates new instance of viewport callback and sets the viewport size to the specified size
*
* \param width viewport width
* \param height viewport height
*/
WGEViewportCallback
(
size_t
width
,
size_t
height
);
/**
* Destructor.
*/
...
...
@@ -66,12 +74,34 @@ private:
* The reference camera to use.
*/
osg
::
ref_ptr
<
Source
>
m_reference
;
/**
* Forced viewport width
*/
size_t
m_width
;
/**
* Forced viewport height
*/
size_t
m_height
;
};
template
<
typename
T
,
typename
Source
>
WGEViewportCallback
<
T
,
Source
>::
WGEViewportCallback
(
osg
::
ref_ptr
<
Source
>
reference
)
:
osg
::
NodeCallback
(),
m_reference
(
reference
)
m_reference
(
reference
),
m_width
(
0
),
m_height
(
0
)
{
// initialize members
}
template
<
typename
T
,
typename
Source
>
WGEViewportCallback
<
T
,
Source
>::
WGEViewportCallback
(
size_t
width
,
size_t
height
)
:
osg
::
NodeCallback
(),
m_reference
(
NULL
),
m_width
(
width
),
m_height
(
height
)
{
// initialize members
}
...
...
@@ -88,9 +118,14 @@ void WGEViewportCallback< T, Source >::operator()( osg::Node* node, osg::NodeVis
osg
::
ref_ptr
<
T
>
t
=
dynamic_cast
<
T
*
>
(
node
);
if
(
t
)
{
t
->
setViewport
(
m_reference
->
getViewport
()
);
// NOTE: you want to use a fixed size for the offscreen textures? Try this:
// t->setViewport( new osg::Viewport( 0, 0, 3840, 2160 ) );
if
(
m_reference
)
{
t
->
setViewport
(
m_reference
->
getViewport
()
);
}
else
{
t
->
setViewport
(
new
osg
::
Viewport
(
0
,
0
,
m_width
,
m_height
)
);
}
}
traverse
(
node
,
nv
);
}
...
...
src/core/graphicsEngine/offscreen/WGEOffscreenRenderNode.cpp
View file @
c9808d6d
...
...
@@ -46,7 +46,8 @@ WGEOffscreenRenderNode::WGEOffscreenRenderNode( osg::ref_ptr< osg::Camera > refe
m_hud
(),
m_textureWidth
(
width
),
m_textureHeight
(
height
),
m_nextPassNum
(
0
)
m_nextPassNum
(
0
),
m_forceViewportTextureSize
(
false
)
{
WAssert
(
checkTextureSize
(
width
)
&&
checkTextureSize
(
height
),
"Invalid offscreen texture size. Must be power of two and in [8,4096]."
);
...
...
@@ -124,3 +125,14 @@ size_t WGEOffscreenRenderNode::getTextureHeight() const
{
return
m_textureHeight
;
}
void
WGEOffscreenRenderNode
::
setLinkViewportToTextureSize
(
bool
vp
)
{
m_forceViewportTextureSize
=
vp
;
}
bool
WGEOffscreenRenderNode
::
getLinkViewportToTextureSize
()
const
{
return
m_forceViewportTextureSize
;
}
src/core/graphicsEngine/offscreen/WGEOffscreenRenderNode.h
View file @
c9808d6d
...
...
@@ -191,6 +191,21 @@ public:
*/
size_t
getTextureHeight
()
const
;
/**
* If true, the viewport has the size of the resulting texture. This is very interesting if you want to force large scale renderings and want
* to decouple your offscreen pass from the reference camera viewport.
*
* \param vp if true, viewport is forced to be the whole texture size
*/
void
setLinkViewportToTextureSize
(
bool
vp
=
true
);
/**
* The flag denotes whether the viewport is linked to the texture size or the reference camera. See \ref setViewportToTextureSize for
* details.
*
* \return the flag.
*/
bool
getLinkViewportToTextureSize
()
const
;
protected:
private:
/**
...
...
@@ -218,6 +233,11 @@ private:
* The number of the next pass getting added.
*/
size_t
m_nextPassNum
;
/**
* Flag denotes whether the viewport is coupled to the reference camera or the texture size
*/
bool
m_forceViewportTextureSize
;
};
template
<
typename
T
>
...
...
@@ -232,7 +252,14 @@ osg::ref_ptr< T > WGEOffscreenRenderNode::addRenderPass( std::string name )
insert
(
pass
);
// insert into this group
// ensure proper propagation of viewport changes
pass
->
addUpdateCallback
(
new
WGEViewportCallback
<
T
>
(
m_referenceCamera
)
);
if
(
m_forceViewportTextureSize
)
{
pass
->
addUpdateCallback
(
new
WGEViewportCallback
<
T
>
(
m_textureWidth
,
m_textureHeight
)
);
}
else
{
pass
->
addUpdateCallback
(
new
WGEViewportCallback
<
T
>
(
m_referenceCamera
)
);
}
// set clear mask and color according to reference cam
pass
->
setClearMask
(
m_referenceCamera
->
getClearMask
()
);
...
...
src/core/graphicsEngine/postprocessing/WGEPostprocessingNode.cpp
View file @
c9808d6d
...
...
@@ -64,6 +64,9 @@ WGEPostprocessingNode::WGEPostprocessingNode( osg::ref_ptr< osg::Camera > refere
osg
::
ref_ptr
<
WGEOffscreenRenderNode
>
offscreen
(
new
WGEOffscreenRenderNode
(
reference
,
width
,
height
,
noHud
)
);
offscreen
->
getTextureHUD
()
->
addUpdateCallback
(
textureHudCallback
);
// if the specific postprocessor requires us to fix the viewport size to the result-texture size:
offscreen
->
setLinkViewportToTextureSize
(
(
*
iter
)
->
getFixedViewportSize
()
);
// the geometry render step
osg
::
ref_ptr
<
WGEOffscreenRenderPass
>
render
=
offscreen
->
addGeometryRenderPass
(
m_childs
,
...
...
src/core/graphicsEngine/postprocessing/WGEPostprocessor.cpp
View file @
c9808d6d
...
...
@@ -173,3 +173,7 @@ const std::string WGEPostprocessor::getDescription() const
return
m_description
;
}
bool
WGEPostprocessor
::
getFixedViewportSize
()
const
{
return
false
;
}
src/core/graphicsEngine/postprocessing/WGEPostprocessor.h
View file @
c9808d6d
...
...
@@ -232,6 +232,17 @@ public:
* \return the description
*/
virtual
const
std
::
string
getDescription
()
const
;
/**
* When this returns true, the viewport size is fixed to the size of the target texture. This is very useful if you want to process high resolution
* images offscreen. You can implement this function in your postprocessor to modify this. Please be aware that this does not modify the
* camera's projection matrix. This is especially important for correct aspect ratios. You can modify the camera dynamically by using
* callbacks.
*
* \return true if fixed.
*/
virtual
bool
getFixedViewportSize
()
const
;
protected:
/**
* The textures contain the result. Add at least one result texture
...
...
src/modules/fiberDisplaySimple/WMFiberDisplaySimple.cpp
View file @
c9808d6d
...
...
@@ -33,6 +33,9 @@
#include <osg/LineWidth>
#include <osg/Point>
#include <osg/PointSprite>
#include <osgDB/Export>
#include <osgDB/Registry>
#include <osgDB/WriteFile>
#include "core/common/WPropertyHelper.h"
#include "core/common/WPropertyObserver.h"
...
...
@@ -40,6 +43,8 @@
#include "core/dataHandler/WDataSetFiberClustering.h"
#include "core/dataHandler/WDataSetFibers.h"
#include "core/graphicsEngine/WGEColormapping.h"
#include "core/graphicsEngine/WGEUtils.h"
#include "core/graphicsEngine/WGEGeodeUtils.h"
#include "core/graphicsEngine/callbacks/WGEFunctorCallback.h"
#include "core/graphicsEngine/callbacks/WGENodeMaskCallback.h"
#include "core/graphicsEngine/postprocessing/WGEPostprocessingNode.h"
...
...
@@ -256,8 +261,6 @@ void WMFiberDisplaySimple::moduleMain()
// Remember the condition provided to some properties in properties()? The condition can now be used with this condition set.
m_moduleState
.
add
(
m_propCondition
);
ready
();
// 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
()
...
...
@@ -275,6 +278,8 @@ void WMFiberDisplaySimple::moduleMain()
rootState
->
addUniform
(
tubeSizeUniform
);
rootState
->
addUniform
(
colormapRationUniform
);
ready
();
// needed to observe the properties of the input connector data
boost
::
shared_ptr
<
WPropertyObserver
>
propObserver
=
WPropertyObserver
::
create
();
m_moduleState
.
add
(
propObserver
);
...
...
src/modules/fiberDisplaySimple/WMFiberDisplaySimple.h
View file @
c9808d6d
...
...
@@ -31,9 +31,10 @@
#include "core/kernel/WModuleInputData.h"
#include "core/kernel/WModuleOutputData.h"
#include "core/dataHandler/WDataSetFiberClustering.h"
#include "core/dataHandler/WDataSetFibers.h"
// forward declarations
class
WDataSetFibers
;
class
WDataSetFiberClustering
;
class
WGEShader
;
/**
...
...
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