Decals not showing when they should
by Richard Marrevee · in Torque 3D Professional · 08/11/2013 (3:10 am) · 19 replies
I have added some decals to my level. The decals are applied with the decal editor on horizontal and vertical faces. Now when viewed from certain angles the decals disappear although they should be visible.
Here is a vid showing what is happening (best viewed in HD and fullscreen)
I think that somehow the decals are not flagged for rendering by the decalmanager, but I'm not sure about this.
I am using T3D 3.0 MIT.
Is someone having the same issues?
Is there a solution or can someone point me in the right direction?
Thanks
Richard
Here is a vid showing what is happening (best viewed in HD and fullscreen)
I think that somehow the decals are not flagged for rendering by the decalmanager, but I'm not sure about this.
I am using T3D 3.0 MIT.
Is someone having the same issues?
Is there a solution or can someone point me in the right direction?
Thanks
Richard
About the author
Started programming in 1984 on an Oric, when time progressed switched to MSX, Amiga and finally the Windows PC with T3D. Now developing an epic fantasy game: The Master's Eye. Creator of the DoorClass pack and VolumetricFog pack @ richardsgamestudio.com
#2
I reduced the level to only one sphere with 2 decals (1 vertical, 1 horizontal) and tried figuring out what happen. I found out that when the spere (and the decals) are not showing, DecalManager::prepRenderImage isn't called, so I think the problem is founded somewhere else, but I don't know where to look. I've added a vid showing the DecalSphere rendered and then disappear when it should'nt.
I hope someone can explain what is happening here.
08/11/2013 (1:08 pm)
@Lucas: thanks for the advice.I reduced the level to only one sphere with 2 decals (1 vertical, 1 horizontal) and tried figuring out what happen. I found out that when the spere (and the decals) are not showing, DecalManager::prepRenderImage isn't called, so I think the problem is founded somewhere else, but I don't know where to look. I've added a vid showing the DecalSphere rendered and then disappear when it should'nt.
I hope someone can explain what is happening here.
#3
08/11/2013 (5:32 pm)
Looks like you're using zones. Either the zone setup is incorrect or there's a bug in the culling code (wouldn't be surprised).
#4
08/12/2013 (4:15 am)
That sounds weird to me. Afaik the DecalManager should always have its prepRenderImage method called because it is a global object that handles the culling of the decals. It shouldn't be possible to cull it. Try to see if you can find out how it gets removed from the rendering queue and try to force it to be rendered at all times.
#5
Because the debug renderer only renders the decalspheres that is not culled out. Therefore if prepRenderImage is still called, then I believe it would be this line:
08/12/2013 (9:40 am)
Oh did you just turn the debug rendering on? Or did you actually go into Visual Studio and set a breakpoint to see if prepRenderImage was called or not?Because the debug renderer only renders the decalspheres that is not culled out. Therefore if prepRenderImage is still called, then I believe it would be this line:
if( state->getFrustum().isCulled( worldSphere ) )that introduces the issue.
#6
Btw: "Frustum Lock" locks the frustum so it acts as if the camera is located where you enabled the lock.
08/12/2013 (9:46 am)
Ok try this: Enable "Debug Render: Decals" like you did before, and then enable "Frustum Lock" where the decals isn't rendered but they should be rendered, see if the DecalSphere is inside or intersects with the frustum.Btw: "Frustum Lock" locks the frustum so it acts as if the camera is located where you enabled the lock.
#7
I don't think it has something to do with the zoning system, because the issue still exists when there are no zones in the level.
@Lukas:
I did set a breakpoint at prepRenderImage and it won't get called when the issue is there.
When I enable Frustum Lock when the decals aren't visible while they should be I can see that the sphere is defenitely located inside the frustum.
08/12/2013 (11:02 am)
@Rene:I don't think it has something to do with the zoning system, because the issue still exists when there are no zones in the level.
@Lukas:
I did set a breakpoint at prepRenderImage and it won't get called when the issue is there.
When I enable Frustum Lock when the decals aren't visible while they should be I can see that the sphere is defenitely located inside the frustum.
#8
Somethings wrong with Torques hierarchy when the DecalManager inherits from SceneObject... Owell try modifying the onSceneAdd function:
08/12/2013 (12:50 pm)
Okay well that is interesting indeed.. For some reason it is taken out of the render queue..Somethings wrong with Torques hierarchy when the DecalManager inherits from SceneObject... Owell try modifying the onSceneAdd function:
bool DecalManager::onSceneAdd()
{
if( !Parent::onSceneAdd() )
return false;
SceneZoneSpaceManager::getZoningChangedSignal().notify( this, &DecalManager::_handleZoningChangedEvent );
setGlobalBounds(); // Added this
return true;
}And see if it helps.
#9
The issue remains :( I think it is deeper, the DecalManager isn't found in SceneContainer::findObjectList when it should be found.
08/12/2013 (1:26 pm)
@Lukas:The issue remains :( I think it is deeper, the DecalManager isn't found in SceneContainer::findObjectList when it should be found.
#10
Perhaps it is getting added and removed from the clientcontainer.
Also try adding:
To the loops in findObjectList so you can trace exactly where the Manager is left out of the search.
08/12/2013 (2:03 pm)
Hmm try adding a breakpoint to DecalManager::onSceneAdd()Perhaps it is getting added and removed from the clientcontainer.
Also try adding:
SceneObject *object = chain->object; DecalManager* mgr = dynamic_cast<DecalManager*>(object); if(mgr && mgr->isClientObject()) int a = 2; // Breakpoint here
To the loops in findObjectList so you can trace exactly where the Manager is left out of the search.
#11
Edit: Nvm it uses a box search for the scenerendering.
08/12/2013 (2:10 pm)
Another thing you could try is adding the setGlobalBounds to the sceneOnAdd and then in the Frustum findObjectList change the if clause to this:if ( frustum.isCulled( worldBox ) && !(*outFound)[i]->isGlobalBounds() )
Edit: Nvm it uses a box search for the scenerendering.
#12
After trying all your suggestions still no success :(( The breakpoint you suggested in #10 is never hit, the DecalManager isn't part of the chain anymore when the issue occures.
08/13/2013 (12:56 pm)
@Lukas:After trying all your suggestions still no success :(( The breakpoint you suggested in #10 is never hit, the DecalManager isn't part of the chain anymore when the issue occures.
#13
Pretty lost on this atm.
The only thing I can find that might cause this atm is this piece of code:
08/13/2013 (3:24 pm)
Well that is interesting indeed.. How come it gets deleted from the chain..Pretty lost on this atm.
The only thing I can find that might cause this atm is this piece of code:
MODULE_BEGIN( DecalManager )
MODULE_INIT_AFTER( Scene )
MODULE_SHUTDOWN_BEFORE( Scene )
MODULE_INIT
{
gDecalManager = new DecalManager;
gClientSceneGraph->addObjectToScene( gDecalManager );
}
MODULE_SHUTDOWN
{
gClientSceneGraph->removeObjectFromScene( gDecalManager );
SAFE_DELETE( gDecalManager );
}
MODULE_END;Which is very cryptic to me.. Mystical macros getting involved here. Anw try setting a breakpoint and see if removeObjectFromScene gets called.
#14
Didn't solve the issue either. I checked my other levels and the strange thing is that the issue didn't occur. So I think there mauy be something else in that particular level which causes the issue. I'm going to look at the other things to see what is causing the issue. Thanks for your help anyway.
08/14/2013 (12:44 pm)
@Lukas:Didn't solve the issue either. I checked my other levels and the strange thing is that the issue didn't occur. So I think there mauy be something else in that particular level which causes the issue. I'm going to look at the other things to see what is causing the issue. Thanks for your help anyway.
#15
Unfortunately I don't know anything about how zoning works under the hood.
Edit: anw good luck! I will be listening to this thread if you figure something out.
08/14/2013 (1:12 pm)
Heres a thought, perhaps for some reason the DecalManager belongs to a specific zone, and gets culled out when that zone isn't rendered. Did you use zoning in the other levels?Unfortunately I don't know anything about how zoning works under the hood.
Edit: anw good luck! I will be listening to this thread if you figure something out.
#16
The vids were taken with zones, but I deleted them to see if they were causing the problem, but to no success.
In my other levels I use zones too, but no issue there. The only difference which might be of importance is that the other levels all have small meshes, where the dungeon is one big mesh.
08/15/2013 (9:44 am)
@Lukas:The vids were taken with zones, but I deleted them to see if they were causing the problem, but to no success.
In my other levels I use zones too, but no issue there. The only difference which might be of importance is that the other levels all have small meshes, where the dungeon is one big mesh.
#17
Another difference between this level and the other levels was the value of visibleDistance in LevelInfo. For this level it was set at a low value. Increasing this value did solve the issue, but why it is working this way is still a question. At least I've got the cause of the issue and can dig deeper to see why this is happening.
08/15/2013 (12:20 pm)
Just figured out what is causing this issue :)Another difference between this level and the other levels was the value of visibleDistance in LevelInfo. For this level it was set at a low value. Increasing this value did solve the issue, but why it is working this way is still a question. At least I've got the cause of the issue and can dig deeper to see why this is happening.
#18
Change it to read as:
What this does is first check if the object is using global bounds and then immediately skips to the else{} section below. With the previous logic the (maxX - minX + 1) < csmNumBins test could trigger a dump into the wrong set of sorting bins which was the case for the decal manager.
Another possible fix was to ensure that the decal manager's world bounds are properly set up when first created (it has a size of 0 at this point) but this logic fix should fix all cases.
Unfortunately, I've not tested this change against all other global bounds objects to make sure something else hasn't been broken by this. So far, it is working at my end for my game. Please give the fix a try and let me know. I'll then put in an Issue and Pull Request.
- Dave
08/25/2013 (1:40 pm)
Just spent an hour today fighting with this very same issue. I believe I've found the fix. Open up scene/sceneContainer.cpp and go to SceneContainer::insertIntoBins(). There you'll find this line:if ((maxX - minX + 1) < csmNumBins || (maxY - minY + 1) < csmNumBins && !obj->isGlobalBounds())
Change it to read as:
if (!obj->isGlobalBounds() && ((maxX - minX + 1) < csmNumBins || (maxY - minY + 1) < csmNumBins))
What this does is first check if the object is using global bounds and then immediately skips to the else{} section below. With the previous logic the (maxX - minX + 1) < csmNumBins test could trigger a dump into the wrong set of sorting bins which was the case for the decal manager.
Another possible fix was to ensure that the decal manager's world bounds are properly set up when first created (it has a size of 0 at this point) but this logic fix should fix all cases.
Unfortunately, I've not tested this change against all other global bounds objects to make sure something else hasn't been broken by this. So far, it is working at my end for my game. Please give the fix a try and let me know. I'll then put in an Issue and Pull Request.
- Dave
#19
I don't see strange side-effects on other global bounds objects. I tested it at levels containing cloadlayers, decalroads, scattersky, timeofday, rivers, suns and skyboxes.
Thanks for the fix.
08/26/2013 (9:57 am)
@Dave:I don't see strange side-effects on other global bounds objects. I tested it at levels containing cloadlayers, decalroads, scattersky, timeofday, rivers, suns and skyboxes.
Thanks for the fix.
Torque Owner Lukas Joergensen
WinterLeaf Entertainment
Edit: 1 or as few as possible to make the issue appear.