yellow objects
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
yellow objects
I moved a working program from the 2.1 version to the 2.2 version. For some reason, my items are all showing up yellow. they should be white as I call setDiffuse( { 1.0f, 1.0f, 1.0f } ) on the material being applied to the them. The items have no textures applied I simply want properly colored shapes. I get the right color if I call set setEmissive( { 1.0f, 1.0f, 1.0f } ) so I know the material is generally working. Note I am programmatically creating the material...
auto tmpName = "C3DWindowController_mat_rgba_cone_Pbs_"s + std::to_string(tmpKey);
auto tmpHlmsManagerPtr = Ogre::Root::getSingleton().getHlmsManager();
auto tmpHlmsPbsPtr = tmpHlmsManagerPtr->getHlms(Ogre::HLMS_PBS);
if(tmpMaterialPtr == nullptr)
{
auto tmpMaterial2Ptr = static_cast<Ogre::HlmsPbsDatablock*>(
tmpHlmsPbsPtr->createDatablock( tmpName,
tmpName,
Ogre::HlmsMacroblock(),
Ogre::HlmsBlendblock(),
Ogre::HlmsParamVec() , true, "", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) );
auto tmpRedValue = (float_t)((theValue >> 24) & 0xFF) / 255.0f;
auto tmpGreenValue = (float_t)((theValue >> 16) & 0xFF) / 255.0f;
auto tmpBlueValue = (float_t)((theValue >> & 0xFF) / 255.0f;
tmpMaterial2Ptr->setDiffuse( { 1.0f, 1.0f, 01.0f } );
...
WHat might I be doing wrong to get everything yellow? I don't have anything I color yellow myself in the program
auto tmpName = "C3DWindowController_mat_rgba_cone_Pbs_"s + std::to_string(tmpKey);
auto tmpHlmsManagerPtr = Ogre::Root::getSingleton().getHlmsManager();
auto tmpHlmsPbsPtr = tmpHlmsManagerPtr->getHlms(Ogre::HLMS_PBS);
if(tmpMaterialPtr == nullptr)
{
auto tmpMaterial2Ptr = static_cast<Ogre::HlmsPbsDatablock*>(
tmpHlmsPbsPtr->createDatablock( tmpName,
tmpName,
Ogre::HlmsMacroblock(),
Ogre::HlmsBlendblock(),
Ogre::HlmsParamVec() , true, "", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) );
auto tmpRedValue = (float_t)((theValue >> 24) & 0xFF) / 255.0f;
auto tmpGreenValue = (float_t)((theValue >> 16) & 0xFF) / 255.0f;
auto tmpBlueValue = (float_t)((theValue >> & 0xFF) / 255.0f;
tmpMaterial2Ptr->setDiffuse( { 1.0f, 1.0f, 01.0f } );
...
WHat might I be doing wrong to get everything yellow? I don't have anything I color yellow myself in the program
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: yellow objects
Yellow is an indication of wrong padding in our shader structures.
What RenderSystem / OS are you using?
Are you customizing Hlms or using stock?
Would you be able to repro this bug in one of our samples? (e.g. take Tutorial02 and make a few changes to highlight the bug)
What RenderSystem / OS are you using?
Are you customizing Hlms or using stock?
Would you be able to repro this bug in one of our samples? (e.g. take Tutorial02 and make a few changes to highlight the bug)
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
Re: yellow objects
I did try using my simple material in Sample_decals. I changed to code to apply my material to the plane. I did not get yellow color I see in my production project, but the result is not what I expect either. snippet...
planeMesh->importV1( planeMeshV1.get(), true, true, true );
{
Ogre::Item *item = sceneManager->createItem( planeMesh, Ogre::SCENE_DYNAMIC );
Ogre::HlmsManager *hlmsManager = mGraphicsSystem->getRoot()->getHlmsManager();
auto tmpHlmsPbsPtr = hlmsManager->getHlms(Ogre::HLMS_PBS);
auto tmpMaterial2Ptr = static_cast<Ogre::HlmsPbsDatablock*>(
tmpHlmsPbsPtr->createDatablock( "C3DWindowController_mat_rgba_Pbs_4294901760",
"C3DWindowController_mat_rgba_Pbs_4294901760",
Ogre::HlmsMacroblock(),
Ogre::HlmsBlendblock(),
Ogre::HlmsParamVec() , true, "", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) );
tmpMaterial2Ptr->setDiffuse( { 1.0f, 1.0f, 1.0f } );
item->setDatablock( tmpMaterial2Ptr );
//item->setDatablock( "Marbledgfgfg" );
Ogre::SceneNode *sceneNode = sceneManager->getRootSceneNode( Ogre::SCENE_DYNAMIC )->
createChildSceneNode( Ogre::SCENE_DYNAMIC );
sceneNode->setPosition( 0, -1, 0 );
sceneNode->attachObject( item );
I would expect to see a white plane, but it looks like white is being blended with the blue background. I'm not doing anything to cause transparency.
planeMesh->importV1( planeMeshV1.get(), true, true, true );
{
Ogre::Item *item = sceneManager->createItem( planeMesh, Ogre::SCENE_DYNAMIC );
Ogre::HlmsManager *hlmsManager = mGraphicsSystem->getRoot()->getHlmsManager();
auto tmpHlmsPbsPtr = hlmsManager->getHlms(Ogre::HLMS_PBS);
auto tmpMaterial2Ptr = static_cast<Ogre::HlmsPbsDatablock*>(
tmpHlmsPbsPtr->createDatablock( "C3DWindowController_mat_rgba_Pbs_4294901760",
"C3DWindowController_mat_rgba_Pbs_4294901760",
Ogre::HlmsMacroblock(),
Ogre::HlmsBlendblock(),
Ogre::HlmsParamVec() , true, "", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME) );
tmpMaterial2Ptr->setDiffuse( { 1.0f, 1.0f, 1.0f } );
item->setDatablock( tmpMaterial2Ptr );
//item->setDatablock( "Marbledgfgfg" );
Ogre::SceneNode *sceneNode = sceneManager->getRootSceneNode( Ogre::SCENE_DYNAMIC )->
createChildSceneNode( Ogre::SCENE_DYNAMIC );
sceneNode->setPosition( 0, -1, 0 );
sceneNode->attachObject( item );
I would expect to see a white plane, but it looks like white is being blended with the blue background. I'm not doing anything to cause transparency.
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
Re: yellow objects
platform is OSX 10.14
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: yellow objects
I get a white plane:
I noticed you wrote:
{ 1.0f, 1.0f, 01.0f }
Could you try Ogre::Vector3( 1.0f, 1.0f, 1.0f )
I don't know if that C++11 construct has the same meaning, and also you wrote 01.0f instead of 1.0f. That zero on the left may be causing trouble.
Btw you didn't mention your RenderSystem. Are you using OpenGL? Are you able to try Metal? Or OpenGL on another platform? (e.g. Linux, Windows)
I noticed you wrote:
{ 1.0f, 1.0f, 01.0f }
Could you try Ogre::Vector3( 1.0f, 1.0f, 1.0f )
I don't know if that C++11 construct has the same meaning, and also you wrote 01.0f instead of 1.0f. That zero on the left may be causing trouble.
Btw you didn't mention your RenderSystem. Are you using OpenGL? Are you able to try Metal? Or OpenGL on another platform? (e.g. Linux, Windows)
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: yellow objects
Place a breakpoint inside HlmsPbsDatablock::uploadToConstBuffer when you hit your datablock's name, and ensure mkDr, mkDg and mkDb are white (divided by PI).
If it's not, then your value got modified somewhere in the middle.
Adding a data breakpoint to datablock->mkDb could help you find where it's being modified.
Use:
Where 0x12345678 is the address of &datablock->mkDb
If it's not, then your value got modified somewhere in the middle.
Adding a data breakpoint to datablock->mkDb could help you find where it's being modified.
Use:
Code: Select all
wa s e -- 0x12345678
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
Re: yellow objects
I set diffuse to blue (0,0,1). after here..
float oldkDr = mkDr;
float oldkDg = mkDg;
float oldkDb = mkDb;
oldkDr = 0
oldkDg = 0
oldkDb = 0.318309873
same after here...
mkDr = oldkDr;
mkDg = oldkDg;
mkDb = oldkDb;
float oldkDr = mkDr;
float oldkDg = mkDg;
float oldkDb = mkDb;
oldkDr = 0
oldkDg = 0
oldkDb = 0.318309873
same after here...
mkDr = oldkDr;
mkDg = oldkDg;
mkDb = oldkDb;
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
Re: yellow objects
Where mkDr, mkDg and mkDb actually make their way into the mental renderer where they are put to use to actually render the scene? I don't see those values stored to any buffers or fed to anything else.
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
Re: yellow objects
ah. I see how it is copied to a buffer.
The value is making its way into dstPtr.
Where is the next access point to check?
The value is making its way into dstPtr.
Where is the next access point to check?
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: yellow objects
That happens here:
Try setting pbs->setOptimizationStrategy( LowerGpuOverhead );
Also stupid question: Your light isn't set to yellow? Because blue will never appear if the lights don't send blue.
Code: Select all
memcpy( dstPtr, &mBgDiffuse[0], MaterialSizeInGpu - sizeof(mTexIndices) );
dstPtr += MaterialSizeInGpu - sizeof(mTexIndices);
memcpy( dstPtr, texIndices, sizeof(texIndices) );
dstPtr += sizeof(texIndices);
Also stupid question: Your light isn't set to yellow? Because blue will never appear if the lights don't send blue.
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: yellow objects
None, that's the last step. You can use XCode GPU Debugger to check the buffer is properly set.
But beware the value is material[materialIdx], and sometimes materialIdx is hard to get (unless you're using LowerGpuOverhead, which always forces everything to material[0])
It's also quite possible to check in XCode GPU Debugger that the PassBuffer's light colour is incorrectly set, which could happen if we missed some alignment/padding.
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
Re: yellow objects
dark_sylinc wrote: ↑Thu Aug 15, 2019 4:41 pm Also stupid question: Your light isn't set to yellow? Because blue will never appear if the lights don't send blue.
The light is white.
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
Re: yellow objects
dark_sylinc wrote: ↑Thu Aug 15, 2019 3:52 pm I get a white plane:
how is it white? It looks lavender to me. I'd expect pure white. given the plane is not set to be transparent. What am I missing?
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
Re: yellow objects
Metal. OpenGL is broken on 2.2. doesn't even build. I only operate on OSXdark_sylinc wrote: ↑Thu Aug 15, 2019 3:52 pm
Btw you didn't mention your RenderSystem. Are you using OpenGL? Are you able to try Metal? Or OpenGL on another platform? (e.g. Linux, Windows)
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
Re: yellow objects
ok. I want to investigate the possibility that there is an alignment error. What am I looking for in developer docs to understand the structure that is being built in the buffer?dark_sylinc wrote: ↑Thu Aug 15, 2019 4:45 pm
It's also quite possible to check in XCode GPU Debugger that the PassBuffer's light colour is incorrectly set, which could happen if we missed some alignment/padding.
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: yellow objects
Let me know if this guide helps you or is not what you're looking for.
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
- dark_sylinc
- OGRE Team Member
- Posts: 5299
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1280
- Contact:
Re: yellow objects
Is it possible your Hlms templates are out of date?
Very recently we added "float4 pccVctMinDistance_invPccVctInvDistance_unused2" to 500.Structs_piece_vs_piece_ps.any which sits right between invViewMatCubemap and ambientUpperHemi; and would be filled with 1 1 0 0 with the default values.
Very recently we added "float4 pccVctMinDistance_invPccVctInvDistance_unused2" to 500.Structs_piece_vs_piece_ps.any which sits right between invViewMatCubemap and ambientUpperHemi; and would be filled with 1 1 0 0 with the default values.
-
- Halfling
- Posts: 48
- Joined: Wed Sep 05, 2018 3:18 pm
Re: yellow objects
dark_sylinc wrote: ↑Fri Aug 16, 2019 7:48 pm Is it possible your Hlms templates are out of date?
Very recently we added "float4 pccVctMinDistance_invPccVctInvDistance_unused2" to 500.Structs_piece_vs_piece_ps.any which sits right between invViewMatCubemap and ambientUpperHemi; and would be filled with 1 1 0 0 with the default values.
that is exactly the problem. when I updated the libs in my 3rd party sdk folder, I didn't install the new shader files. thanks!
I tracked it down to exactly that chunk of code.