Hello Carsten,
I've started to work on this. I've added the necessary fields to ShadowStage class and used that information to setup the FBO accordingly.
The result is that I've lost the shadows :-(
Looking with an OpenGL debugger I can see that the color map is rendered correctly, but the shadow factor map is empty (black).
Do you have an idea why this is happening? Maybe some shader code that has problems accessing multi-sampler data?!
Regards,
Michael
Gesendet: Montag, 26. Mai 2014 um 14:05 Uhr
Von: "Carsten Neumann" <carsten_neum...@gmx.net>
An: opensg-users@lists.sourceforge.net
Betreff: Re: [Opensg-users] OpenSG2: Open questions
Von: "Carsten Neumann" <carsten_neum...@gmx.net>
An: opensg-users@lists.sourceforge.net
Betreff: Re: [Opensg-users] OpenSG2: Open questions
Hello Michael,
On 05/21/2014 10:22 AM, Michael Raab wrote:
> > For now I have implemented the use of ShadowEngines. I'll look into
> the details of the ShadowsStages in the next days..
> After some testing the results of the ShadowEngine's seems to be not as
> good as the shadow technique's in OpenSG1.8 were. Therefore I switched
> to the ShadowStage approach.
yes, not all the "filtering" techniques to improve shadow quality are
implemented as engines.
> Works as expected in principle, but with shadows enabled we loose
> anti-aliasing. I guess multisampling needs to be enabled for the
> Framebuffer object that renders to main view. I already looked at the
> code but I have no idea how integrate that in a clean way.
The relevant code should be in ShadowTreeHandler (and derived classes).
The ShadowStage implements an algorithm that is slightly more involved:
1) render scene into FBO (color map fbo, for PCF filtering this is done
in PCFShadowMapHandler::createColorMapFBO, other techniques have similar
functions).
2) render a shadow map for each light source (e.g.
PCFShadowMapHandler::createShadowMapsFBO).
3) Combine all shadow maps into one shadow factor map (e.g.
PCFShadowMapHandler::createShadowFactorMapFBO).
4) Combine the color image from step 1 with the shadow factor map from
step 3 an render to the target buffer (application framebuffer or FBO),
ShadowTreeHandler::setupDrawCombineMap2.
I believe the buffers that should use multisampling are the color map
fbo from 1) and possibly the shadow factor map from 3). These buffers
are generated by the ShadowTreeHandler derived classes [1]. They all get
a pointer to the owning ShadowStage, where a "UseMultisampling" flag
could be added - unfortunately all the ShadowTreeHandlers would need to
be adjusted to evaluate the flag.
Cheers,
Carsten
[1] I haven't checked if a helper function in the base class for setting
up common types of buffers makes sense. That would shrink down the
number of places that require adjustment to evaluate a
"UseMultisampling" flag.
------------------------------------------------------------------------------
The best possible search technologies are now affordable for all companies.
Download your FREE open source Enterprise Search Engine today!
Our experts will assist you in its installation for $59/mo, no commitment.
Test it for FREE on our Cloud platform anytime!
http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users
On 05/21/2014 10:22 AM, Michael Raab wrote:
> > For now I have implemented the use of ShadowEngines. I'll look into
> the details of the ShadowsStages in the next days..
> After some testing the results of the ShadowEngine's seems to be not as
> good as the shadow technique's in OpenSG1.8 were. Therefore I switched
> to the ShadowStage approach.
yes, not all the "filtering" techniques to improve shadow quality are
implemented as engines.
> Works as expected in principle, but with shadows enabled we loose
> anti-aliasing. I guess multisampling needs to be enabled for the
> Framebuffer object that renders to main view. I already looked at the
> code but I have no idea how integrate that in a clean way.
The relevant code should be in ShadowTreeHandler (and derived classes).
The ShadowStage implements an algorithm that is slightly more involved:
1) render scene into FBO (color map fbo, for PCF filtering this is done
in PCFShadowMapHandler::createColorMapFBO, other techniques have similar
functions).
2) render a shadow map for each light source (e.g.
PCFShadowMapHandler::createShadowMapsFBO).
3) Combine all shadow maps into one shadow factor map (e.g.
PCFShadowMapHandler::createShadowFactorMapFBO).
4) Combine the color image from step 1 with the shadow factor map from
step 3 an render to the target buffer (application framebuffer or FBO),
ShadowTreeHandler::setupDrawCombineMap2.
I believe the buffers that should use multisampling are the color map
fbo from 1) and possibly the shadow factor map from 3). These buffers
are generated by the ShadowTreeHandler derived classes [1]. They all get
a pointer to the owning ShadowStage, where a "UseMultisampling" flag
could be added - unfortunately all the ShadowTreeHandlers would need to
be adjusted to evaluate the flag.
Cheers,
Carsten
[1] I haven't checked if a helper function in the base class for setting
up common types of buffers makes sense. That would shrink down the
number of places that require adjustment to evaluate a
"UseMultisampling" flag.
------------------------------------------------------------------------------
The best possible search technologies are now affordable for all companies.
Download your FREE open source Enterprise Search Engine today!
Our experts will assist you in its installation for $59/mo, no commitment.
Test it for FREE on our Cloud platform anytime!
http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users
diff --git a/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStage.fcd b/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStage.fcd index eba10fa..edaf95e 100644 --- a/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStage.fcd +++ b/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStage.fcd @@ -233,4 +233,41 @@ Use blending when writing the combined scene and shadow images to the target framebuffer. </Field> + <Field + name="enableMultiSample" + type="bool" + cardinality="single" + visibility="external" + access="public" + defaultValue="false" + > + Use multisampling when rendering color map and shadow factor map. + </Field> + <Field + name="colorSamples" + type="UInt32" + cardinality="single" + visibility="external" + access="public" + defaultValue="4" + > + </Field> + <Field + name="coverageSamples" + type="UInt32" + cardinality="single" + visibility="external" + access="public" + defaultValue="4" + > + </Field> + <Field + name="fixedSampleLocation" + type="bool" + cardinality="single" + visibility="external" + access="public" + defaultValue="true" + > + </Field> </FieldContainer> diff --git a/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.cpp b/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.cpp index 6a7a3c8..449cb4a 100644 --- a/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.cpp +++ b/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.cpp @@ -180,6 +180,22 @@ OSG_BEGIN_NAMESPACE target framebuffer. */ +/*! \var bool ShadowStageBase::_sfEnableMultiSample + Use multisampling when rendering color map and shadow factor map. +*/ + +/*! \var UInt32 ShadowStageBase::_sfColorSamples + +*/ + +/*! \var UInt32 ShadowStageBase::_sfCoverageSamples + +*/ + +/*! \var bool ShadowStageBase::_sfFixedSampleLocation + +*/ + /***************************************************************************\ * FieldType/FieldTrait Instantiation * @@ -478,6 +494,54 @@ void ShadowStageBase::classDescInserter(TypeObject &oType) static_cast<FieldGetMethodSig >(&ShadowStage::getHandleRenderPropertyMask)); oType.addInitialDesc(pDesc); + + pDesc = new SFBool::Description( + SFBool::getClassType(), + "enableMultiSample", + "Use multisampling when rendering color map and shadow factor map.\n", + EnableMultiSampleFieldId, EnableMultiSampleFieldMask, + false, + (Field::SFDefaultFlags | Field::FStdAccess), + static_cast<FieldEditMethodSig>(&ShadowStage::editHandleEnableMultiSample), + static_cast<FieldGetMethodSig >(&ShadowStage::getHandleEnableMultiSample)); + + oType.addInitialDesc(pDesc); + + pDesc = new SFUInt32::Description( + SFUInt32::getClassType(), + "colorSamples", + "", + ColorSamplesFieldId, ColorSamplesFieldMask, + false, + (Field::SFDefaultFlags | Field::FStdAccess), + static_cast<FieldEditMethodSig>(&ShadowStage::editHandleColorSamples), + static_cast<FieldGetMethodSig >(&ShadowStage::getHandleColorSamples)); + + oType.addInitialDesc(pDesc); + + pDesc = new SFUInt32::Description( + SFUInt32::getClassType(), + "coverageSamples", + "", + CoverageSamplesFieldId, CoverageSamplesFieldMask, + false, + (Field::SFDefaultFlags | Field::FStdAccess), + static_cast<FieldEditMethodSig>(&ShadowStage::editHandleCoverageSamples), + static_cast<FieldGetMethodSig >(&ShadowStage::getHandleCoverageSamples)); + + oType.addInitialDesc(pDesc); + + pDesc = new SFBool::Description( + SFBool::getClassType(), + "fixedSampleLocation", + "", + FixedSampleLocationFieldId, FixedSampleLocationFieldMask, + false, + (Field::SFDefaultFlags | Field::FStdAccess), + static_cast<FieldEditMethodSig>(&ShadowStage::editHandleFixedSampleLocation), + static_cast<FieldGetMethodSig >(&ShadowStage::getHandleFixedSampleLocation)); + + oType.addInitialDesc(pDesc); } @@ -727,6 +791,43 @@ ShadowStageBase::TypeObject ShadowStageBase::_type( " Use blending when writing the combined scene and shadow images to the\n" " target framebuffer.\n" " </Field>\n" + " <Field\n" + " name=\"enableMultiSample\"\n" + " type=\"bool\"\n" + " cardinality=\"single\"\n" + " visibility=\"external\"\n" + " access=\"public\"\n" + " defaultValue=\"false\"\n" + " >\n" + "\tUse multisampling when rendering color map and shadow factor map.\n" + " </Field>\n" + " <Field\n" + " name=\"colorSamples\"\n" + " type=\"UInt32\"\n" + " cardinality=\"single\"\n" + " visibility=\"external\"\n" + " access=\"public\"\n" + " defaultValue=\"4\"\n" + " >\n" + " </Field>\n" + " <Field\n" + " name=\"coverageSamples\"\n" + " type=\"UInt32\"\n" + " cardinality=\"single\"\n" + " visibility=\"external\"\n" + " access=\"public\"\n" + " defaultValue=\"4\"\n" + " >\n" + " </Field>\n" + " <Field\n" + " name=\"fixedSampleLocation\"\n" + " type=\"bool\"\n" + " cardinality=\"single\"\n" + " visibility=\"external\"\n" + " access=\"public\"\n" + " defaultValue=\"true\"\n" + " >\n" + " </Field>\n" "</FieldContainer>\n", "First Release of ShadowMap-Viewport. Viewport is capable to handle multiple\n" "Lights and produces ambient Shadows. Viewport uses On-Screen-rendering, so\n" @@ -1047,6 +1148,58 @@ const SFRenderPropBitVector *ShadowStageBase::getSFRenderPropertyMask(void) cons } +SFBool *ShadowStageBase::editSFEnableMultiSample(void) +{ + editSField(EnableMultiSampleFieldMask); + + return &_sfEnableMultiSample; +} + +const SFBool *ShadowStageBase::getSFEnableMultiSample(void) const +{ + return &_sfEnableMultiSample; +} + + +SFUInt32 *ShadowStageBase::editSFColorSamples(void) +{ + editSField(ColorSamplesFieldMask); + + return &_sfColorSamples; +} + +const SFUInt32 *ShadowStageBase::getSFColorSamples(void) const +{ + return &_sfColorSamples; +} + + +SFUInt32 *ShadowStageBase::editSFCoverageSamples(void) +{ + editSField(CoverageSamplesFieldMask); + + return &_sfCoverageSamples; +} + +const SFUInt32 *ShadowStageBase::getSFCoverageSamples(void) const +{ + return &_sfCoverageSamples; +} + + +SFBool *ShadowStageBase::editSFFixedSampleLocation(void) +{ + editSField(FixedSampleLocationFieldMask); + + return &_sfFixedSampleLocation; +} + +const SFBool *ShadowStageBase::getSFFixedSampleLocation(void) const +{ + return &_sfFixedSampleLocation; +} + + void ShadowStageBase::pushToLightNodes(Node * const value) @@ -1251,6 +1404,22 @@ SizeT ShadowStageBase::getBinSize(ConstFieldMaskArg whichField) { returnValue += _sfRenderPropertyMask.getBinSize(); } + if(FieldBits::NoField != (EnableMultiSampleFieldMask & whichField)) + { + returnValue += _sfEnableMultiSample.getBinSize(); + } + if(FieldBits::NoField != (ColorSamplesFieldMask & whichField)) + { + returnValue += _sfColorSamples.getBinSize(); + } + if(FieldBits::NoField != (CoverageSamplesFieldMask & whichField)) + { + returnValue += _sfCoverageSamples.getBinSize(); + } + if(FieldBits::NoField != (FixedSampleLocationFieldMask & whichField)) + { + returnValue += _sfFixedSampleLocation.getBinSize(); + } return returnValue; } @@ -1348,6 +1517,22 @@ void ShadowStageBase::copyToBin(BinaryDataHandler &pMem, { _sfRenderPropertyMask.copyToBin(pMem); } + if(FieldBits::NoField != (EnableMultiSampleFieldMask & whichField)) + { + _sfEnableMultiSample.copyToBin(pMem); + } + if(FieldBits::NoField != (ColorSamplesFieldMask & whichField)) + { + _sfColorSamples.copyToBin(pMem); + } + if(FieldBits::NoField != (CoverageSamplesFieldMask & whichField)) + { + _sfCoverageSamples.copyToBin(pMem); + } + if(FieldBits::NoField != (FixedSampleLocationFieldMask & whichField)) + { + _sfFixedSampleLocation.copyToBin(pMem); + } } void ShadowStageBase::copyFromBin(BinaryDataHandler &pMem, @@ -1465,6 +1650,26 @@ void ShadowStageBase::copyFromBin(BinaryDataHandler &pMem, editSField(RenderPropertyMaskFieldMask); _sfRenderPropertyMask.copyFromBin(pMem); } + if(FieldBits::NoField != (EnableMultiSampleFieldMask & whichField)) + { + editSField(EnableMultiSampleFieldMask); + _sfEnableMultiSample.copyFromBin(pMem); + } + if(FieldBits::NoField != (ColorSamplesFieldMask & whichField)) + { + editSField(ColorSamplesFieldMask); + _sfColorSamples.copyFromBin(pMem); + } + if(FieldBits::NoField != (CoverageSamplesFieldMask & whichField)) + { + editSField(CoverageSamplesFieldMask); + _sfCoverageSamples.copyFromBin(pMem); + } + if(FieldBits::NoField != (FixedSampleLocationFieldMask & whichField)) + { + editSField(FixedSampleLocationFieldMask); + _sfFixedSampleLocation.copyFromBin(pMem); + } } //! create a new instance of the class @@ -1611,7 +1816,11 @@ ShadowStageBase::ShadowStageBase(void) : _sfAlpha (bool(GL_TRUE)), _sfBlitZBuffer (bool(false)), _sfCombineBlend (bool(false)), - _sfRenderPropertyMask (RenderPropBitVector(SystemRenderProperties.ColorBuffer)) + _sfRenderPropertyMask (RenderPropBitVector(SystemRenderProperties.ColorBuffer)), + _sfEnableMultiSample (bool(false)), + _sfColorSamples (UInt32(4)), + _sfCoverageSamples (UInt32(4)), + _sfFixedSampleLocation (bool(true)) { } @@ -1638,7 +1847,11 @@ ShadowStageBase::ShadowStageBase(const ShadowStageBase &source) : _sfAlpha (source._sfAlpha ), _sfBlitZBuffer (source._sfBlitZBuffer ), _sfCombineBlend (source._sfCombineBlend ), - _sfRenderPropertyMask (source._sfRenderPropertyMask ) + _sfRenderPropertyMask (source._sfRenderPropertyMask ), + _sfEnableMultiSample (source._sfEnableMultiSample ), + _sfColorSamples (source._sfColorSamples ), + _sfCoverageSamples (source._sfCoverageSamples ), + _sfFixedSampleLocation (source._sfFixedSampleLocation ) { } @@ -2257,6 +2470,106 @@ EditFieldHandlePtr ShadowStageBase::editHandleRenderPropertyMask(void) return returnValue; } +GetFieldHandlePtr ShadowStageBase::getHandleEnableMultiSample (void) const +{ + SFBool::GetHandlePtr returnValue( + new SFBool::GetHandle( + &_sfEnableMultiSample, + this->getType().getFieldDesc(EnableMultiSampleFieldId), + const_cast<ShadowStageBase *>(this))); + + return returnValue; +} + +EditFieldHandlePtr ShadowStageBase::editHandleEnableMultiSample(void) +{ + SFBool::EditHandlePtr returnValue( + new SFBool::EditHandle( + &_sfEnableMultiSample, + this->getType().getFieldDesc(EnableMultiSampleFieldId), + this)); + + + editSField(EnableMultiSampleFieldMask); + + return returnValue; +} + +GetFieldHandlePtr ShadowStageBase::getHandleColorSamples (void) const +{ + SFUInt32::GetHandlePtr returnValue( + new SFUInt32::GetHandle( + &_sfColorSamples, + this->getType().getFieldDesc(ColorSamplesFieldId), + const_cast<ShadowStageBase *>(this))); + + return returnValue; +} + +EditFieldHandlePtr ShadowStageBase::editHandleColorSamples (void) +{ + SFUInt32::EditHandlePtr returnValue( + new SFUInt32::EditHandle( + &_sfColorSamples, + this->getType().getFieldDesc(ColorSamplesFieldId), + this)); + + + editSField(ColorSamplesFieldMask); + + return returnValue; +} + +GetFieldHandlePtr ShadowStageBase::getHandleCoverageSamples (void) const +{ + SFUInt32::GetHandlePtr returnValue( + new SFUInt32::GetHandle( + &_sfCoverageSamples, + this->getType().getFieldDesc(CoverageSamplesFieldId), + const_cast<ShadowStageBase *>(this))); + + return returnValue; +} + +EditFieldHandlePtr ShadowStageBase::editHandleCoverageSamples(void) +{ + SFUInt32::EditHandlePtr returnValue( + new SFUInt32::EditHandle( + &_sfCoverageSamples, + this->getType().getFieldDesc(CoverageSamplesFieldId), + this)); + + + editSField(CoverageSamplesFieldMask); + + return returnValue; +} + +GetFieldHandlePtr ShadowStageBase::getHandleFixedSampleLocation (void) const +{ + SFBool::GetHandlePtr returnValue( + new SFBool::GetHandle( + &_sfFixedSampleLocation, + this->getType().getFieldDesc(FixedSampleLocationFieldId), + const_cast<ShadowStageBase *>(this))); + + return returnValue; +} + +EditFieldHandlePtr ShadowStageBase::editHandleFixedSampleLocation(void) +{ + SFBool::EditHandlePtr returnValue( + new SFBool::EditHandle( + &_sfFixedSampleLocation, + this->getType().getFieldDesc(FixedSampleLocationFieldId), + this)); + + + editSField(FixedSampleLocationFieldMask); + + return returnValue; +} + #ifdef OSG_MT_CPTR_ASPECT void ShadowStageBase::execSyncV( FieldContainer &oFrom, diff --git a/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.h b/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.h index 1d6136b..3bd38fb 100644 --- a/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.h +++ b/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.h @@ -118,7 +118,11 @@ class OSG_EFFECTGROUPS_DLLMAPPING ShadowStageBase : public Stage BlitZBufferFieldId = AlphaFieldId + 1, CombineBlendFieldId = BlitZBufferFieldId + 1, RenderPropertyMaskFieldId = CombineBlendFieldId + 1, - NextFieldId = RenderPropertyMaskFieldId + 1 + EnableMultiSampleFieldId = RenderPropertyMaskFieldId + 1, + ColorSamplesFieldId = EnableMultiSampleFieldId + 1, + CoverageSamplesFieldId = ColorSamplesFieldId + 1, + FixedSampleLocationFieldId = CoverageSamplesFieldId + 1, + NextFieldId = FixedSampleLocationFieldId + 1 }; static const OSG::BitVector BufferFormatFieldMask = @@ -165,6 +169,14 @@ class OSG_EFFECTGROUPS_DLLMAPPING ShadowStageBase : public Stage (TypeTraits<BitVector>::One << CombineBlendFieldId); static const OSG::BitVector RenderPropertyMaskFieldMask = (TypeTraits<BitVector>::One << RenderPropertyMaskFieldId); + static const OSG::BitVector EnableMultiSampleFieldMask = + (TypeTraits<BitVector>::One << EnableMultiSampleFieldId); + static const OSG::BitVector ColorSamplesFieldMask = + (TypeTraits<BitVector>::One << ColorSamplesFieldId); + static const OSG::BitVector CoverageSamplesFieldMask = + (TypeTraits<BitVector>::One << CoverageSamplesFieldId); + static const OSG::BitVector FixedSampleLocationFieldMask = + (TypeTraits<BitVector>::One << FixedSampleLocationFieldId); static const OSG::BitVector NextFieldMask = (TypeTraits<BitVector>::One << NextFieldId); @@ -190,6 +202,10 @@ class OSG_EFFECTGROUPS_DLLMAPPING ShadowStageBase : public Stage typedef SFBool SFBlitZBufferType; typedef SFBool SFCombineBlendType; typedef SFRenderPropBitVector SFRenderPropertyMaskType; + typedef SFBool SFEnableMultiSampleType; + typedef SFUInt32 SFColorSamplesType; + typedef SFUInt32 SFCoverageSamplesType; + typedef SFBool SFFixedSampleLocationType; /*---------------------------------------------------------------------*/ /*! \name Class Get */ @@ -279,6 +295,18 @@ class OSG_EFFECTGROUPS_DLLMAPPING ShadowStageBase : public Stage SFRenderPropBitVector *editSFRenderPropertyMask(void); const SFRenderPropBitVector *getSFRenderPropertyMask (void) const; + SFBool *editSFEnableMultiSample(void); + const SFBool *getSFEnableMultiSample (void) const; + + SFUInt32 *editSFColorSamples (void); + const SFUInt32 *getSFColorSamples (void) const; + + SFUInt32 *editSFCoverageSamples(void); + const SFUInt32 *getSFCoverageSamples (void) const; + + SFBool *editSFFixedSampleLocation(void); + const SFBool *getSFFixedSampleLocation (void) const; + GLenum &editBufferFormat (void); const GLenum &getBufferFormat (void) const; @@ -344,6 +372,18 @@ class OSG_EFFECTGROUPS_DLLMAPPING ShadowStageBase : public Stage RenderPropBitVector &editRenderPropertyMask(void); const RenderPropBitVector &getRenderPropertyMask (void) const; + bool &editEnableMultiSample(void); + bool getEnableMultiSample (void) const; + + UInt32 &editColorSamples (void); + UInt32 getColorSamples (void) const; + + UInt32 &editCoverageSamples(void); + UInt32 getCoverageSamples (void) const; + + bool &editFixedSampleLocation(void); + bool getFixedSampleLocation (void) const; + /*! \} */ /*---------------------------------------------------------------------*/ /*! \name Field Set */ @@ -369,6 +409,10 @@ class OSG_EFFECTGROUPS_DLLMAPPING ShadowStageBase : public Stage void setBlitZBuffer (const bool value); void setCombineBlend (const bool value); void setRenderPropertyMask(const RenderPropBitVector &value); + void setEnableMultiSample(const bool value); + void setColorSamples (const UInt32 value); + void setCoverageSamples(const UInt32 value); + void setFixedSampleLocation(const bool value); /*! \} */ /*---------------------------------------------------------------------*/ @@ -467,6 +511,10 @@ class OSG_EFFECTGROUPS_DLLMAPPING ShadowStageBase : public Stage SFBool _sfBlitZBuffer; SFBool _sfCombineBlend; SFRenderPropBitVector _sfRenderPropertyMask; + SFBool _sfEnableMultiSample; + SFUInt32 _sfColorSamples; + SFUInt32 _sfCoverageSamples; + SFBool _sfFixedSampleLocation; /*! \} */ /*---------------------------------------------------------------------*/ @@ -539,6 +587,14 @@ class OSG_EFFECTGROUPS_DLLMAPPING ShadowStageBase : public Stage EditFieldHandlePtr editHandleCombineBlend (void); GetFieldHandlePtr getHandleRenderPropertyMask (void) const; EditFieldHandlePtr editHandleRenderPropertyMask(void); + GetFieldHandlePtr getHandleEnableMultiSample (void) const; + EditFieldHandlePtr editHandleEnableMultiSample(void); + GetFieldHandlePtr getHandleColorSamples (void) const; + EditFieldHandlePtr editHandleColorSamples (void); + GetFieldHandlePtr getHandleCoverageSamples (void) const; + EditFieldHandlePtr editHandleCoverageSamples(void); + GetFieldHandlePtr getHandleFixedSampleLocation (void) const; + EditFieldHandlePtr editHandleFixedSampleLocation(void); /*! \} */ /*---------------------------------------------------------------------*/ diff --git a/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.inl b/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.inl index a9ce898..270cf06 100644 --- a/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.inl +++ b/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowStageBase.inl @@ -574,6 +574,106 @@ void ShadowStageBase::setRenderPropertyMask(const RenderPropBitVector &value) _sfRenderPropertyMask.setValue(value); } +//! Get the value of the ShadowStage::_sfEnableMultiSample field. + +inline +bool &ShadowStageBase::editEnableMultiSample(void) +{ + editSField(EnableMultiSampleFieldMask); + + return _sfEnableMultiSample.getValue(); +} + +//! Get the value of the ShadowStage::_sfEnableMultiSample field. +inline + bool ShadowStageBase::getEnableMultiSample(void) const +{ + return _sfEnableMultiSample.getValue(); +} + +//! Set the value of the ShadowStage::_sfEnableMultiSample field. +inline +void ShadowStageBase::setEnableMultiSample(const bool value) +{ + editSField(EnableMultiSampleFieldMask); + + _sfEnableMultiSample.setValue(value); +} +//! Get the value of the ShadowStage::_sfColorSamples field. + +inline +UInt32 &ShadowStageBase::editColorSamples(void) +{ + editSField(ColorSamplesFieldMask); + + return _sfColorSamples.getValue(); +} + +//! Get the value of the ShadowStage::_sfColorSamples field. +inline + UInt32 ShadowStageBase::getColorSamples(void) const +{ + return _sfColorSamples.getValue(); +} + +//! Set the value of the ShadowStage::_sfColorSamples field. +inline +void ShadowStageBase::setColorSamples(const UInt32 value) +{ + editSField(ColorSamplesFieldMask); + + _sfColorSamples.setValue(value); +} +//! Get the value of the ShadowStage::_sfCoverageSamples field. + +inline +UInt32 &ShadowStageBase::editCoverageSamples(void) +{ + editSField(CoverageSamplesFieldMask); + + return _sfCoverageSamples.getValue(); +} + +//! Get the value of the ShadowStage::_sfCoverageSamples field. +inline + UInt32 ShadowStageBase::getCoverageSamples(void) const +{ + return _sfCoverageSamples.getValue(); +} + +//! Set the value of the ShadowStage::_sfCoverageSamples field. +inline +void ShadowStageBase::setCoverageSamples(const UInt32 value) +{ + editSField(CoverageSamplesFieldMask); + + _sfCoverageSamples.setValue(value); +} +//! Get the value of the ShadowStage::_sfFixedSampleLocation field. + +inline +bool &ShadowStageBase::editFixedSampleLocation(void) +{ + editSField(FixedSampleLocationFieldMask); + + return _sfFixedSampleLocation.getValue(); +} + +//! Get the value of the ShadowStage::_sfFixedSampleLocation field. +inline + bool ShadowStageBase::getFixedSampleLocation(void) const +{ + return _sfFixedSampleLocation.getValue(); +} + +//! Set the value of the ShadowStage::_sfFixedSampleLocation field. +inline +void ShadowStageBase::setFixedSampleLocation(const bool value) +{ + editSField(FixedSampleLocationFieldMask); + + _sfFixedSampleLocation.setValue(value); +} @@ -659,6 +759,18 @@ void ShadowStageBase::execSync ( ShadowStageBase *pFrom, if(FieldBits::NoField != (RenderPropertyMaskFieldMask & whichField)) _sfRenderPropertyMask.syncWith(pFrom->_sfRenderPropertyMask); + + if(FieldBits::NoField != (EnableMultiSampleFieldMask & whichField)) + _sfEnableMultiSample.syncWith(pFrom->_sfEnableMultiSample); + + if(FieldBits::NoField != (ColorSamplesFieldMask & whichField)) + _sfColorSamples.syncWith(pFrom->_sfColorSamples); + + if(FieldBits::NoField != (CoverageSamplesFieldMask & whichField)) + _sfCoverageSamples.syncWith(pFrom->_sfCoverageSamples); + + if(FieldBits::NoField != (FixedSampleLocationFieldMask & whichField)) + _sfFixedSampleLocation.syncWith(pFrom->_sfFixedSampleLocation); } #endif diff --git a/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowTreeHandler.cpp b/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowTreeHandler.cpp index 1326f28..cc9db29 100644 --- a/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowTreeHandler.cpp +++ b/Source/System/NodeCores/Groups/Effects/ShadowStage/OSGShadowTreeHandler.cpp @@ -297,7 +297,11 @@ bool ShadowTreeHandler::initSceneFBO(DrawEnv *pEnv, } _pSceneFBO = FrameBufferObject::createLocal(); - + _pSceneFBO->setEnableMultiSample(this->_pStage->getEnableMultiSample()); + _pSceneFBO->setColorSamples(this->_pStage->getColorSamples()); + _pSceneFBO->setCoverageSamples(this->_pStage->getCoverageSamples()); + _pSceneFBO->setFixedSampleLocation(this->_pStage->getFixedSampleLocation()); + _pSceneFBO->setSize(_width, _height); diff --git a/Source/System/State/Shader/SHL/OSGSimpleSHLChunk.cpp b/Source/System/State/Shader/SHL/OSGSimpleSHLChunk.cpp index 9699a75..c58a084 100644 --- a/Source/System/State/Shader/SHL/OSGSimpleSHLChunk.cpp +++ b/Source/System/State/Shader/SHL/OSGSimpleSHLChunk.cpp @@ -105,6 +105,7 @@ UInt32 SimpleSHLChunk::handleGL(DrawEnv *pEnv, { GLuint uiProgram = GLuint(pWin->getGLObjectId(getGLId()));; + bool forceVariableUpdate = false; if(mode != Window::needrefresh) { if(uiProgram != 0) @@ -276,6 +277,8 @@ UInt32 SimpleSHLChunk::handleGL(DrawEnv *pEnv, pWin->setGLObjectId(getGLId(), uiProgram); updateVariableLocations(pEnv, uiProgram); + + forceVariableUpdate = true; } if(uiProgram != 0) @@ -287,7 +290,7 @@ UInt32 SimpleSHLChunk::handleGL(DrawEnv *pEnv, osgGlUseProgram(uiProgram); - updateVariables(pEnv, uiProgram); + updateVariables(pEnv, uiProgram, forceVariableUpdate); if(0x0000 == (uiOptions & KeepProgActive)) { @@ -1295,7 +1298,8 @@ void SimpleSHLChunk::updateVariableLocations(DrawEnv *pEnv, } void SimpleSHLChunk::updateVariables(DrawEnv *pEnv, - UInt32 uiProgram) + UInt32 uiProgram, + bool forceUpdate ) { if(uiProgram == 0) return; @@ -1339,7 +1343,7 @@ void SimpleSHLChunk::updateVariables(DrawEnv *pEnv, if(pVar == NULL) continue; - if(*mVarChgIt == false) + if(*mVarChgIt == false && !forceUpdate) continue; *mVarChgIt = false; diff --git a/Source/System/State/Shader/SHL/OSGSimpleSHLChunk.h b/Source/System/State/Shader/SHL/OSGSimpleSHLChunk.h index 1dcdc27..dfd5e8f 100644 --- a/Source/System/State/Shader/SHL/OSGSimpleSHLChunk.h +++ b/Source/System/State/Shader/SHL/OSGSimpleSHLChunk.h @@ -354,7 +354,8 @@ class OSG_SYSTEM_DLLMAPPING SimpleSHLChunk : public SimpleSHLChunkBase void updateVariableLocations (DrawEnv *pEnv, UInt32 uiProgram); void updateVariables (DrawEnv *pEnv, - UInt32 uiProgram); + UInt32 uiProgram, + bool forceUpdate = false); void updateParameters (DrawEnv *pEnv, UInt32 uiProgram); void updateProceduralVariables(DrawEnv *pEnv,
------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech
_______________________________________________ Opensg-users mailing list Opensg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensg-users