View Full Version : Fast Shadows questions... (AGAIN)
12-03-2001, 12:04 AM
Hello to you reader!!!!
Several days ago i had posted a question on how to make fast shadows without using stencil buffer.
The reason i ask for such a think is because my PC is not a state of the art (in case it is for a museum).PMMX 233MHz, 96MB RAM, and Diamond Viper V330 with GLSetup installed.
I tried NeHe's tutorials on shadows and reflections and i found that my card can't handle things with a normal speed. That's why i want someone to tell me if there is a way to make shadows without stencil buffer.
The general algorithm (i think) is to render the scene from the light's position and color everything black (this kind of algo can be found in OpenGL SuperBible). But there is a little problem with it. You can project the shadow only on one plane. The result i want is the shadow to bent on surfaces.
I have found an article on the web title (if i remember correct) "Fast shadows and lighting effects", that talk about make shadows using "shadow textures". I can't figure out how it works.
Is there anyone who can be more specific with the way this algo work? Is there any tut or any other kind of resource on the web talking about this effect (OpenGL specific or not, i don't care) in a more detailed way? The reason i am asking for more specific algorithms is because i am not an expert C++ or OpenGL programmer. I am learning OpenGL because i like it, and my target,someday, will be a GameEngine (the Lightning Game Engine).
Please forgive my terrible English and don't laugh with my thoughts.
12-03-2001, 10:16 PM
If you want your shadow bent on your surface, you can compute 1 projection per triangle of your surface.
Yes, this will be slow if your surface has many triangles, but notice that in the games they never cast shadows on curved surfaces.
I don't know anything about shadow textures, but I guess that it means that you render your shadow in a bitmap which you map as a texture on your surface... Yes, that might work... i dont't know....
12-03-2001, 10:31 PM
You can use projective texturing to get your shadow texture to conform to geometry. Its a simple method and there are tuts all over the place on it.
Render your shadow caster from the light view and then make a texture out of it, bind the texture, setup tex gen using the light view and light projection, then render your shadow receiver.
Look in Game Programming Gems, this method is listed in there. Its pretty fast, but just so you know you will have to sacrifice performance for any good shadows.
Another method you may want to look at is shadow mapping which is similar to the what I just described. Shadow mapping uses the depth buffer and texture projection and texture environment combine to make shadows. Its a neat trick with its own problems but when used correctly it can work just like shadow volumns but you dont need to use the stencil buffer as long as you only have 1 light.
I recommend checking the Nvidia developer site. The shadow demo can be a little complex but if you arent good at reading code and figuring things out now is a good time to improve that skill. It will help you in the long run, believe you me.
12-06-2001, 11:25 PM
Please tell me where can i find the tuts you are talking about ????????????
Are there any shadow specific tuts for projective texturing?????
Are they need any special hardware (????) , because my Viper is not the best card in market.
Where can i find Game Programming Gems source code????????
I don't have difficulty in reading source code, when it is writen detailed (not commented, DETAILED).
My problem is to make out the code from an algorithm. Because i am not an expert (not even an intermediate) programmer i can't translate algorithm's commands into source in the best way it can be.
Please REPLY. Pleeease!!!!!!!!!!!
The problem with OpenGL Superbible's algorithm is that it can project shadows only on one plane (three points). I can't figure out how can i project the shadow on multiply polygons, like a terrain.
12-07-2001, 12:05 AM
Here you'll find a lot of docs on shadow mapping, that is the name of what you are looking for.
I'm going to implement it in the next days!!
The link: http://developer.nvidia.com/view.asp?IO=shadow_mapping
It has generic docs, and hardware related docs.
Very good the slides (pdf or ppt on the left).
... I missed: with this technique you can project shadows on curve surfaces, objects are self shadowing, all without specific hardware and without operations in the object space... independent from the number of objects... only an additional texture to apply. This is good!
The drawbacks... read it in the slides!!
[This message has been edited by Teofuzz (edited 12-07-2001).]
12-07-2001, 12:22 AM
I found the code on Nvidia's web site to be a little hard to understand and I have made a living out of reading other peoples code. (porting code from platform to platform) Eventually I figured it out and you can too if you remain persistent. A pdf called "shadow mapping with todays opengl hardware" is also available but it gives an overview only. I recommend it so you can get an idea as to how it works without being confused by code. As for Game Programming Gems, I recommend buying it. They have good explanations and the source code is on the CD. It may be available on a website somewhere but I never bothered to look since I own the book. There is a second book out but I havent gotten around to buying it yet. I have the Superbible but I think the OpenGL Programming Guide is better. In fact I wish I never bought the superbible. Anyone want a used copy? http://www.opengl.org/discussion_boards/ubb/smile.gif
The only special hardware you need is a card with an OpenGL driver that supports TexGen and tex_env_combine. I dont think the Viper supports tex_env_combine but I really wouldnt know. You can find out info on tex_env_combine on the sgi extension repository. I dont know the link offhand but you can find it in the FAQ on this site. Its pretty complex but once you figure it out you can do some really neat stuff.
Check out the stuff on Nvidia about projective texturing too. Its also a neat trick and you will nead to use it to project your shadow texture onto any geometry.
Good luck and as always ask lots of questions.
12-07-2001, 02:50 AM
I think nVidia is the only way.
Thanks a lot guys.
"I will be back"
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.