PDA

View Full Version : Shadows



pedrovr
04-01-2003, 04:39 AM
Hello,
I don't know anything about advanced opengl, but I need to implement the algorithm for Shadows.
Can anyone help me find this algorithm implemented? But with an easy implementation code.
I know that this work was done in the past.

Tom Nuydens
04-01-2003, 04:47 AM
No shadowing algorithm is "the" shadowing algorithm. The two most popular approaches at the moment are stencil shadow volumes and shadow mapping, and they both have their pros and cons. You can find plenty of threads about both of these approaches in the forum archives.

-- Tom

raverbach
04-01-2003, 05:04 AM
If you´re used to work with multitexturing , i think you´ll find shadowmaps quite easier in a first approach ...
stencil shadows are a little more difficult to understand due to the necessity of some knowledge of the stencil buffer... which is good thing to know AFAIK
when oyu get more familiar with the 2 processes , then you should choose wich one gives you the type of shadows you´re looking for , and that you like more to implement

pedrovr
04-01-2003, 05:19 AM
Have one implementation of the stencil shadow volume, but works only in planes XZ and not in XY.
I already try to do some changes on the program, but don't do what i want.
The program that I use is from Mark J. Kilgard, the dinoshade with shadow and reflection.
This program is good becouse I can change easyli the geometric shape, it's what I need.
http://www.opengl.org/discussion_boards/ubb/frown.gif(

Pedro

okapota
04-01-2003, 05:46 AM
these are not stencil shadows, but projected shadows. look at the nvidia site, it has enough info.

knackered
04-01-2003, 07:06 AM
Shall I fetch your coat, pedrovr?

pedrovr
04-01-2003, 07:22 AM
You are joking with me, knackered!?
If yes, I don't have time to jokes, ok?
I have a Red Line to this work and don't know kow is implemented, don't know anything about advanced OpenGL.
Thank you,
Pedro

KRONOS
04-01-2003, 08:55 AM
http://www.opengl.org/discussion_boards/ubb/smile.gif Bem, é bom ver alguem de Portugal...

Mas aquela pergunta tá um pouco mal feita e como isto é um forum avançado o pessoal daqui fica sempre um pouco lixado...

Sabes pelo menos que tipo de sombras tens de implementar?

pedrovr
04-01-2003, 09:38 AM
Olá!
finalmente alguém disposto a dar-me uma ajudita.
Sei sim, basicamente qualquer tipo de sombras será bem vindo, apenas um tipo de sombras será necessário.
Passo a explicar, estou a trabalhar para um projecto europeu, no qual é necessário criar uma biblioteca de Técnicas Avançadas de Render.
Um dos algoritmos a implementar terá que ser necessariamente sobre sombras.
Eu sei que há pelo menos 3 tipos de algoritmos:
- Projective shadows
- Shadow volumes
- Shadow maps
Encontrei um programa que faz alguma coisa do que eu quero, ou seja, dou-lhe uma geometria e ele calcula a sombra, só que apenas funciona bem para o chão, quando coloco paredes, a coisa dá para o torto. A sombra é cortada, ou então, não parece minimamente real.
O que eu queria era um programa que pega numa geometria qualquer e com base na posição da luz, projecta sombras contra as paredes, chão, etc.
Tb já percebi que as sombras terão que ser calculadas para cada um dos planos.
Sabes de algum site, programa escrito em opengl com C, Tutorial, Aulas, etc.

Se os meus conhecimentos de OpenGL fosse mais além do básico, já o teria implementado porque há descrições até muito boas, mas há muita coisa do OpenGL que me passa ao lado.

Se poderes-me ajudar de alguma forma agradecia.

Obrigado,
Pedro

knackered
04-01-2003, 10:10 AM
Have I had a stroke or are you lot talking in some kind of foreign language?
I do hope you're not one of those Iraqi gentlemen...

pedrovr, don't take it out on me that you lied to someone that you can do something by a certain date - that's down to your stupidity.

rgpc
04-01-2003, 07:06 PM
Originally posted by knackered:
Have I had a stroke or are you lot talking in some kind of foreign language?


Oh no... It's catching... I've just had the same stroke....

KRONOS
04-02-2003, 06:27 AM
lol Sorry, but this way we could understand eatch other better.

Portugal! Not Iraque. We're speaking portuguese (one of the most beautifull languages on the planet). http://www.opengl.org/discussion_boards/ubb/smile.gif

Pedro: Não existem muitos sites sobre GL em portugues, embora na minha pagina tenhas lá algumas coisas (está no meu info). Dá-me o teu mail e mando-te uma implementação de shadow volumes....

titan
04-02-2003, 07:54 AM
IMHO the easiest way is to use shadow maps.

Unfortunatly they have a ton of artefacts (http://ca.geocities.com/titan_spamaccount/robot.jpg) that you can't really do anything about.

Also when you have a light and shadow at a very small angle you get huge ugly jaggies (http://ca.geocities.com/titan_spamaccount/sm-a.jpg) . Supposedly you're able to reduce these by rotation (http://ca.geocities.com/titan_spamaccount/sm-b.jpg) , but that isn't what I've found.

Woo has an improved (http://ca.geocities.com/titan_spamaccount/woo.jpg) variation of shadow maps. But even with rotation (http://ca.geocities.com/titan_spamaccount/woo-b.jpg) it still can't handle situtaions where the light angle with a surface is small.

In case you're thinking I just implemented these algorithms incorrectly I'll point out all of these screenshots are from nvidia's samples.

I originally avoided stencil shadows because they have so many errors when self shadowing. Unfortunately I wasn't paying enough attention to the nvidia examples (http://developer.nvidia.com/view.asp?IO=cg_toolkit) , because they have just as many (different) problems (http://ca.geocities.com/titan_spamaccount/robot.jpg) . They look great with the default view, but when you zoom in or put the light at a non optimal position you get a ton of artefacts.

With stencils you simply get incorrect shadows.

Has anybody found a way to reduce these artefacts?

titan
04-02-2003, 08:05 AM
Damn, Geocities is a PITA.

If you want to see those pictures showing various shadow map artefacts you'll have to load the web page (http://ca.geocities.com/titan_spamaccount/) as it seems you can't link to a picture. http://www.opengl.org/discussion_boards/ubb/frown.gif

I'd still love to hear if anybody has solutions for either the robot or the small light/surface angle problems. They really do limit shadow maps usefulness.

JustHanging
04-02-2003, 08:24 AM
The page doesn't work either!

I'd argue that in most cases stencil shadows are better if all you need is "correct" shadows for depth hints or so. Shadow maps can be plugged in more easily, but with all their problems, I wouldn't call them easier. There are hacks aroud most of them though.

But if you want realism or athmosphere, softness matters more than correctness, and that's where the shadow maps start to rock.

Jittered soft stencil shadows are likely to be the first shadowing algorithm that doesn't suck, but that's still out of reach when it comes to complex scenes and lighting. So it's a tradeoff you wouldn't want to make...

-Ilkka

Mazy
04-02-2003, 09:21 AM
I have seen problem with shadowmaps, but not that much.. use offset when creating the shadowmap to lift it a small bit in the Z and you should be able to tweak awat some of those errors.

titan
04-02-2003, 11:22 AM
Originally posted by JustHanging:
The page doesn't work either!

I'd argue that in most cases stencil shadows are better if all you need is "correct" shadows for depth hints or so.
-Ilkka

The page should be working now. The biggest drawback, IMHO, to stencil shadows, is the way shadows pop on or off. Check out the knight's shield on the bottom of that page (http://ca.geocities.com/titan_spamaccount/) (screen shot also from nvidia's cg broswer 5.0). They really don't work well for self shadowing either.

The 2nd drawback is they are a bit more diffuicult to implement than shadow maps.

titan
04-02-2003, 11:35 AM
Originally posted by Mazy:
I have seen problem with shadowmaps, but not that much.. use offset when creating the shadowmap to lift it a small bit in the Z and you should be able to tweak awat some of those errors.

The problem is no matter what I can't seem to get rid of the errors. I can tweak away for a given scene until it looks perfect.

Then I'll move the object or light and I'll see artefacts. So I'll tweak those away. Then I go back to the first light/object position and I see it has artefacts again!

This tricked me into using shadow maps. I thought I would be able to tweak artefacts away for any scene. This is really only sort of possible if the scene is static! http://www.opengl.org/discussion_boards/ubb/frown.gif

In the second depth (http://www.cs.unc.edu/~lastra/Courses/Papers/Wang_Molnar_Second_Depth_Shadow.pdf) paper (bottom of 1st column, 2nd page) Wang and Molnar come to basically the same conclusion I did, you can't just tweak away the artefacts in your scenes.

If you think you can I challenge you to try to fix those nvidia samples. http://www.opengl.org/discussion_boards/ubb/wink.gif

(don't take the challenge to seriously, I think shadow maps simply don't yet work)

DopeFish
04-02-2003, 10:11 PM
Originally posted by titan:
The page should be working now. The biggest drawback, IMHO, to stencil shadows, is the way shadows pop on or off.

The easiest way to get rid of that (mostly) is to use a form of per-pixel lighting, so that as the light source goes past a surface, it fades out and is near black (or whatever your ambient lighting is) by the time the shadow "pops" in.

tfpsly
04-02-2003, 10:50 PM
At least with stencil buffers, you can have phisically more realistical shadows. I means that you do not highlight everything and then put black/gray pixels where shadows should appear. You instead noly hilight only the exact area that can receive some light.

Shadow maps are said to be easier to blur/make soft? So what? In most case it is just an image based technic, not a geometry based technic, so it does not take into account the distance from occluders so it's not realistical.

I don't have any problem with self-shadowing. Do you use a planar silouhette? When generating a volume from the 3d edges, you don't have such problem.

JustHanging
04-03-2003, 12:56 AM
Originally posted by tfpsly:
you do not highlight everything and then put black/gray pixels where shadows should appear. You instead noly hilight only the exact area that can receive some light.

Why on the earth couldn't you do this for shadowmaps? It's a one-pass per light thing for static lights!



Shadow maps are said to be easier to blur/make soft? So what? In most case it is just an image based technic, not a geometry based technic, so it does not take into account the distance from occluders so it's not realistical.
Well mine do: http://www.hut.fi/~ikuusela/images/softshadows2.jpg
Again, one pass for static diffuse.

There are still artifacts to be fixed, but at the moment I'm pretty confident that shadow maps can get closer to the result I'm interested in than stencil shadows.

The pop-up thing is common to all shadow algorithms, with shadow maps it's just hidden by other artifacts. I guess you don't get it because you don't have smooth shaded geometry.

-Ilkka

pedrovr
04-03-2003, 02:55 AM
Hello again,
I have a little problem with projection shadows.
So: I have a light that it's moving in circle. The shadow that is project on the floor it's also moving in circle, the problem is that the center of rotation is wrong. How I change the center of rotation on the shadow matrix?

Thank you,
Pedro

raverbach
04-03-2003, 03:40 AM
Legal saber que tem gente que tbm fala português nesse fórum http://www.opengl.org/discussion_boards/ubb/smile.gif

Não sou de Portugal , sou do Brasil ,e é muito bom ver pessoas falando a boa e velha língua de camões http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by raverbach (edited 04-03-2003).]