Game Development Community

ScatterSky Flare Rendering Broken?

by Chad Hall · in Torque 3D Professional · 08/23/2014 (8:39 pm) · 4 replies

This is something I've been aware of for awhile now but never put the effort into tracking down until today. When you use a Sun object with a flare everything seems to render fine but when a ScatterSky object with a sun flare enabled is used the flare just doesn't work.

In scatterSky.cpp in the prepRenderImage function the flare data is setup with a position:

Point3F lightPos = state->getCameraPosition() - state->getFarPlane() * mLight->getDirection() * 0.9f;
mFlareState.lightMat.identity();
mFlareState.lightMat.setPosition( lightPos );

Just like in the Sun object's flare code the flare is then sent to LightFlareData::prepRender. Except, unlike the Sun object's flare the ScatterSky flare exits the function here:

bool lightVisible = _testVisibility( state, flareState, &visDelta, &occlusionFade, &lightPosSS );
   
// We can only skip rendering if the light is not 
// visible, and it has elapsed the fade out time.
if (  mIsZero( occlusionFade ) ||
      !lightVisible && visDelta > FadeOutTime )
   return;

_testVisibility will return false and the render will be skipped. I can "fix" the problem by altering the position the ScatterSky object sets the flare to:

Point3F lightPos = state->getCameraPosition() - state->getFarPlane() * mLight->getDirection() * 0.22f;

0.22 is the highest value I've tried before it starts rendering. Any values over that don't seem to work. I could swear I remember this being mentioned here somewhere but I can't figure out where. Since there was also the recent issue with water reflection rendering that seems to be specific to a certain set of graphics cards I'm not totally sure if this is also a card-specific problem involving occlusion testing.

Anyone else have this problem, or was an alternative solution ever found?

Here are links to the code I referenced:
github.com/GarageGames/Torque3D/blob/development/Engine/source/environment/scatt...
github.com/GarageGames/Torque3D/blob/development/Engine/source/T3D/lightFlareDat...


#1
08/23/2014 (9:28 pm)
Ok, I just fired up the default Empty Terrain mission in stock T3D 3.5.1. For me, with the default ScatterSky settings, only LightFlareExample2 and SunFlarePacificIsland flare types produced a noticeable flare. I did not change any other settings - only the flareType.

GeForce GT 640

Can anyone else verify this? It might help pinpoint the issue.
#2
08/23/2014 (10:05 pm)
Not sure how I missed that. Yeah, LightFlareExample2 and SunPacificIsland flares work with no code changes... interesting. I guess I'll try to see if anything is unique with those two.

Forgot to mention I have a GTX 650 Ti.

Edit:

So, a quick interesting note:

I went back to try more stuff and was confused when it seemed like nothing worked. Then I realized none of the flares will render when the resolution is below 1152x864 with my changes. Fullscreen doesn't seem to matter.

LightFlareExample2 and SunPacificIsland flares work in vanilla T3D 3.5.1 at resolutions under 1152x864. All flares work with resolutions over 1152x864 with my code changes. I'll see f I can find a more solid connection between all this.
#3
08/23/2014 (10:59 pm)
Okay, it looks like I might have found the issue. In the light flare datablocks the following value is set for the flares that don't work.

occlusionRadius = "0.25";

Example: github.com/GarageGames/Torque3D/blob/development/Templates/Full/game/art/datablo...

Notably, LightFlareExample2 and SunPacificIsland do not have those values defined in script. Once that is commented out all flares seem to work at all resolutions. Which means this does appear to be an occlusion problem. So, I guess the next question is, is it specific to only certain cards?
#4
08/27/2014 (6:33 pm)
Went ahead and created an issue on GitHub: github.com/GarageGames/Torque3D/issues/764.

Was hoping more people would test this out to help determine if this problem occurs on different hardware. I'll continue looking into it to see if I can figure anything else out in the meantime.