Game Development Community

Weapon Trails not alpha-ing

by Ashley Leach · in Torque Game Engine Advanced · 07/19/2007 (11:02 pm) · 11 replies

Hi All, i posted my previous problem in the Programmer forums, but i have now solved that.

My new issue is that i cant get my trail to alpha at all. It always stays a solid color (i had it fading into the sky but it never fades into the terrain)

Its state setup looks like this.

GFX->pushWorldMatrix();
GFX->setAlphaBlendEnable( true );  
GFX->setZEnable(true);
GFX->setZWriteEnable(true);
GFX->setSrcBlend(GFXBlendSrcAlpha);
GFX->setDestBlend(GFXBlendInvSrcAlpha);


State reset looks like this
GFX->popWorldMatrix();
GFX->setBaseRenderState();

And Build Function

PrimBuild::begin(GFXTriangleStrip,mQuadQueue.size());
   for(VectorF *itr = mQuadQueue.begin(); itr != mQuadQueue.end(); itr++){
   PrimBuild::color4f(1,1,1,0.5);



And here is a pic of it

[IMG]http://img293.imageshack.us/img293/4954/alphabrokenwv6.th.jpg[/IMG]


Any help would be greatly appreciated.

This is the link for the previous solved problem, thanks again Tom.

http://www.garagegames.com/mg/forums/result.thread.php?qt=64936

edit: fixed some spelling and added the previous post link.

#1
07/20/2007 (7:20 am)
First of all use GFX->pushState() and GFX->popState() instead of calling setBaseRenderState() at the end... it does a better job of ensuring you restore things to the way they were before rendering.

For your problem... it seems your trying to use fixed function rendering, so make sure you call GFX->disableShaders(). Also make sure the texture stages are empty... add this loop before rendering:

for ( S32 i=0; i < TEXTURE_STAGE_COUNT; i++ )
      GFX->setTextureStageColorOp( i, GFXTOPDisable );

This ensures that none of the texture stages are enabled.

Unfortunately TGEA has a quite messy state... many times rendering issues are caused by a previous state set by some other SceneObject that didn't get restored to default correctly. It has become an *assume nothing* sort of thing.
#2
07/24/2007 (4:10 pm)
Hi Tom,

this didnt actually change anything at all, unfortunately.

I have moved on from this and made it so i only draws when attacking :)

Do you think if i render the trail using a shader it would help?
#3
07/24/2007 (5:54 pm)
Naw... you shouldn't need a shader for this, although it wouldn't hurt anything.
#4
07/28/2007 (12:01 am)
Hi Tom,

Ive revisited this today for a bit, and i've settled for just blending from purple to white in the trail.

Is there any way i can debug or dump the render states so i can see that they are coming into the function cleanly? The only thing i can think is that the quads cant find anything behind them to alpha to. or the Alpha is not working properly.

Do you have any suggestions or theories i could explore.

thanks for your help thus far.

Kind Regards,
Ashley Leach
#5
07/28/2007 (10:51 am)
Check out Pix for Windows. I often use it to capture a single frame then analyze the render states ... its a really useful debugging tool.
#6
08/07/2007 (1:56 am)
Hi Tom,

This feature is bugging me so i had another try today,

im doing the render call in the bottom of


bool ShapeBase::prepRenderImage(SceneState* state, const U32 stateKey,
                                const U32 startZone, const bool modifyBaseState)

i know this is a bad place for it, but do you think it would cause it not to render alpha on objects behind it, from the look of it, it can alpha itself (i.e. when the trails overlap they alpha each other correctly) but it wont alpha anything else.


Worst case scenario, how much would you charge to implement something like this, if you have the time?
#7
08/07/2007 (8:36 am)
Oh yea... you don't do that.

In prepRenderImage() your supposed to submit a RenderInst* to the gRenderInstManager which later will call the renderObject() function on your object. See ShapeBase::prepRenderImage() and look for gShowBoundingBox. You may need to use the RIT_ObjectTranslucent type instead of RIT_Object to get it to be sorted properly... fxLight::prepRenderImage() has an example of that.
#8
08/07/2007 (6:38 pm)
[IMG]http://img444.imageshack.us/img444/8130/alphafixedomgho7.th.jpg[/IMG]

You rock Tom :)

Here are the results.

If you have a Amazon wish list let me know

ashley.leach[at]silhouette-studios.com.[australia]
#9
08/07/2007 (7:30 pm)
Wow... thats looking like a great effect there.

Naw... no really wishlist... but you can always pick up Torsion or the AdventureKit. They make great gifts! ;)

Uggghhh... i can't believe i said that.
#10
08/07/2007 (7:32 pm)
I already own torsion and had the uni i teach at buy 10 :)
#11
08/07/2007 (7:43 pm)
Then i owed you this one. ;)