Terrain & Static Not Lighting/Shading Equally
by DavidRM · in Torque Game Engine · 06/26/2006 (1:27 pm) · 14 replies
In this picture:

The same rock texture is used on both the DTS statics shapes (the rocks) and the cliff terrain. Yet the static is being lit/shaded about...25%-50%...darker than the terrain.
I have SG_LIGHTING_OVERBRIGHT_AMOUNT set to "1.0". That's the only TLK change I've got active.
If I set SG_LIGHTING_OVERBRIGHT_AMOUNT to "2.0" then portions of the rocks have the same color as the terrain. But only portions. The overbrightness kicks the shit out of the rest of the rock (though it renders the terrain the same).
Any hints? Tips?
Thanks!
-David

The same rock texture is used on both the DTS statics shapes (the rocks) and the cliff terrain. Yet the static is being lit/shaded about...25%-50%...darker than the terrain.
I have SG_LIGHTING_OVERBRIGHT_AMOUNT set to "1.0". That's the only TLK change I've got active.
If I set SG_LIGHTING_OVERBRIGHT_AMOUNT to "2.0" then portions of the rocks have the same color as the terrain. But only portions. The overbrightness kicks the shit out of the rest of the rock (though it renders the terrain the same).
Any hints? Tips?
Thanks!
-David
#2
The result is slightly different (better, I think, but still showing the same overall issue):

Am I chasing an impossible dream, here? Is the lighting on the terrain calculated so different that simply using the same texture on the terrain and a DTS will never match? DIF's seem to offer a 3rd possible way to render the same texture:

Should I just tell the artist he's gonna have to have to have 3 different textures, one for each use? Or is there something I'm missing?
Thanks.
-David
06/27/2006 (10:54 am)
OK...I played with turning off the terrain overbright. Mostly I decided I liked the bright terrain, so I put that back, and then figured out a simple way to keep the cel shaded DTS objects from being "overexposed" (using SG_LIGHTING_NORMAL) while letting the rest of the DTS objects (like the rocks) continue to use SG_LIGHTING_OVERBRIGHT_AMOUNT (set to the default "2.0"). I also got the "scaled DTS" fix in place.The result is slightly different (better, I think, but still showing the same overall issue):

Am I chasing an impossible dream, here? Is the lighting on the terrain calculated so different that simply using the same texture on the terrain and a DTS will never match? DIF's seem to offer a 3rd possible way to render the same texture:

Should I just tell the artist he's gonna have to have to have 3 different textures, one for each use? Or is there something I'm missing?
Thanks.
-David
#3
In your mission there is a lot of shading on the terrain, making it hard to tell if things are similarly lit.
Here's the best way to setup a test mission; create a flat terrain using one solid texture, add an interior with a flat top using the same texture (make sure the surface is parallel to the terrain), and add in your dts objects.
At this point the terrain and interior should look very similar. It won't be perfect, the terrain uses cpu blending and 16 bit textures which causes color distortion, but it should be close.
The dts is probably looking dark, because by default its lighting is set to light map lighting ('LM Lighting'), which pulls the lighting from directly beneath the object (which is in its shadow). Changing this to use the sunlight will resolve the lighting issue and make the object look very similar to the terrain and interior. Dts objects use vertex lighting so the shading can appear odd at time, but most of the time people cannot tell the difference.
06/27/2006 (1:08 pm)
The lighting should look the same (or very similar) across all objects.In your mission there is a lot of shading on the terrain, making it hard to tell if things are similarly lit.
Here's the best way to setup a test mission; create a flat terrain using one solid texture, add an interior with a flat top using the same texture (make sure the surface is parallel to the terrain), and add in your dts objects.
At this point the terrain and interior should look very similar. It won't be perfect, the terrain uses cpu blending and 16 bit textures which causes color distortion, but it should be close.
The dts is probably looking dark, because by default its lighting is set to light map lighting ('LM Lighting'), which pulls the lighting from directly beneath the object (which is in its shadow). Changing this to use the sunlight will resolve the lighting issue and make the object look very similar to the terrain and interior. Dts objects use vertex lighting so the shading can appear odd at time, but most of the time people cannot tell the difference.
#4
I'm the artist helping David with this level. I haven't had a chance to do the test you describe (with the flat objects), but I did try another DTS test. I took the heightmap from the level and used it to create a DTS that almost exactly matches the terrain. Then I brought it into the level:

You can see some identical hills; the ones on the right are DTS geometry, and are a bit darker.
From what you said above, I figured the DTS is darker because receiveLMLighting was checked, and the DTS was picking up some shadow from the terrain's lightmap. I went into the DTS object and unchecked receiveLMLighting, but I didn't see any change at all. I re-lit the scene, and there was no change. I hit "apply", selected and unselected the DTS, and generally did all the voodoo it sometimes takes to get a change to stick when using the mission editor, but still nothing. I re-lit again, nothing. I even opened the level in a text editor to make sure the value was set to "0" (it was).
To check if the DTS was sampling light mapping, I moved the object around a bit, but locating it over a shadow produced no different results, regardless of whether I had receiveLMLighting checked or not.
Should I see something happen as soon as I uncheck "receiveLMLighting"?
Should I see the lighting change if I move the DTS object around?
What part of the DTS object samples the lightmap - is it the pivot, or some average of all the lightmap under the extents of the DTS?
Am I simply seeing, in the image above, the expected difference between baked vertex lighting and baked lightmap lighting?
Thanks for the help!
-Spencer
06/27/2006 (6:12 pm)
Hi John, I'm the artist helping David with this level. I haven't had a chance to do the test you describe (with the flat objects), but I did try another DTS test. I took the heightmap from the level and used it to create a DTS that almost exactly matches the terrain. Then I brought it into the level:

You can see some identical hills; the ones on the right are DTS geometry, and are a bit darker.
From what you said above, I figured the DTS is darker because receiveLMLighting was checked, and the DTS was picking up some shadow from the terrain's lightmap. I went into the DTS object and unchecked receiveLMLighting, but I didn't see any change at all. I re-lit the scene, and there was no change. I hit "apply", selected and unselected the DTS, and generally did all the voodoo it sometimes takes to get a change to stick when using the mission editor, but still nothing. I re-lit again, nothing. I even opened the level in a text editor to make sure the value was set to "0" (it was).
To check if the DTS was sampling light mapping, I moved the object around a bit, but locating it over a shadow produced no different results, regardless of whether I had receiveLMLighting checked or not.
Should I see something happen as soon as I uncheck "receiveLMLighting"?
Should I see the lighting change if I move the DTS object around?
What part of the DTS object samples the lightmap - is it the pivot, or some average of all the lightmap under the extents of the DTS?
Am I simply seeing, in the image above, the expected difference between baked vertex lighting and baked lightmap lighting?
Thanks for the help!
-Spencer
#5
When turning off all of the lighting options the dts should become completely black. There are two things I can think of off hand that would cause what you're seeing; the object is rather large and its center may be bellow the terrain (the LM Lighting works by casting a ray down from the object's center axis gizmo) if you raise the object so its center is above the terrain you should be able to get some change when toggling the LM Lighting, or that the code integration isn't complete, even with the object center bellow the terrain the other options should work (especially the Sunlight option which is what you would want in this case).
If you guys are still having trouble try using a fresh TLK exe, and if that doesn't work send your test mod to me and I'll see if I can identify whats happening.
06/28/2006 (11:19 am)
Hi Spencer,When turning off all of the lighting options the dts should become completely black. There are two things I can think of off hand that would cause what you're seeing; the object is rather large and its center may be bellow the terrain (the LM Lighting works by casting a ray down from the object's center axis gizmo) if you raise the object so its center is above the terrain you should be able to get some change when toggling the LM Lighting, or that the code integration isn't complete, even with the object center bellow the terrain the other options should work (especially the Sunlight option which is what you would want in this case).
If you guys are still having trouble try using a fresh TLK exe, and if that doesn't work send your test mod to me and I'll see if I can identify whats happening.
#6
06/28/2006 (11:29 am)
I've been experiencing similar problems. For the moment I'm just adjusting my textures accordingly (brightness) but I don't like doing this as I'm loosing texture quality.
#7
I have always been taught to place the origin (I assume we are talking about the same thing) at the point on the object I want the object to meet the ground. This is most useful for snap too options and things like the replicators in TGE.
Please correct me if I am misunderstanding you here John
This would explain a few of the issues I am still having.
06/28/2006 (12:19 pm)
Good info about the objects "center".I have always been taught to place the origin (I assume we are talking about the same thing) at the point on the object I want the object to meet the ground. This is most useful for snap too options and things like the replicators in TGE.
Please correct me if I am misunderstanding you here John
This would explain a few of the issues I am still having.
#8
I've seen a problem similar to the one you describe, with the lighting changing when the object's center dips below the terrain, but that was only in vanilla Torque. In the TLK I haven't noticed that (and that's a good thing, IMO :). I did try raising that hillside DTS, and it didn't make a difference.
Playing with the settings just now, it seems as if turning on receiveSunLight negates anything I might do to the receiveLMLighting setting. Is that correct? And that hillside DTS had receiveSunLight on the whole time.
So it seems that, if I have receiveSunLight on, it's only using (in the case of this hillside DTS) the sun and the sun's ambient color for illumination. If I want to use receiveLMLighting, I have to turn *off* receiveSunLight. (And then the DTS is illuminated by the LM color only, a solid, rather dark, non-directional illumination). Is that all correct?
See, what I was originally thinking was that the LM might be injecting a little darkness into the DTS's illumination. But if what I said in the previous paragraphs is correct, then the terrain is illuminated by the sun and the sun's ambient *only*, the DTS is illuminated by the sun and sun's ambient *only*, but the DTS comes out a little darker anyway.
Perhaps it's the difference between baking lighting to verts vs baking to a texture?
06/28/2006 (2:37 pm)
Hi John, I've seen a problem similar to the one you describe, with the lighting changing when the object's center dips below the terrain, but that was only in vanilla Torque. In the TLK I haven't noticed that (and that's a good thing, IMO :). I did try raising that hillside DTS, and it didn't make a difference.
Playing with the settings just now, it seems as if turning on receiveSunLight negates anything I might do to the receiveLMLighting setting. Is that correct? And that hillside DTS had receiveSunLight on the whole time.
So it seems that, if I have receiveSunLight on, it's only using (in the case of this hillside DTS) the sun and the sun's ambient color for illumination. If I want to use receiveLMLighting, I have to turn *off* receiveSunLight. (And then the DTS is illuminated by the LM color only, a solid, rather dark, non-directional illumination). Is that all correct?
See, what I was originally thinking was that the LM might be injecting a little darkness into the DTS's illumination. But if what I said in the previous paragraphs is correct, then the terrain is illuminated by the sun and the sun's ambient *only*, the DTS is illuminated by the sun and sun's ambient *only*, but the DTS comes out a little darker anyway.
Perhaps it's the difference between baking lighting to verts vs baking to a texture?
#9
I took these 2 shots today. The first is from our own project's EXE:

Here's a shot from the same mission using the EXE that comes with the TLK (in synapseGaming_lightingPack-1.4.0.zip):

The rock DTS is no longer scaled (it's shown actual size), and receiveMLLighting was turned off.
If we can get closer, we'd love it. But, for now, we're basically resigned to just living with it (and adjusting artwork as needed).
-David
06/28/2006 (2:57 pm)
John,I took these 2 shots today. The first is from our own project's EXE:

Here's a shot from the same mission using the EXE that comes with the TLK (in synapseGaming_lightingPack-1.4.0.zip):

The rock DTS is no longer scaled (it's shown actual size), and receiveMLLighting was turned off.
If we can get closer, we'd love it. But, for now, we're basically resigned to just living with it (and adjusting artwork as needed).
-David
#10
Hi David, if you can send over the test mission I'll take a look at it and see what's going on. The dts lighting should look a lot closer to the light maps than that.
06/28/2006 (4:12 pm)
Hi Spencer, thats correct, based on your description it sounds like the lighting options are working 100%.Hi David, if you can send over the test mission I'll take a look at it and see what's going on. The dts lighting should look a lot closer to the light maps than that.
#11
06/29/2006 (3:17 pm)
Hi David, I got your email and I'll take a look at the test mission very soon.
#12
To verify I flattened the terrain, set the texture to the rock texture, and then placed the rock's flattest face parallel to the terrain surface and they looks nearly identical (the rock's lighting was set to use only the sunlight). Any variation in the color looks like it's due to the terrain's lower texture quality, which causes a slight discoloration.
I tried putting your sun light values back into the scene and did notice a slight difference in the lighting intensity, though it didn't seem as pronounced as the images above. You can stop this problem by changing the following line of code (though I'm not sure how this will affect non-TSShape dts objects):
In sgLightingModel.cc line 326:
change to:
Let me know if that helps,
-John
07/06/2006 (11:58 am)
Ok, I loaded up your test level and checked it out. At first I noticed that the dts objects were darker, but this was due to the scaling. As a test I removed the scaling and the objects looked very good.To verify I flattened the terrain, set the texture to the rock texture, and then placed the rock's flattest face parallel to the terrain surface and they looks nearly identical (the rock's lighting was set to use only the sunlight). Any variation in the color looks like it's due to the terrain's lower texture quality, which causes a slight discoloration.
I tried putting your sun light values back into the scene and did notice a slight difference in the lighting intensity, though it didn't seem as pronounced as the images above. You can stop this problem by changing the following line of code (though I'm not sure how this will affect non-TSShape dts objects):
In sgLightingModel.cc line 326:
F32 factor; LightManager *lm = gClientSceneGraph->getLightManager(); if(lm && lm->getVectorLightsEnabled()) factor = mClampF(lm->getVectorLightsAttenuation() - ambientFactor, 0.f, 1.f); else factor = mClampF(1.0f - ambientFactor, 0.f, 1.f);
change to:
F32 factor; LightManager *lm = gClientSceneGraph->getLightManager(); if(lm && lm->getVectorLightsEnabled()) [b]factor = 1.0;[/b] else factor = mClampF(1.0f - ambientFactor, 0.f, 1.f);
Let me know if that helps,
-John
#13
I implemented that fix. There is a noticeable difference (a good one). If this is as close as we can get, it seems workable.
Thanks.
-David
07/06/2006 (1:27 pm)
John,I implemented that fix. There is a noticeable difference (a good one). If this is as close as we can get, it seems workable.
Thanks.
-David

Torque Owner John Kabus (BobTheCBuilder)
Did you remove the TLK changes from the assembly terrain blender, or switch to the C++ blender? If not the terrain will be brighter than all other objects. Also are you scaling those dts objects? That can also cause lighting changes in Torque (see this thread for a fix).