Game Development Community

Bad Dynamic Lighting

by Jeff Faust · in Torque Game Engine Advanced · 07/18/2007 (8:09 pm) · 8 replies

I'm getting bad dynamic lighting on objects using a basic shader.

www.arcane-fx.com/visuals/forums_pics/bad_orc_lighting.jpg
In these pics, there is a dynamic sgLightObject light near the orc's feet. Image on the left is in TGEA. It behaves much like an ambient light with no shading. Image on the right is in TGE with a similar lighting situation and it shows a result that is closer to expectations.

I have been customizing some material and shader code, so to rule out causing the problem myself, I ran the test using the stock TGEA 1.01 executable and a migrated version of starter.fps.

Anyone know what's happening here?

The Orc Material:
new Material(player_tex)
{
   baseTex[0] = "player";
 };
The Light Datablock:
datablock sgLightObjectData(myRedTestLight_DB) {
   canSaveDynamicFields = "1";
   className = "sgLightObjectData";
   LightOn = "1";
   Radius = "5";
   Brightness = "1";
   Colour = "1 0 0 1";
   FlareOn = "0";
   FlareTP = "1";
   FlareColour = "1 1 1 1";
   ConstantSizeOn = "0";
   ConstantSize = "3";
   NearSize = "3";
   FarSize = "0.5";
   NearDistance = "10";
   FarDistance = "30";
   FadeTime = "0.1";
   BlendMode = "0";
   AnimColour = "0";
   AnimBrightness = "0";
   AnimRadius = "0";
   AnimOffsets = "0";
   AnimRotation = "0";
   LinkFlare = "1";
   LinkFlareSize = "0";
   MinColour = "0 0 0 1";
   MaxColour = "1 0 0 1";
   MinBrightness = "0";
   MaxBrightness = "1";
   MinRadius = "0.1";
   MaxRadius = "5";
   StartOffset = "-5 0 0";
   EndOffset = "5 0 0";
   MinRotation = "0";
   MaxRotation = "359";
   SingleColourKeys = "1";
   RedKeys = "AZA";
   GreenKeys = "AZA";
   BlueKeys = "AZA";
   BrightnessKeys = "AZA";
   RadiusKeys = "AZA";
   OffsetKeys = "AZA";
   RotationKeys = "AZA";
   ColourTime = "5";
   BrightnessTime = "5";
   RadiusTime = "5";
   OffsetTime = "5";
   RotationTime = "5";
   LerpColour = "1";
   LerpBrightness = "1";
   LerpRadius = "1";
   LerpOffset = "1";
   LerpRotation = "1";
   StaticLight = "0";
   SpotLight = "0";
   SpotAngle = "1";
   AdvancedLightingModel = "1";
   EffectsDTSObjects = "1";
   CastsShadows = "0";
   DiffuseRestrictZone = "0";
   AmbientRestrictZone = "0";
   LocalAmbientAmount = "0";
   SmoothSpotLight = "0";
   DoubleSidedAmbient = "0";
   LightingModelName = "SG - Original Advanced (Lighting Pack)";
   UseNormals = "0";
   SupportedFeatures = "Full";
   MountPoint = "0";
   MountPosition = "0 0 0";
   MountRotation = "1 0 0 0";
};
The Light:
new sgLightObject(myRedTestLight) {
      canSaveDynamicFields = "1";
      position = "494.029 -121.04 256.428";
      rotation = "1 0 0 0";
      scale = "1 1 1";
      dataBlock = "myRedTestLight_DB";
      Enable = "1";
      IconSize = "1";
      ParticleColorAttenuation = "1";
   };

About the author

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


#1
07/19/2007 (8:49 am)
Followup:

I've found that with a bumpTex added to the material, even if it's not well matched to the model, the lighting produced is much closer to expectations.

Still, it seems like we should get good lighting on the basic material, too. Am I wrong?
#2
07/19/2007 (9:08 am)
Good catch Jeff. It could be that the TGEA lighting system is really "optimized" to look for that Normal Map in order to attenuate itself. Perhaps a tweak could be done to the lighting code if it detects there is no Normal Map to switch to some sort of "fallback" roll-off?
#3
07/19/2007 (9:16 am)
Material based materials (as opposed to CustomMaterials) make use of the procedurally generated shaders. Adding in a bumpTex will cause a different procedural shader to be used, so this probably means that the procedural shader generated for the base material isn't doing the lighting right.
#4
07/19/2007 (9:43 am)
@Jeff - It is possible that the procedural shader gen is buggy in some cases. I fixed some alpha bugs just the other day.
#5
07/19/2007 (10:02 am)
@ Tom -- Yeah, no kidding. I saw your post on the alpha problems.

I need to move forward on redoing the lighting on all the existing AFX effects so that they look good in TGEA (there are big differences from TGE), but I can't really do that while we're still fixing bugs in the way the simplest dynamic light shines on the simplest material. It's too much work to do more than once so I'm trying to sense when the lighting is stable enough. I'm not sensing it yet.
#6
07/19/2007 (10:54 am)
Cue: John Kabus!

"Hi guys, I fixed it. Just do this and that..."
#7
07/26/2007 (12:34 pm)
Hey guys, I checked in fixes for this - the changes are widespread and not easy to post, but it's fixed in the repo.
#8
07/26/2007 (1:21 pm)
Do you think it will get included in the 1.02 release?

PS You really kick butt (in a good way) John!