Jump to content
  • Advertisement
Sign in to follow this  
OrangyTang

Improving terrain lighting (pics!)

This topic is 5412 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

You probably don't remember my earlier ponderings over terrain lighting, but I just recently tried an improvised form of horizon mapping and have very nice results for shadowing. :) Now I'm wondering what other factors people think is important for outdoor-style rendering. I know how people love pics to accompany peoples testing, so: Not very detailed as terrain goes I know, but this horizon mapping lets me move the light source along a pre-defined arc which is perfect for a sun. So far its just regular per-pixel diffuse * shadow intensity. Obviously the first improvement that springs to mind is some form of specular, but I think that might be unsuitable for 'soft' surfaces (grass, sand) that you typically find in such a scene. Having said that, perhaps rock or snow type surfaces would benifit from good specular, maybe some form of gloss map in my diffuse textures' (currently unused) alpha component. Suggestions muchly appreciated. :)

Share this post


Link to post
Share on other sites
Advertisement
the shadows almost seem too dark to me. They almost look like cloud cover shadows. Unless the light is farily close the horizon ... they just seem darker then they should be.


The blending is nice though and the edges look smooth. How does it look as you move the light?

Share this post


Link to post
Share on other sites
Yeah, I've added ambient light to the fragment shader now which stops it looking pitch black in the shadows. At the moment all my lighting is just a single (white) colour, I'm thinking that it should vary depending on the angle of the sun, such as shifting the ambient towards blue at nighttime.

Moving the light source is where it really starts to look good, you can watch the shadows from the hills slowly form and stretch as the sun gets lower. [grin]

Share this post


Link to post
Share on other sites
Basically a big texture (same resolution as the vertex data) stored horizon angles at each terrain tile (in a texture's r channel, the rest are unused). Unlike regular horizon mapping I only store the horizon in one direction, which means theres not much memory cost.

A fragment shader looks up the (interpolated) horizon angle, then compares it with the global sun angle. If the sun is below the horizon then we're in shadow, else we're being lit. Chuck in a smoothstep useage for a little softness rather than a harsh on/off. By switching between an texture for east horizons and a texture for west horizons you can make the sun travel in a complete arc over the landscape. After the initial precalculating of the horizon values you can move the sun anywhere on this arc and you just let the fragment shader work out the light intensity.

Share this post


Link to post
Share on other sites
now you make me think about wild methods like storing a texture with values like
r: time of begin shadowing
g: time of max shadowing
b: time of end shadowing
a: darkness of shadowing

where you just do shadowing depending on daytime and maybe abuse value clamping to further your goals and replace if instructions. hmmm.. nah, sounds like too much work just for shadows.

Share this post


Link to post
Share on other sites
Quote:
Original post by Trienco
now you make me think about wild methods like storing a texture with values like
r: time of begin shadowing
g: time of max shadowing
b: time of end shadowing
a: darkness of shadowing

where you just do shadowing depending on daytime and maybe abuse value clamping to further your goals and replace if instructions. hmmm.. nah, sounds like too much work just for shadows.
I think, ideally, you'd want any such technique to only use three values, instead of four - allowing you to pack into into an ARGB texture along with the heightmap value at that point.

Share this post


Link to post
Share on other sites
considering that there really is no limit to the amount of times a vertex can pop in and out of shadow, a more flexible datastructure might be more suitable. and probably a lot less efficient.

Share this post


Link to post
Share on other sites
OrangyTang, can you try doing the terrain lighting using per-vertex lighting and using your form of horizon mapping and post the FPS results? I wonder - I use per-vertex lighting on my terrain. Because usally terrains are well-tesselated, it looks good as well. Your method looks better, true, however per-vertex lighting on the terrain also create soft shadows. I wonder if horizon mapping is a lot faster(or slower) than per-vertex lighting on the same terrain.

- Etus

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
In general pixel lighting is ofthen the best choice for terrains.

This does not mean that vertex lighting cant be used for anything, but with most LOD schemes it has the disadvantage that vertex lighting significantly increases the visibility of LOD changes. For instance approaching a mountainside with pixellighting you could maintaing a wery rought tesselation for a long time because the actual geometry is not visible, only the shadows, if it was vertex lit these would change a lot when the tesselation was changed.

The horizonmap lighting looks good, but to see it in full effect you would really need an animation ;)
There is a paper written on terrain lighting a while ago, which included some really cool effects including interreflections from surrounding terrain. That would be really cool.

In adition I think that outdoor scenes benefit enourmously from high dynamic range lighting and areal perspective.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!