Using a USL for sunlight
by Robert Nall · in · 04/28/2005 (12:24 pm) · 13 replies
My basic problem is that my player model is still getting lit when in it's in a shadowed area.
I'm currently trying to use a USL with a very large radius as a "parallel" light in my scene instead of TGE's built-in Sun. My Sun color is set to 0 0 0 and I've increased it's ambient a bit so I don't have pure black shadows.
Everything looks great except that now, when the player walks under a bridge (interior object), the shaded areas of the player model get darker, but the lit areas stay lit, giving the player an interesting effect not unlike having an invisible light bulb floating over it and constantly lighting it.
Is this problem because my USL is set to EffectsDTSObjects=true? If so, then is my best option to set it to not and then link every TSStatic in my environment to my USL sun? Or is there another option that might save my modellers the extra work?
Thanks,
-Rob
[edit: a few grammer corrections]
I'm currently trying to use a USL with a very large radius as a "parallel" light in my scene instead of TGE's built-in Sun. My Sun color is set to 0 0 0 and I've increased it's ambient a bit so I don't have pure black shadows.
Everything looks great except that now, when the player walks under a bridge (interior object), the shaded areas of the player model get darker, but the lit areas stay lit, giving the player an interesting effect not unlike having an invisible light bulb floating over it and constantly lighting it.
Is this problem because my USL is set to EffectsDTSObjects=true? If so, then is my best option to set it to not and then link every TSStatic in my environment to my USL sun? Or is there another option that might save my modellers the extra work?
Thanks,
-Rob
[edit: a few grammer corrections]
#2
I was experimenting with a USL sun because it seems to give better lighting results than the sun. I had a lot of flat dts objects with collision that were casting shadows then lighting themselves based on those shadows and I didn't know how to get a static light to light my dts objects without spilling more light on the terrain. Also, I think the lighting on the DTS objects, including the player, look better under USL lights. Is there actually a difference in the way the sun renders light and a USL renders light? Or am I just imaging things?
-Rob
04/28/2005 (1:35 pm)
Oh, nice. That might be useful.I was experimenting with a USL sun because it seems to give better lighting results than the sun. I had a lot of flat dts objects with collision that were casting shadows then lighting themselves based on those shadows and I didn't know how to get a static light to light my dts objects without spilling more light on the terrain. Also, I think the lighting on the DTS objects, including the player, look better under USL lights. Is there actually a difference in the way the sun renders light and a USL renders light? Or am I just imaging things?
-Rob
#3
Basically this option is great for bright sun lit exteriors, darker exteriors illuminated with Lighting Pack lights should avoid it - interior lighting is unaffected by the option.
04/28/2005 (1:45 pm)
Try setting the pref option '$pref::OpenGL::sgDynamicDTSVectorLighting' to true (you can set this in the console - it will save on exit), this enables a more natural directional lighting, but it can cause Lighting Pack lights to look a little less accurate.Basically this option is great for bright sun lit exteriors, darker exteriors illuminated with Lighting Pack lights should avoid it - interior lighting is unaffected by the option.
#4
Going back to the sun light I did notice that there is definately a difference in the shading of the player model. The USL only lights the polys that face it whereas the sun just lights the entire object based on the lightmap it's standing on. What would be great would be to have the USL shading, but have interior and TSStatic shadows effect the object as well. Is that possible?
Thanks for the quick responses,
-Rob
04/28/2005 (2:05 pm)
I tried the dynamicDTSVectorLighting global, and I have to admit I didn't notice any difference. Should the sun be lighting DTS objects when the object has receiveLMLighting set to true and the above gloabl set to true as well? Or is there a way I can turn off the shadows cast by the collision meshes of particular DTS objects? I noticed there is a castShadows variable, but I can't see that it actually does anything.Going back to the sun light I did notice that there is definately a difference in the shading of the player model. The USL only lights the polys that face it whereas the sun just lights the entire object based on the lightmap it's standing on. What would be great would be to have the USL shading, but have interior and TSStatic shadows effect the object as well. Is that possible?
Thanks for the quick responses,
-Rob
#5
The extended options used on static DTS objects override this pref option, but you'll notice a big difference on the player (and all other dynamic shapebase objects). The sun will illuminate only the surfaces of the object facing the sun and only on the terrain, on and in interiors the lighting looks the same.
The field 'castShadows' is an old lighting option, which, although I've tried to remove all references to it, keeps popping up in the mission editor. :)
"What would be great would be to have the USL shading, but have interior and TSStatic shadows effect the object as well. Is that possible?"
Yes, with sgDynamicDTSVectorLighting on, the lighting looks the same as USL lighting and the terrain, interior, and TSStatic shadows affect the object.
04/28/2005 (2:20 pm)
You may need to exit out of Torque and jump back in for the change to take effect. If it still looks the same do an 'echo($pref::OpenGL::sgDynamicDTSVectorLighting );' to make sure you get a '1' or 'true' back.The extended options used on static DTS objects override this pref option, but you'll notice a big difference on the player (and all other dynamic shapebase objects). The sun will illuminate only the surfaces of the object facing the sun and only on the terrain, on and in interiors the lighting looks the same.
The field 'castShadows' is an old lighting option, which, although I've tried to remove all references to it, keeps popping up in the mission editor. :)
"What would be great would be to have the USL shading, but have interior and TSStatic shadows effect the object as well. Is that possible?"
Yes, with sgDynamicDTSVectorLighting on, the lighting looks the same as USL lighting and the terrain, interior, and TSStatic shadows affect the object.
#6
Sun lit:

and USL lit:


Are there other options that would effect the dynamic DTS vector lighting that I might need to change?
And while we're talking about shadows and such, do you know if there is any control over the darkness of the player shadow?
[edit: typo - plus images were huge, so I shrunk them a little]
04/28/2005 (2:46 pm)
Yeah, I actually set the pref in my defaults before starting it up, but still no difference. I'm gonna post a few screens to show what I'm getting:Sun lit:

and USL lit:


Are there other options that would effect the dynamic DTS vector lighting that I might need to change?
And while we're talking about shadows and such, do you know if there is any control over the darkness of the player shadow?
[edit: typo - plus images were huge, so I shrunk them a little]
#7
There are two pref files (common and your mod directory) sometimes the changes don't take.
04/28/2005 (2:51 pm)
Did you check in the console with 'echo($pref::OpenGL::sgDynamicDTSVectorLighting );'?There are two pref files (common and your mod directory) sometimes the changes don't take.
#8
04/28/2005 (2:54 pm)
I did, and I got "1."
#9
04/28/2005 (3:25 pm)
What are the settings on your TGE sun (the color and ambient levels)?
#10
04/28/2005 (3:31 pm)
For that sun-lit mission the settings are as follows:new Sun() {
azimuth = "245";
elevation = "80";
color = "0.600000 0.600000 0.500000 1.000000";
ambient = "0.150000 0.150000 0.150000 1.000000";
scale = "1 1 1";
locked = "true";
position = "0 0 0";
direction = "0 0 0";
rotation = "1 0 0 0";
};
#11
I think we need to head over to the private forum and step through some code.
04/28/2005 (3:34 pm)
Is this a stock Lighting Pack or did you merge it into your project? Oh, and what version are you using?I think we need to head over to the private forum and step through some code.
#12
www.garagegames.com/mg/forums/result.thread.php?qt=29517
[edit: clarification]
04/28/2005 (3:51 pm)
Continued here (private forum):www.garagegames.com/mg/forums/result.thread.php?qt=29517
[edit: clarification]
#13
04/28/2005 (3:56 pm)
Cool, I'm on my way. :)
Torque Owner John Kabus (BobTheCBuilder)
Just out of curiosity why aren't you using the sun?
If all of your missions use this setup and the main (sun) light is always named the same, then you can edit 'common/editor/EditorGui.cs' at line 1311 to look like this:
function TSStatic::create(%shapeName) { %obj = new TSStatic() { shapeName = %shapeName; [b]lightGroupName = "<your sun object name>";[/b] }; return(%obj); }This will add the sun light object to every TSStatic created.
Let me know if this helps!
-John