Public Group

#### Archived

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

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

## Recommended Posts

When I started to wonder how shadows could be drawn, I came up with a simple idea, that each triangle casts shadow-triangles on other triangles. Though, I''ve got a feeling that there must be smarter ways, because going through every triangle as many times as there is triangles, would be very slow. I''ve tried to read this Nehe-tutorial (lesson 27) about shadows, but it just describes details of drawing shadows, and I''ve never understood what''s the basic theory or principle behind it. Could any one explain it briefly? Or was my first idea already correct?

##### Share on other sites
Anyway, next question:

Let''s assume I would be drawing shadows as shadow-triangles. Now, if I have a triangle that has alpha-channel in it''s texture, and kind of holes in the texture, having this triangle casting a shadow would still be easy: I could just draw the shadow-triangle with same alpha-picture as the original texture had. This way shadow would have holes in same places as the original texture had.
The big problem is: What should I do when another triangle casts a shadow on this triangle with holes? How could I prevent shadow from being drawn on the holes?

##### Share on other sites
quote:
Original post by Plasmite I came up with a simple idea, that each triangle casts shadow-triangles on other triangles.

Your description is very vauge, how on earth do you actually plan to cast your ''shadow triangles''?

Theres many different ways of doing shadows, some suitable for practically any geometry, some only for casting on flat surfaces, some which limit you to no self shadowing. In general the more generic and complete, the more complex.

First you need to figure out what you actually require. Odds are you could get away with something simpler like projecting a shadow texture.

If you really do need a robust and general shadowing method, check out shadow volumes (which is used in nehe27) or shadow maps. Both of which have lots of information on the web.

##### Share on other sites
Actually I was planning on this:
There''s a surface triangle I want the shadow to be casted on. I define a plane where this triangle lies. Then there is a triangle that casts a shadow, and a light source. I define three lines that go through light source and each corner of the casting triangle. I find where these lines intersect with the plane defined earlier. Points of intersection would then work as corners of shadow triangle. I could use stencil buffer to prevent shadow from been drawn outside the surface triangle.

This is a bit silly excuse, but it is so, very, hard to read tutorials about certain methods, when you already have one of your own. Specially when tutorials are difficult to understand.

I would like know two things. Are these shadow volumes and shadow maps so much significantly better, that it would be waste of time for me to start coding this shadow stuff of my own? And if it would not be waste of time, does anyone know the solution to this "casting shadows on textures with alpha channel"-problem I described?

##### Share on other sites
quote:
Original post by Plasmite
does anyone know the solution to this "casting shadows on textures with alpha channel"-problem I described?

This is one of the major limitations of shadow volumes - since you have to create and render the boundaries of a shadow cast by an object (and get it properly in sync with the depth buffer) it doesn''t work with alpha tested/blended surfaces.

Its also why shadow maps are a better alternative (assuming relativly modern, up to date hardware) since they work with this kind of geometry. Nvidia have a whole bunch of documents covering this on their site if you''re interested.

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
16
5. 5

• 14
• 29
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631773
• Total Posts
3002270
×