Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DanielH

Terrain shadows

This topic is 5730 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

How do i get som shadows to my terrain? Its hard to see anything when everything have almost the same green color!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
you check if there is something between a point and another if so light is blocked if not it isn t blocked

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!