Skip to main content
gamedev.net
🔒 Locked

Terrain Lighting?

Started by JSCFaith Jul 25, 2002 at 4:02 PM 5 replies 1.1k views
Original Post
JSCFaith
JSCFaith
What would be the best way to do shadows in a terrain engine? I have tried using Directx lighting, but that didn''t cut it.. I wrote a simple vertex lighting thing, but my shadows look blocky. Is there a better way to do lighting than this?? Thanks.
HoozitWhatzit
HoozitWhatzit
Why didn''t Direct3D lighting cut it?

You could also use light maps/shadow maps, depending on the characteristics of your terrain.

--Hoozit.
pangplast
pangplast
Read thorugh this tutorial twice:
http://www.gamedev.net/reference/programming/features/shadows/page4.asp

Now rip the ShadowVolume class from the directx sdk stencilbuffer->shadowvolume sample.

I just did it, and it looks great when my spaceship flies over my generated terrain

.Pangis
Screenshos of "Humanoid invasion": http://humanoid.vaultcity.org/
JSCFaith
JSCFaith
Well, shadow mapping doesn''t allow for realtime effects. I am looking for something I can alter in realtime without much fuss and computational expense. The Directx lighting I was using, used normals to compute the ligting, it wasn''t true lighting, it didn''t cast shadows, it just shadded polygons that faced away from the light source, this isn''t what Im looking for. Would stencil buffers work, I haven''t read to much into stencil buffers, but I know they can be used for shadows. Would this be a fast realively fast approach or not? If so, do you know of any good tutorials on how to use stencil buffers for shadowing? If you could help I would really appreciate it..

Thanks in advance.

Later,
James
JSCFaith
JSCFaith
Can I make the terrain cast shadows, or only stuff cast shadows on the terrain?
HoozitWhatzit
HoozitWhatzit
Read these great articles on Gamasutra. One explains stencil buffers, and the other explains the use of shadow volumes to create realtime shadows.

http://www.gamasutra.com/features/19991115/bestimt_freitag_01.htm
http://www.gamasutra.com/features/20000807/kovach_01.htm

After you''ve read them, study the SDK tutorial on shadow volumes. (Source: (SDK root) \Samples\Multimedia\Direct3D\StencilBuffer\ShadowVolume)

In answer to your question about speed, that depends on your implementation. The first thing you''ll notice when you filch the SDK sample''s code for your own project is how slow it runs. This is because the sample is creating/deleting heap memory every frame of animation, and also locking/unlocking the vertex buffer once per object.

With a little creativity you can speed shadowing of this type up quite a bit. I''m using shadow volumes for my demo, and it hauls pretty well.

Ganbatte kudasai (good luck).
--Hoozit.
JSCFaith
JSCFaith
Thanks for the reply.. I will definitally read both of those artcles mentioned..

Thanks again.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.