Lighting the Terrain

Falagard

02-06-2006 21:35:13

Tuan, questions about lighting the terrain dynamically.

My requirements are:
1. Works on older cards without vertex shader or pixel shader support
2. Some dynamic lights for things like street lights or campfires.
3. Supports day/night cycle (this one could simply mean supporting an ambient colour change - for example, lightmaps + ambient that changes throughout the day is reasonable)
4. The key factor is the terrain shouldn't look "flat" and have some shading, but it doesn't necessarily need to have the terrain cast shadows.

I've seen instant base texture, and I've also used the fixed function lighting when normals are turned on the terrain.

I need a solution that's going to work for older cards without vertex shader support, so I'm thinking of going with generating normals and having a version of the splatting shader that performs vertex lighting. I know that vertex lighting can look bad on terrain with LODs, but the fact is that I'm going to be having enough stuff in the view that the distant terrain probably won't even be visible very often.

The other possibility is lightmaps + some dynamic lighting. This one might even be the best solution.

Do you have any suggestions on the best way to do this? Another factor I guess is memory consumption, etc.

Clay

tuan kuranes

02-06-2006 21:45:11

I've seen instant base texture
Did you notice the Real-time CPU shadowing if no pixel shader ?
Generates lightmap real-time using shadow map.

-Combines that with fixed normal lighting for no vertex shader cards
-Combines that with vertex lighting for no pixel shader cards
-Could be even Combined that with per pixel- lighting for pixel shader cards (ps1.0)


The other possibility is lightmaps + some dynamic lighting. This one might even be the best solution.

Same but dynamic lightmap.

Falagard

03-06-2006 16:28:31

I'll look further into InstantBaseTexture then.

I kinda need a solution you can edit, like splatting shader, then run a process over to generate shadows. For instant base texture you need the zhorizon right?

tuan kuranes

05-06-2006 13:14:33

I'll look further into InstantBaseTexture then.
I kinda need a solution you can edit, like splatting shader, then run a process over to generate shadows. For instant base texture you need the zhorizon right?


In fact, since last refactoring every texturemode can access the lightmap update, just have to add it to material, fill base class lightbuffer and image.
Yes it uses the Zhorizon texture (and trick, as sun has to be on the Z axis.)

Falagard

06-06-2006 05:00:06

So, does this mean that I can edit the terrain and it recalculates the zhorizon as I deform the terrain?

And I'd have to add the shadow code to the splatting shader cg and create a new texture mode called splatting shader shadowed edit or something?

Falagard

06-06-2006 07:00:00

I'm probably going to add a lit version of the splatting shader that doesn't use the zhorizon shadowing for now. I don't understand the shader myself, since I'm not an expert, and the shader is giving undesired results for me. By that I mean that the shadowed parts of the terrain are very dark, plus there are blotches of very dark shadows all over the terrain. I ran the mapsplitter over the grand canyon map with zhorizon option and it ran for about 40 mins and now I have the grand canyon working with instant base texture shadowed, but like I said, some parts look good and some not so good. Plus I have my sun directions already set up for a 24 hour period and am not sure how to turn them into z values for this texture mode.

For splatting shader lit version, originally I was thinking of writing a shader that iterates per light, but now I'm thinking that I'll write a shader that supports a fixed number of lights on the terrain. For example, one directional light (sun) plus maybe 2 point lights.

Iterate per light would be nice because I could have a shader for point light, and shader for directional light, and it'd run with any number of lights. It'd be up to the game designer to ensure not too many lights are affecting the terrain at any time.

Unfortunately even for just the sun affecting the terrain, (one directional light) it would require 3 passes. Ambient, Directional Light, Splatting.

If I have a fixed number I can get that down to a single pass (I think).

Clay