Game Development Community

[Bug 1.0.1] RenderTranslucentMgr improperly skips fading objects

by Jeff Faust · in Torque 3D Professional · 11/27/2009 (7:23 pm) · 12 replies

Here is some code in renderTranslucentMgr.cpp near line 57:
BaseMatInstance* matInst = getMaterial(inst);
bool translucent = (!matInst || matInst->getMaterial()->isTranslucent());
if (!translucent)
   return RenderBinManager::arSkipped;
The code here skips rendering anything with a material where translucent is set to false.

Since this is the renderTranslucentMgr it appears to be a reasonable action, however, some objects with non-translucent materials can become transparent due to fading operations, or animated visibility. In those cases, this code block causes those objects to vanish as soon as visibility drops below 1.0.

This code appears to persist in T3D 1.1 Alpha.

About the author

Jeff Faust creates special effects indie middleware and games for Faust Logic. --- Blog: Effectronica.com --- Twitter: @FaustLogic


#1
11/27/2009 (7:48 pm)
That might explain the lack of fade out in corpses, then.
#2
11/27/2009 (9:13 pm)
I think in 1.0.1 that code should look something like this:
// See if this instance is translucent.
//   if (!inst->translucentSort) // CHANGED (COMMENTED)
//      return RenderBinManager::arSkipped; // CHANGED (COMMENTED)

   BaseMatInstance* matInst = getMaterial(inst);
   bool translucent = (!matInst || matInst->getMaterial()->isTranslucent());
   if (!translucent && !inst->translucentSort) // CHANGED
      return RenderBinManager::arSkipped;

That should solve the fading issue. I haven't tested that though.

But in 1.1, the part that forces translucentSort to be true when the mesh is fading is not in tsMesh.cpp anymore iirc. (Only have 1.0.1 code in front of me now.) So this will probably work only in 1.0.1.
#3
11/27/2009 (11:05 pm)
To be precise re: 1.1, I only checked that the same code block still existed in that version. It's possible that the fading problem is fixed indirectly in 1.1 without changing this piece of code.
#4
11/28/2009 (1:20 am)
As Konrad noted we don't make a mesh translucent when its fading anymore. In 1.1 opaque objects fade via a new alpha test style fizzle technique in the shader. This allows them to get deferred lighting even when they are fading out which was key to removing pops in LOD switching.
#5
11/28/2009 (11:41 am)
Interesting technique but it looks a bit raster-ie when you're up close. Can you get a better dissolve effect by increasing the resolution of the fizz_noise texture?

#6
11/28/2009 (12:09 pm)
Increasing the resolution of fizz_noise would make it repeat less noticeable but to actually get finer-grain pixel dissolve I guess the game itself would need to run at a higher resolution.
#7
11/28/2009 (12:54 pm)
Still quite raster-ie at my highest res (1680x1050). It comes across as a very 2D digital effect. Overall it's on par with an original Star Trek transporter dissolve.

But this is alpha, so I'm hoping there are options for improving it.
#8
11/28/2009 (3:12 pm)
Hum, with this technique you are limited to turning pixels on or off, so all you have to work with to adjust its quality is the total number of pixels ( resolution ) or the dither / fade pattern.

When this technique is used on a billboard loding away to nothing ( for example GroundCover ) you are not viewing it from very close, also GroundCover in particular would be very expensive to render with true translucency.

For fading out normally opaque objects like a corpse maybe we do need to support an alpha blend fade...
#9
11/28/2009 (11:40 pm)
At the moment... what we got is just about as good as its gonna get for 1.1 final.

Here is the issue.

Advanced Lighting is a deferred renderer... in general deferred renderers do not work with alpha blending. What we do to deal with that is use the normal Basic Lighting rendering for alpha blend objects. The main limitation with that is you won't get any shadowing and are limited to 4 lights affecting the mesh.

So... if you just suddenly switched a normally opaque object that was using AL and getting full shadows and lighting over to BL so that it can fade out, you'll get a clear pop as the shadows disapear and lighting changes on the object.

Of course it all depends on your game what works for you. If you have a game centered on semi-transparent materials on the entire world then maybe you need to make a different.

If you have alot of opaque shadowed shapes that need to do quick transitions between LODs you make this choice. If you remember Doom3... their corpses would do this sort of alpha test disintegration too for the same lighting reasons. Crysis is another that uses the "fizzle" for LOD. So for the time being i think its the least of the evils.

All that said... there is a new deferred rendering technique that allows for transparency and full lighting. Pat and I are working towards getting it into T3D next year, but its not gonna happen in time for 1.1.

So its not that we don't care about this issue... we have a roadmap and we're working towards it.
#10
11/29/2009 (11:17 am)
Thanks for the detailed explaination, Tom.

I'm not worried about corpse fading. It's special effects props that I'm concerned about. However, if it's possible to get non-shadowing opaque objects to do an alpha blend fade, even with BL lighting, that's a compromise that I can get a lot of mileage out of.

#11
12/12/2009 (3:47 am)
For my current project I have to do a lot of transparency effects. One of the features being asked for is to have a Transparency slider control, so that any selected object can be set to any given level of transparency.

I was able to get this working to some extent in 1.01 (with some of the well explained deficiencies above) by calling the swap material function (to a seperate Fade_mat material with an alpha .png texture translucence and lerp alpha settings) and adding some console functions to shapeBase.cpp to manually set the mFadeVal(and all apropriate flags and masks) based on the value of the slider control. Of course as soon as you start fading the object the appearence declines noticably and the shadows disappear (as it switches to basic lighting I assume). If the value is greater than .95 it swaps back the original material(s), and if the slider is less than 0.05 it is set hidden. It's not great, but it works.

I Havn't tested it in 1.1A yet so I hope I can get a similar effect even if it is flawed, otherwise I will be forced to devlope my application in 1.01 only. The pixelated approach would definitely not work for my application as it is not really even a fade(more like a dissolve).
#12
12/12/2009 (5:49 am)
@Jeff

Yes... its exactly a dissolve.

If you want real transparent objects use Basic Lighting, make your materials transparent in AL, or change the code to do whatever you want it too. In a future release... 1.2 or 1.3 we hope to have the new deferred translucency algorithm implemented.