@ -731,7 +731,7 @@ namespace SceneUtil
META_StateAttribute ( NifOsg , LightManagerStateAttribute , osg : : StateAttribute : : LIGHT )
void initSharedLayout ( osg : : GLExtensions * ext , int handle ) const
void initSharedLayout ( osg : : GLExtensions * ext , int handle , LightManager & lightManager ) const
{
constexpr std : : array < unsigned int , 1 > index = { static_cast < unsigned int > ( Shader : : UBOBinding : : LightBuffer ) } ;
int totalBlockSize = - 1 ;
@ -753,13 +753,17 @@ namespace SceneUtil
for ( int i = 0 ; i < 2 ; + + i )
{
auto & buf = mLightManager- > getLightBuffer ( i ) ;
auto & buf = lightManager. getLightBuffer ( i ) ;
buf - > configureLayout ( offsets [ 0 ] , offsets [ 1 ] , offsets [ 2 ] , totalBlockSize , stride ) ;
}
}
void apply ( osg : : State & state ) const override
{
osg : : ref_ptr < LightManager > lightManager ;
if ( ! mLightManager . lock ( lightManager ) )
return ;
if ( ! mInitLayout )
{
mDummyProgram - > apply ( state ) ;
@ -772,12 +776,12 @@ namespace SceneUtil
// wait until the UBO binding is created
if ( activeUniformBlocks > 0 )
{
initSharedLayout ( ext , handle );
initSharedLayout ( ext , handle , * lightManager );
mInitLayout = true ;
}
}
mL ightManager- > getLightBuffer ( state . getFrameStamp ( ) - > getFrameNumber ( ) ) - > uploadCachedSunPos ( state . getInitialViewMatrix ( ) ) ;
mL ightManager- > getLightBuffer ( state . getFrameStamp ( ) - > getFrameNumber ( ) ) - > dirty ( ) ;
l ightManager- > getLightBuffer ( state . getFrameStamp ( ) - > getFrameNumber ( ) ) - > uploadCachedSunPos ( state . getInitialViewMatrix ( ) ) ;
l ightManager- > getLightBuffer ( state . getFrameStamp ( ) - > getFrameNumber ( ) ) - > dirty ( ) ;
}
private :
@ -807,7 +811,7 @@ namespace SceneUtil
return shader ;
}
LightManager* mLightManager ;
osg: : observer_ptr < LightManager > mLightManager ;
osg : : ref_ptr < osg : : Program > mDummyProgram ;
mutable bool mInitLayout ;
} ;