Let i have some mesh (for ex. sphere) in the center of room, full of cubes and one light source. How can i make fast and easy shadow-casting in OpenGL, using "standard" (fixed) functions only? Note: the result must contain cube and sphere shadows as well.
-
1BTW- "standard functions" aren't really the expression you're looking for. "Fixed function" is more like it, but shaders are what's been "standard" for quite a few years now. – Kos Nov 21 '10 at 18:19
-
Yep, i was thinking on how to call this when composed my question. It's fixed now, thanks! =) – shybovycha Nov 21 '10 at 18:24
3 Answers
If you can generate a silhouette of the sphere then you could use shadow volumes. nVidia hardware has also supported fixed function shadow mapping for a fair while as well.
Shadow volumes have the disadvantage of very high fill rate requirements. Shadow maps can be better but require an extra pass.
If you are projecting on to a single plane it may well be easier to just project the object on to a plane.

- 61,365
- 24
- 124
- 204
-
The point is to use universal algorithm - not for sphere silhouette only =) But thanks anyway! =) – shybovycha Nov 21 '10 at 16:23
-
Sorry, haven't clicked second link somewhat... Yep, you were right, shadow mapping is good enought and i've discovered it by myself (stupid me) =) – shybovycha Nov 21 '10 at 18:11
-
@shybovycha: Just so ya know. NONE of the techniques listed above are for spheres only ;) – Goz Nov 21 '10 at 21:38
-
i just aimed for words "if you can generate a silhouette of the sphere..." =P – shybovycha Nov 21 '10 at 21:40
There is no fast and easy way. There are lots of differnt techiques, that each have their own pros and cons. You can look at a project I host on github, that uses very simple code to create a shadow, using the shadow volume technique (http://iuiz.github.com/VolumeShadow/). However it is written in Java, but it should not be hard to port it to any other language.
The most important ways to create shadows are the so called "shadow mapping" method, where you render your scene (with the camera at the light source, directed to each shadow casting object) to a texture. And the second technique is the shadow voulume method (made famous with Doom3).

- 957
- 1
- 10
- 23
-
Thanks, but i've already got the idea =) Projective shadows would be enough =) – shybovycha Nov 21 '10 at 16:24
I've found one way using StencilBuffers. Being a little confused for a while, i finally got the idea - whith this the most hard thing would be looping through each light source and projecting all scene objects. This one looks more pretty than texture shadowing and works faster than volumeric shadows. here and here are some resources, which helped me to understand matrix multiplication step (it confused me a bit when i was looking through dino demo). As for me, this method is most easy to understand and use. The only question left to solve is how to calculate multiplication matrix.
Although this method could be changed a bit using textures as shown here.
Thanks everybody! =)

- 11,556
- 6
- 52
- 82