Terrain shadows

Started by
18 comments, last by DanielH 21 years, 5 months ago
How do i get som shadows to my terrain? Its hard to see anything when everything have almost the same green color!
Advertisement
Just do some raytracing, after you build your height map, and store the result (shaded or not shaded) on each vertex. Then, when you render it, use a different color (maybe 0.5,0.5,0.5) to blend with the current texture.
How do i do "some raytracing"?

I dont even know what raytracing mean
you check if there is something between a point and another if so light is blocked if not it isn t blocked
http://www.8ung.at/basiror/theironcross.html
Ah, i thought of that before but then someone said that wasnt a good idea O_o

But how do i do it then?
For simplicity you could check the angle the terrain has at a given point and choose a light value. That won't do shadows but it looks quite good.
Btw the new Unreal Engine does Raytracing for terrain shadowing so it can't be that bad.

[edited by - noVum on November 8, 2002 5:50:16 PM]
noVum,
that sounds good. can u show some code how i get the angle of a point?
quote:Original post by DanielH
noVum,
that sounds good. can u show some code how i get the angle of a point?


for each vertex in your terrain map, go through all your terrain's triangles and find a surface normal for all the triangles that include that vertex. average the normals together and you get a normal for that vertex. if you use glNormal3f() as you draw out your terrain and then enable and setup glLighting, you'll end up with properly shaded terrain. that way, it'll be dynamically shaded as well, so you can light up the terrain with dynamic lights.

if you want your terrain just statically shaded, do similar calculations to get vertex normals for all the vertices of your map. then you'll want to make up some sort of vector at which the "sunlight" hits your world. compare the vertex normals to the sunlight vector and set a color value for each vertex based on the angle between the two. 180 - 90degrees = black -> pure white. 90 - 0 = black (i.e. normal is pointing away from the light). save that color array in some meaningful way and then do a blend with the shading color and the texture color to get the final shaded appearance of your terrain map.

look up "smallest angle between two vectors" on google to get the math for calculating the angle between the normal and sunlight vector.

look up "3D math tutorial" to learn what vectors are, how to use them, and how to find normal vectors from 3 points.

look up "openGL redbook" and read the chapter on lighting in openGL to see how it all works.

post more questions and i'll try to clarify what you need to learn. (a little busy today at work so i don't have a ton of time to make this post verbose)

-me

[edited by - Palidine on November 8, 2002 6:40:49 PM]

[edited by - Palidine on November 8, 2002 6:41:56 PM]
i only use lights for dynamic light the normal lightning in OGL is shitty
http://www.8ung.at/basiror/theironcross.html
quote:Original post by Raduprv
Just do some raytracing, after you build your height map, and store the result (shaded or not shaded) on each vertex. Then, when you render it, use a different color (maybe 0.5,0.5,0.5) to blend with the current texture.


Do you have some source code for this?

I am trying to get this working but for some reason my ray-poly colision detection isn''t working.
I''m not expiranced with 3D stuff, and I''m just using the collision detection tutorials from www.gametutorials.com. I don''t know if I using the collision detections functions wrong, or if they arn''t working.



Jason Mickela
ICQ : 873518
Excuse my speling.

Vallejo Punk
The V-Town Have-Nots
Eskapo

"I don''t have to take this, I''m going to where I''m appreciated, my mom''s house"
"The paths of glory lead but to the grave." - Thomas GrayMy Stupid BlogMy Online Photo Gallery

This topic is closed to new replies.

Advertisement