dark_sylinc wrote: Wed Sep 26, 2018 3:31 pm
Can you post the scene setup? Thanks
Really sorry, but whilst creating patch for you I re-ran the suite of tests, and it runs fine in OpenGL, not sure where or when I got this mixed up. However it is definitely broken in DirectX

!
Code: Select all
diff -r bb8d0c77f1c1 Samples/2.0/ApiUsage/AreaApproxLights/AreaApproxLightsGameState.cpp
--- a/Samples/2.0/ApiUsage/AreaApproxLights/AreaApproxLightsGameState.cpp Tue Sep 25 16:24:10 2018 +0100
+++ b/Samples/2.0/ApiUsage/AreaApproxLights/AreaApproxLightsGameState.cpp Wed Sep 26 15:45:54 2018 +0100
@@ -235,8 +235,25 @@
planeMesh->importV1( planeMeshV1.get(), true, true, true );
{
+ Ogre::HlmsManager *hlmsManager = mGraphicsSystem->getRoot()->getHlmsManager();
+ Ogre::HlmsTextureManager *hlmsTextureManager = hlmsManager->getTextureManager();
+
+ assert(dynamic_cast<Ogre::HlmsPbs*>(hlmsManager->getHlms(Ogre::HLMS_PBS)));
+
+ Ogre::HlmsPbs *hlmsPbs = static_cast<Ogre::HlmsPbs*>(hlmsManager->getHlms(Ogre::HLMS_PBS));
+
Ogre::Item *item = sceneManager->createItem( planeMesh, Ogre::SCENE_DYNAMIC );
- item->setDatablock( "Marble" );
+ Ogre::String datablockName = "Test_plane";
+ Ogre::HlmsPbsDatablock *datablock = static_cast<Ogre::HlmsPbsDatablock*>(
+ hlmsPbs->createDatablock(datablockName,
+ datablockName,
+ Ogre::HlmsMacroblock(),
+ Ogre::HlmsBlendblock(),
+ Ogre::HlmsParamVec()));
+
+ datablock->setRoughness(0.2);
+ datablock->setDiffuse(Ogre::Vector3(1,1,1));
+ item->setDatablock(datablock);
Ogre::SceneNode *sceneNode = sceneManager->getRootSceneNode( Ogre::SCENE_DYNAMIC )->
createChildSceneNode( Ogre::SCENE_DYNAMIC );
sceneNode->setPosition( 0, -1, 0 );
@@ -244,22 +261,22 @@
//Change the addressing mode of the roughness map to wrap via code.
//Detail maps default to wrap, but the rest to clamp.
- assert( dynamic_cast<Ogre::HlmsPbsDatablock*>( item->getSubItem(0)->getDatablock() ) );
- Ogre::HlmsPbsDatablock *datablock = static_cast<Ogre::HlmsPbsDatablock*>(
- item->getSubItem(0)->getDatablock() );
- //Make a hard copy of the sampler block
- Ogre::HlmsSamplerblock samplerblock( *datablock->getSamplerblock( Ogre::PBSM_ROUGHNESS ) );
- samplerblock.mU = Ogre::TAM_WRAP;
- samplerblock.mV = Ogre::TAM_WRAP;
- samplerblock.mW = Ogre::TAM_WRAP;
- //Set the new samplerblock. The Hlms system will
- //automatically create the API block if necessary
- datablock->setSamplerblock( Ogre::PBSM_ROUGHNESS, samplerblock );
+ //assert( dynamic_cast<Ogre::HlmsPbsDatablock*>( item->getSubItem(0)->getDatablock() ) );
+ //Ogre::HlmsPbsDatablock *datablock = static_cast<Ogre::HlmsPbsDatablock*>(
+ // item->getSubItem(0)->getDatablock() );
+ ////Make a hard copy of the sampler block
+ //Ogre::HlmsSamplerblock samplerblock( *datablock->getSamplerblock( Ogre::PBSM_ROUGHNESS ) );
+ //samplerblock.mU = Ogre::TAM_WRAP;
+ //samplerblock.mV = Ogre::TAM_WRAP;
+ //samplerblock.mW = Ogre::TAM_WRAP;
+ ////Set the new samplerblock. The Hlms system will
+ ////automatically create the API block if necessary
+ //datablock->setSamplerblock( Ogre::PBSM_ROUGHNESS, samplerblock );
}
- for( int i=0; i<4; ++i )
+ for( int i=0; i<0; ++i )
{
- for( int j=0; j<4; ++j )
+ for( int j=0; j<0; ++j )
{
Ogre::String meshName;
@@ -304,8 +321,8 @@
Ogre::HlmsPbs *hlmsPbs = static_cast<Ogre::HlmsPbs*>( hlmsManager->getHlms(Ogre::HLMS_PBS) );
- const int numX = 8;
- const int numZ = 8;
+ const int numX = 0;
+ const int numZ = 0;
const float armsLength = 1.0f;
const float startX = (numX-1) / 2.0f;
@@ -358,7 +375,7 @@
Ogre::Light *light = sceneManager->createLight();
Ogre::SceneNode *lightNode = rootNode->createChildSceneNode();
lightNode->attachObject( light );
- light->setPowerScale( 1.0f );
+ light->setPowerScale( 0 );
light->setType( Ogre::Light::LT_DIRECTIONAL );
light->setDirection( Ogre::Vector3( -1, -1, -1 ).normalisedCopy() );
@@ -371,7 +388,7 @@
light->setSpecularColour( 0.8f, 0.4f, 0.2f );
//Increase the strength 10x to showcase this light. Area approx lights are not
//physically based so the value is more arbitrary than the other light types
- light->setPowerScale( Ogre::Math::PI );
+ light->setPowerScale( 0 );
light->setType( Ogre::Light::LT_AREA_APPROX );
light->setRectSize( Ogre::Vector2( 15.0f, 15.0f ) );
lightNode->setPosition( -10.0f, 6.0f, 10.0f );
@@ -388,17 +405,18 @@
mAreaLights[0] = light;
mLightNodes[1] = lightNode;
+ lightNode->setVisible(false);
light = sceneManager->createLight();
lightNode = rootNode->createChildSceneNode();
lightNode->attachObject( light );
- light->setDiffuseColour( 0.2f, 0.4f, 0.8f ); //Cold
- light->setSpecularColour( 0.2f, 0.4f, 0.8f );
- light->setPowerScale( Ogre::Math::PI );
+ light->setDiffuseColour( 1.0f, 1.0f, 1.0f ); //Cold
+ light->setSpecularColour(1.0f, 1.0f, 1.0f);
+ light->setPowerScale(4.0f );
light->setType( Ogre::Light::LT_AREA_APPROX );
- light->setRectSize( Ogre::Vector2( 5.0f, 5.0f ) );
- lightNode->setPosition( 5.0f, 4.0f, -5.0f );
- light->setDirection( Ogre::Vector3( -1, -1, 1 ).normalisedCopy() );
+ light->setRectSize( Ogre::Vector2( 4.0f, 4.0f ) );
+ lightNode->setPosition( 5.0f, 3.0f, -5.0f );
+ light->setDirection( Ogre::Vector3( -1, 0, 0 ).normalisedCopy() );
light->setAttenuationBasedOnRadius( 10.0f, 0.01f );
//When the array index is 0xFFFF, the light won't use a texture.
light->mTextureLightMaskIdx = std::numeric_limits<Ogre::uint16>::max();
@@ -422,8 +440,8 @@
{
if( mAnimateObjects )
{
- for( int i=0; i<16; ++i )
- mSceneNode[i]->yaw( Ogre::Radian(timeSinceLast * i * 0.125f) );
+ //for( int i=0; i<16; ++i )
+ // mSceneNode[i]->yaw( Ogre::Radian(timeSinceLast * i * 0.125f) );
mLightNodes[1]->roll( Ogre::Radian( timeSinceLast ) );
mLightNodes[1]->yaw( Ogre::Radian( timeSinceLast ) );
rujialiu wrote: Wed Sep 26, 2018 2:34 pm
al2950 wrote: Tue Sep 25, 2018 5:18 pm
Done! . The lighting issues can be seen when using forwardPlus as well as standard forward, although in different ways. Its seems to be a light culling issue, and the light is bing incorrectly culled in both shadow and lighting passes but in different ways
Great!!! We're not using SSR, so we don't use hybrid rendering. By reading your PR I realized that maybe we can still try hybrid rendering even without using SSR. Besides SSR, what else can be implemented/optimized with a z-prepass + thin G-Buffer? Volumetric lighting? SSAO/more advanced AO?
Ignoring the performance improvements (compute shader based clustered shading requires pre-z aswell) There are a whole bunch of effects that require or have a version that requires a depth buffer, although it does not have to be a z-prepass. Volumetric lighting, SSAO, I certainly some popular ones. Also GPU particles, as they can use the scene depth buffer to perform some simple particle collision simulation. Most engines will also render a velocity buffer during the prepass for motion blur, etc. Hybrid rendering is the way forward!!