Terrain Lighting
by Guimo · in Torque Game Engine · 04/06/2007 (8:09 pm) · 7 replies
Hi,
I need the terrain light to be completely independent of the other scene objects. That is, I want the terrain to be rendered as with a white ambient light RGB:(1,1,1) while the other scene objects (static or not) will use a low ambient light RGB:(0.1, 0.1, 0.1) and a point light. The idea is that the terrain renders using the full texture colors.
I have tried different approaches but they just wont work so I'm trying to alter the terrain rendering code. I guess that somewhere the terrain tris are rendered by multiplying the light color at the point by the terrain normal and texture color. I would like to alter this so instead using the lightcolor x normal I use a white color. I'm searching this code everywhere but found nothing.
Please if someone may point me how to do this I'd be really thankful.
Luck!
Guimo
I need the terrain light to be completely independent of the other scene objects. That is, I want the terrain to be rendered as with a white ambient light RGB:(1,1,1) while the other scene objects (static or not) will use a low ambient light RGB:(0.1, 0.1, 0.1) and a point light. The idea is that the terrain renders using the full texture colors.
I have tried different approaches but they just wont work so I'm trying to alter the terrain rendering code. I guess that somewhere the terrain tris are rendered by multiplying the light color at the point by the terrain normal and texture color. I would like to alter this so instead using the lightcolor x normal I use a white color. I'm searching this code everywhere but found nothing.
Please if someone may point me how to do this I'd be really thankful.
Luck!
Guimo
About the author
#2
04/09/2007 (8:46 pm)
Are you looking to disable shadows on the terrain as well or just the colored lighting information?
#3
...
setTexture(terrainTexture)
setColor(1,1,1,1)
setRenderMode(BLEND)
RenderTriangles
....
That is... I want to modify the final rendering coditions. I guess that would be easier than trying to modify all the terrain rendering. Unfortunately I have tried to debug the terrain rendering code but found nothing on this. If you may throw a light here please do so.
Luck!
Guimo
04/16/2007 (12:06 pm)
Im looking to set the light color to (1,1,1,1). That is... instead of rendering the terrain patches using the light/shadow information, I want to set the light color to white so everything is rendered with full color. I guess that engine modification may take a while so I was thinking about changing the render commands like:...
setTexture(terrainTexture)
setColor(1,1,1,1)
setRenderMode(BLEND)
RenderTriangles
....
That is... I want to modify the final rendering coditions. I guess that would be easier than trying to modify all the terrain rendering. Unfortunately I have tried to debug the terrain rendering code but found nothing on this. If you may throw a light here please do so.
Luck!
Guimo
#4
In sgSceneLightingTerrain.cc, find the sgProcessLightMap function and change:
Also, to save some time during relight, comment out the code in SceneLighting::TerrainProxy::light to prevent useless lighting calculations. Let me know if this works and if you need anymore help.
04/19/2007 (7:19 pm)
Sorry for the delay, but here's a solution that should suit your needs.In sgSceneLightingTerrain.cc, find the sgProcessLightMap function and change:
color.red = mLightmap[i].red + sgBakedLightmap[i].red; color.green = mLightmap[i].green + sgBakedLightmap[i].green; color.blue = mLightmap[i].blue + sgBakedLightmap[i].blue;To:
color.red = 255; color.green = 255; color.blue = 255;This way it forces the lightmap to fullbright during a relight.
Also, to save some time during relight, comment out the code in SceneLighting::TerrainProxy::light to prevent useless lighting calculations. Let me know if this works and if you need anymore help.
#5
04/19/2007 (9:53 pm)
Thanks! I'll try this!
#6
I have a secondary solution now but not really convincing. I really need this for my game.
Luck!
Guimo
P.S. I have notices that when I remove the terrain everything is rendered using an ambient light only. Maybe its related.
04/19/2007 (10:15 pm)
Nope... that didnt work. It lloks like any object placed over the terrain uses the lightmap info. So all the items, vehicles and staticshapes are now rendered with no shading (just a dull white). Looks like the lightmap must be computed, but I dont want to use the lightmap info when rendering the terrain.I have a secondary solution now but not really convincing. I really need this for my game.
Luck!
Guimo
P.S. I have notices that when I remove the terrain everything is rendered using an ambient light only. Maybe its related.
#7
Change that to false and it should solve your problems.
05/16/2007 (11:57 am)
You can override the receiveLMLighting property for all of your objects to force them to use whatever ambient color they so choose, which is usually the sun's. If you go to sceneObject.cc and look into SceneObject's constructor, you will see:receiveLMLighting = true;
Change that to false and it should solve your problems.
Torque Owner Stephen Lujan