Shadows

Started by
9 comments, last by nildo 20 years, 10 months ago
Can someone copy here a Shadow routine, that makes all the objects shadows that has in my 3d surface, by a Light point ? For example: I pass as parameter the Light position and this function makes all the shadows for me. But anything that dont use Arb_multitexture_Something_like_that because my computer does not suport this function. Thank you all and c ya =)
Advertisement
What you are asking is not easy at all.
The simplest way to make shadows is the stencil projective shadows. They are fast, easy to understand, but have the dissadvantage that you can only project them on a flat ground.
I wrote an article on my site, check it here.
BTW, ignore the multiple source shadows part in the article, most of the times it gives crappy shadows.


Height Map Editor | Eternal Lands | Fast User Directory
glEnable(GL_SHADOWS);

world->draw();

glDiable(GL_SHADOWS);

LOL

Sorry, I couldn''t resist....

For the simplest shadows just find the transformation that projects onto the surface you want to cast the shadow (For instance, the ground plane) and mutilply it by your current modelview and then draw your object to get the shadow, (you still have to worry about clipping and stuff). As well this method is very simple and it dosn''t look good and is not very realistic, (it''s a step up from drawing a circle underneath ur model); it also dosn''t scale up to casting on multiple planes.

In essence:

float planarProjection[16];computePlanarProjectionTransformation(planarProjection, lightVector, projectionPlane);//draw the model normallymodel->draw();//draw shadow of modelglColor(0.1, 0.1, 0.1);                    //something darkglPushMatrix();glMultMatrix(planarProjection);  //setup modelview to project the vertices onto proejctionPlanemodel->draw();  //draw the shadowglPopMatrix(); 


computing the planar projection matrix is quite simple( a few dot products), you can find it on the net somewhere or i can post it. Remember this is a very simple method and dosent account for a lot of things, but is about the only method that can be explained with out haveing to summarize a masters thesis.





"But anything that dont use Arb_multitexture_Something_like_that because my computer does not suport this function."

??? u mean multitexturing...any card that came out in the last say 5 years should support this vodoo2 and greater.

Hehe. I wish it was just
glEnable(GL_SHADOWS); and glDisable(GL_SHADOWS);

LOL

Can you write here examples ? Cause i am beginner on this subject. Thank you
Shadows arent a beginners subject really. Doing them properly will be almost impossible to do for a beginner. Its not just something you can write code for that will plug into any code situation. You have to write the code for them that will work into your engine.

-----------------------
"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else''s drivers, I assume it is their fault" - John Carmack
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
hey before you waste your time on trying something complexe like shadows i d suggest you create your own camera and maybe map format so you have atleast something more complex to test your shadows with not just a cube and a plane rofl
http://www.8ung.at/basiror/theironcross.html
Oh thanx. I will do that.

Its cause i am trying to do the Snake game (witch has to eat the apples) but in first person.. Lol

Thank you ppl. Thank so mutch
I know it''s quick and dirty (just the way it should be ; ), but if you just want something simple to anchor your apples to the ground then just render a black circle below them.

I was forced at flunk-point to make a pacman clone for one of my uni modules, and all of my food bits looked really strange until I put drop shadows under them. If you have a kinda cartoony look to begin with it''s all you need.
Do u have a code the source of this shadow maker ?
http://ice.prohosting.com/~bgcjr/Release.rar

a Demo of DPSM.
Game Core

This topic is closed to new replies.

Advertisement