# raylighting terrain article

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

## Recommended Posts

Ive been assigned to make a programming work at school and give it in as an article... i have been working on my own way to creat shadowmaps for terrain and have come up with a at in atleast my opinion good method ... i thought id ask you guys for suggestions on improvements on the article and/or the code... here is the link.. http://www.falconclan.org/Ray%20Lighting%20Article.doc any help will be apriciated...

##### Share on other sites
where did u get that wierd adress from.. lol

##### Share on other sites
Your article looks really good, and it's easy to understand (this being said without trying to implement it ... yet.) It's also just the kind of explaination I've been looking for. I'll drop it on my terrain engine tonight (it's really simple, doesn't look nearly as good as the one in your article) and see how it fairs.

##### Share on other sites
Hi Dragon,

your article looks good and the results look good, too!
I must stress that I am not a ray tracer nor did I write a very intersting myself, but I guess one other way to shade the terrain would be:

p := the surface point you want to shade
n := the normal of the surface at point p
r := ray form p to the light source
phi := the angle between r and p (calculated by phi = acos(dot(n, r)/|n|*|r|))

Now you calculate for every point you are interested in
the intensity the light is hitting the surface at point p
I(p) = cos(phi) = dot(n,r)/|n|*|r|

you get values -1 <= I(p) <= 1
I(p) = 1 if the normal is pointing directly towards the light source
I(p) = 0 if the normal is orthogonal to the ray pointing to the lighsource (no shadow, but no extra light energy)
I(p) = -1 if the normal points in the opposite direction (full shadow)

This results woun't result in smooth shadowing (because the normal is for every point in a plane the same), but you can go on like this:
scatter in random directions at point p, so light is reflected to other surface points, or maybe easier (but I don't know how it will look like)
use multiple light sources. The light sources should be near to eachother. for every surface point p you calculate the intensity for each light source and divide it by the number of sources to get the final intensity. Maybe that gives you smoother shadow borders.

This only one way to do it. And it will look approximately the same than your way. But I hope you find it interesting (because you get the possibility of scattering the light and such things :)

Bye,
Constantin

##### Share on other sites
K, I didn't understand some of the things in your paper, or didn't have easy access to some of the things I'd need data for, but I pushed the concept in and came up with the following nifty time lapse shots of my terrain engine doing some very basic shadow stuff.

Shot 1
Shot 2
Shot 3
Shot 4
Shot 5
Shot 6
Shot 7

##### Share on other sites
Hi Wudan,

is it possible that you calculated only the shading for the vertices and let OpenGL interpolate between them?
It looks a little bit like that because I can see the mesh geometry in the shadow. As far as I understood the article, he generated a lightmap which is a texture. This texture is used to texture the terrain mesh. If you do so you get a much better shadow resolution.

-- Constantin

##### Share on other sites
In my shots above I calculated the color per vertex, as I don't use lightmaps in my engine. It was a pretty quick implementation and it does not run anywhere near as smooth as it should.

##### Share on other sites
ive updated the article a bit.. the only differance is that ive added "shadowDepth" which makes the calculations the same at every height which wasnt the case before...

http://www.falconclan.org/RayLightingArticle1.doc

conman ur method seems good 2... ill try it...

##### Share on other sites
wudan what is that u dont understand?

##### Share on other sites
To be honest and fair, I'm a business student and haven't taken any engineering courses, computer science courses, or technical writing classes.

However, I don't feel that the initial part of the tutorial or the description of the tecnique are adequate.

I'll have some more time to post my particular questions later on tonight. I hope that you will find it beneficial.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634090
• Total Posts
3015434
×