MS 3.5) Glow + Translucent Material Not Working
by John Kanalakis · in Torque Game Engine Advanced · 07/08/2006 (3:54 pm) · 9 replies
A .dts shape handles glow perfectly and handles translucent perfectly, but not both combined. This was working perfectly in MS3 but has stopped working with MS 3.5. Here is the material definition used:
terrain_water_demo\data\shapes\test\material.cs
As you can see in the images below, both releases have the translucency working, however, the MS 3.5 version kills the glow effect.
Milestone 3 Code

Milestone 3.5 Code

terrain_water_demo\data\shapes\test\material.cs
new Material(One)
{
mapTo = one;
baseTex[0] = "one";
emissive[0] = true;
glow[0] = true;
[b]translucent[0]=true;
translucentBlendOp = 5;[/b]
};As you can see in the images below, both releases have the translucency working, however, the MS 3.5 version kills the glow effect.
Milestone 3 Code

Milestone 3.5 Code

About the author
John Kanalakis is the owner of EnvyGames, an independent game development studio in Silicon Valley that produces games and tools for Xbox 360, Windows, and the Web.
#2
Look in RenderInstManager::addInst().
Take this block of code:
and move it to the top of the function - this will allow an object to be entered into both the glow and translucent bins.
The next thing you want to do is re-order the RenderBinTypes enum in renderInstMgr.h. Change it to the following:
That should work for you.
IMO, you really can't see much translucency once you make something glow, so I don't think it's worth the extra rendering cost.
07/10/2006 (3:09 pm)
OK, so you can set it up such that glow renders after translucent objects which would enable this effect. The problem will be that glow will completely draw over any translucent objects. So if you had a pane of tinted glass you were looking out of, for instance, the glow would go right over it, which might look odd. If that's fine for your game, here's how to do that:Look in RenderInstManager::addInst().
Take this block of code:
if( inst->matInst )
{
CustomMaterial *custMat = dynamic_cast<CustomMaterial*>( inst->matInst->getMaterial() );
if( custMat && custMat->refract )
{
mRenderBins[ Refraction ]->addElement( inst );
}
if( inst->matInst->hasGlow() &&
!gClientSceneGraph->isReflectPass() &&
!inst->obj )
{
mRenderBins[ Glow ]->addElement( inst );
}
}and move it to the top of the function - this will allow an object to be entered into both the glow and translucent bins.
The next thing you want to do is re-order the RenderBinTypes enum in renderInstMgr.h. Change it to the following:
enum RenderBinTypes
{
Sky = 0,
Begin,
Interior,
Mesh,
MiscObject,
Refraction,
Water,
Translucent,
Glow,
Foliage,
NumRenderBins
};That should work for you.
IMO, you really can't see much translucency once you make something glow, so I don't think it's worth the extra rendering cost.
#3
This certainly does the trick, thank you!!! Everything is back to normal again.... BTW - we're using the glow and translucent combination to produce an engine flare effect. Here's a quick look....
07/10/2006 (10:35 pm)
Brian, This certainly does the trick, thank you!!! Everything is back to normal again.... BTW - we're using the glow and translucent combination to produce an engine flare effect. Here's a quick look....
#4
07/11/2006 (11:38 am)
Looks pretty good.
#5
Just curious, so I can bookmark this thread for the future when I need this :)
07/11/2006 (12:31 pm)
Brian, you're saying that this change won't get into HEAD?Just curious, so I can bookmark this thread for the future when I need this :)
#6
07/11/2006 (2:35 pm)
It's pretty situation specific, and very easy to change, so may not be a HEAD change. One reason we put the instance renderers in was because it was so seasy to then make the right sort order for a given game..
#7
07/11/2006 (6:03 pm)
@Stefan - no this will not go into head. Like Ben said, this is a game-specific thing. I'm keeping head as-is because this rendering order can cause more weird artifacts like I mention above, than not. Ie. head will look correct in more situations.
#8
07/12/2006 (1:54 am)
Got you, thanks for the heads up.
#9
I quickly hacked in this functionality to allow for glowing objects that don't use materials:
renderInstMgr.h, in the RenderInst structure, after the GFX CubeMap pointer:
renderInstMgr.cpp, at the end of the addInst function:
renderGlowMgr.cpp, in the render method:
You can try it out by re-enabling Sky glow like so:
sky.cpp, in prepRenderImage, after the first render instance is added:
Then in the renderObject method, uncomment:
and replace 'image' with 'ri'
Don't mind all the - JM tags, they're just there to help me find my code changes.
There's a few problems with this setup, mainly Z buffering issues. I haven't had the time to work with this any more than getting it to initialy "work". If anybody wants to try to figure out a good way of having glowing custom render objects, please share any progress.
07/22/2006 (12:23 am)
I am also having some issues with the new way glow is handled. Currently, only Materials can use the glow buffer. With the previous setup, it was possible to have custom render objects that glow(for example, the Sky). This seems to me like a needless restriction that TSE should not have.I quickly hacked in this functionality to allow for glowing objects that don't use materials:
renderInstMgr.h, in the RenderInst structure, after the GFX CubeMap pointer:
// Added - JM bool noMat; bool glow;
renderInstMgr.cpp, at the end of the addInst function:
// Added - JM
if(inst->noMat && inst->glow && !gClientSceneGraph->isReflectPass() && inst->obj != NULL) {
mRenderBins[Glow]->addElement(inst);
}renderGlowMgr.cpp, in the render method:
RenderInst *ri = mElementList[j].inst;
//*****
// Added - JM
if(!ri->matInst && ri->noMat) {
if(ri->glow && ri->obj != NULL) {
ri->obj->renderObject(ri->state, ri);
j++;
}
continue;
}
//*****
setupSGData( ri, sgData );You can try it out by re-enabling Sky glow like so:
sky.cpp, in prepRenderImage, after the first render instance is added:
// Added - JM
if(mSkyGlow) {
RenderInst *ri = gRenderInstManager.allocInst();
ri->obj = this;
ri->state = state;
ri->type = RenderInstManager::RIT_Sky;
ri->noMat = true;
ri->glow = true;
gRenderInstManager.addInst(ri);
}Then in the renderObject method, uncomment:
if(image->glow) PrimBuild::color3f(mSkyGlowColor.red,mSkyGlowColor.green,mSkyGlowColor.blue);
and replace 'image' with 'ri'
Don't mind all the - JM tags, they're just there to help me find my code changes.
There's a few problems with this setup, mainly Z buffering issues. I haven't had the time to work with this any more than getting it to initialy "work". If anybody wants to try to figure out a good way of having glowing custom render objects, please share any progress.
Associate Kyle Carter