Game Development Community

[Bug 1.0.1] setCloaked not working + Basic Lighting shadow issue with faded object - fix included

by elvince · in Torque 3D Professional · 11/02/2009 (3:52 pm) · 12 replies

Hi,

I was testing this functionality but I have a strange behavior. when setting the first cloaked value to "true", the mounted image disappear but not the player.

How to reproduce:
Open the FPS example.
Launch your game.
Edit your mission to get the player Id
call id.setcloaked(true)
and you will see the weapon disappear.
call id.setcloaked(false) and the weapon is back again

I saw some thread on TGEA for this : www.garagegames.com/community/forums/viewthread/53230
A guy said to fix this issue:
PrepRenderImage (shapeBase.cpp) add the mCloaked check yourself for the shadow image before its added to the render instance manager. prepBatchRender add the check for parent object before its animated and rendered.

I hope this help, because this didn't help me :(

Question: Does the cloaked function is obsolete and we should use fade functionality?

#1
11/02/2009 (4:12 pm)
shapeBase.cpp , (line 2446)

At the end of _prepRenderImage(),locate this:

if ( mShapeInstance && renderSelf )
       prepBatchRender( state, -1 );

replace with:

if ( mShapeInstance && renderSelf )
         if (mCloakLevel == 0.0f  && mFadeVal == 1.0f) prepBatchRender( state, -1 );
#2
11/02/2009 (4:24 pm)
Also, *.setallmesheshidden(1);

Is there a real difference between the idea of setCloaked and this?
#3
11/02/2009 (4:30 pm)
Steve, it is the same.

setCloaked() stops the rendering from shapeBase::_prepRenderImage()
setAllMeshesHidden () stops the rendering from TSShapeInstance::MeshObjectInstance::render()

It is the same functionality.
#4
11/02/2009 (4:33 pm)
Just checking, I was a bit confused as to why they'd be 2 functions that do the same thing.
#5
11/02/2009 (5:08 pm)
Thanks for the bug fix picasso.

setCloaked is equivalent of setAllMeshesHidden, as steve said, it very confusing to have 2 function for the same functionality.

The only difference I see is that setcloaked take 0.5 sec to be active and setAllMeshesHidden is immediate.

But what about fade functionality? it seems it will do the same as setCloaked but we have the opportunity to set the "timeout". But I'm not sure you see a real fading, it seems to be like an on/off but after a certain amount of time correct?
#6
11/03/2009 (7:24 am)
If you want to fade something, take care that you have translucency enabled in your material.
You can add an element in the RenderTranslucentMgr if only translucency is set to "true".

translucent = true;
translucentBlendOp = "LerpAlpha";
translucentZWrite = "1";

Then you should provide a texture with an alpha channel(png,..).

Then call:
object.startfade(1000,1000,1); // fade in
object.startfade(1000,1000,0); // fade out

EDIT:
Found a bug in Basic lightning.
When the object is faded,player's shadow decal renders squared at the place of the invisible object.
The idea is when an object is faded,there must be no shadow rendering.

img43.imageshack.us/img43/4669/decalbug2.jpg
I think decalManager is responsible for this bug.
#7
11/04/2009 (3:31 am)
many thanks for the tips.
T3D have a lot of thing already included but sometimes difficult to understand/know them without the community.

SO now we have 2 bugs in one thread :D
#8
11/04/2009 (4:38 pm)
Anyone ?
This decal should not be rendered.
#9
11/05/2009 (12:04 pm)
[RESOLVED]

It was a very simple bug into the shadow projector.

bool ProjectedShadow::shouldRender( const SceneState *state )
{...
   if (  shapeFade || !mDecalData ||
         (  mDecalInstance && 
            mDecalInstance->calcPixelRadius( state ) < mDecalInstance->calcEndPixRadius( state->getViewportExtent() ) ) )
   {
      // Release our shadow texture
      // so that others can grab it out
      // of the pool.
      mShadowTexture = NULL;
      return true;
   }
...
}

@elvince
I think the 2 bugs are resolved now,so you can move this thread to resolved.
#10
11/05/2009 (2:33 pm)
OK I will edit also the thread name and put this issue as resolved.

But just to understand the 2nd fix:
You change the return false to return true isn't it?

So if you are in this case, why the return false didn't work?
because shouldRender = True means it will render the shadow with texture = null.
With false, it should not render the shadow at all. Could you please explain me why we need to do that? it seems to be non sense in my opinion, or there is a side effect by having shouldRender=false and you fix it by doint shouldRender=true and shadow texture=null and we may need to look at fixing this?

Thanks in advance for the clarification.
#11
11/05/2009 (3:32 pm)
I think it is due to BasicSceneObjectLightingPlugin.
It is searching for mShadow->shouldRender( state ))
If shouldRender() returns false,the shadow is not rendered and we see this unlit decal.

So..

mShadowTexture = NULL;  
return true;

means it will render the shadow with NULL texture

For what i have tested,i think shadow should be rendered,even the object is faded.
May be there is another optimized solution,but right now this works.
#12
11/05/2009 (4:41 pm)
Thanks for the explanation.

I hope GG will comment this and approve this is the correct approach to solve this issue.
In the meantime, we have a working solution thanks to you.