Shadows

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.

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

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

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.
(

Pedro

these are not stencil shadows, but projected shadows. look at the nvidia site, it has enough info.

Shall I fetch your coat, pedrovr?

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

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?

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

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.

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…

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).

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…

IMHO the easiest way is to use shadow maps.

Unfortunatly they have a ton of artefacts 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 . Supposedly you’re able to reduce these by rotation , but that isn’t what I’ve found.

Woo has an improved variation of shadow maps. But even with rotation 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 , because they have just as many (different) problems . 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?

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 as it seems you can’t link to a picture.

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.

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

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.

Originally posted by JustHanging:
[b]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[/b]

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 (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.

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!

In the second depth 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.

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

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.

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.