shadows? Best way and advise on "pauls projects"?

Hi, firstly im wanting to give shadows a go. And after lots of “googling” im now a little confused.

What is the current best way or most common used way of shadows? “real-time” if i dare? :slight_smile: I would have thought using shaders? But cant find much on that soim not sure?

another good question would also be (from a beginners POV) what would be the best way to have a go at first?

I thought about this one (im sure you have seen it before) its hte “pauls projects” one. http://www.paulsprojects.net/tutorials/smt/smt.html
Is that a real-time one? As in if there is a rotating object the shadows are also updated? Its just at the start it seems he has some rotating objects?

Bascially, im still classing myself as a beginner, and im wanting to have a go at shadows.

Thanks
Andy

I’m also a beginner and know nothing about shadows right now but I’m reading the red book and its doing a good job teaching me OpenGl, so I recommend this section of the book that deals with Shadows.

Again I did not read it myself and so do not know if it’s the best way to start. Anyway, I believe shadow is a fairly “hard” topic to start with so good luck :slight_smile:

http://www.glprogramming.com/red/chapter14.html#name15

The tricky thing about shadows is when rendering an object, you have to have information of other objects in your scene similar to ray tracing to see if it’s blocking the light. The two most popular ways of providing shadows are shadow maps and shadow volumes.

Shadow maps are depth textures rendered from the light’s point of view and with a reprojection a surface you’re shading can see if something is between in and the light. There are a lot of different methodologies on filtering these so they don’t look blocky. They’re the de facto way to do shadows interactively.

Shadow volumes involve calculating silhouettes around the objects at edges where one face is in shadow and the other is in light. This requires calculating them, which can be tricky for complex geometry and scenes. They do give nice clean shadows though.

You ought to. It’s great fun. If you understand basic vector and matrix math, and understand what MODELING, VIEWING, and PROJECTION transforms are, then you shouldn’t have any trouble. Just a little learning and piecing things together – should be a fun project.

And after lots of “googling” im now a little confused.

Post your questions, and we’ll help you out. Might outline what you think you understand and then ask what’s got you confused.

What is the current best way or most common used way of shadows? “real-time” if i dare? :slight_smile:

Define “best” :cool: That’s a flame war waiting to happen. Best quality? Best performance? Best hard shadows? Best soft shadows? Best for explicit geometry? Alpha geometry? Dynamic geometry? Point light sources? Directional light sources? Area light sources? etc. …you see what I mean. :smiley:

However, in terms of “most common” “real-time” shadowing techniques, arguably “shadow maps” have that title right now.

There are bunches of tweaks, variations, and add-ons (cascaded, variance, exponential, etc.), but just try your hand at some basic shadow mapping first to lock in the basic concepts. Then branch off to the variations as desired.

I would have thought using shaders? But cant find much on that soim not sure?

Yeah, it’s a heck of a lot more flexible doing shadow mapping using shaders, versus legacy techniques using the fixed-function pipeline, but you can use legacy fixed-function pipeline functionality to do very basic shadow mapping if you want.

another good question would also be (from a beginners POV) what would be the best way to have a go at first?

Just start with a simple scene casting a shadow of a cube or sphere onto a plane. Easy to cook up such a scene using GLUT or similar (sphere above plane – check!) or just borrow it from an on-line tutorial somewhere. Then add the shadow casting logic.

I thought about this one (im sure you have seen it before) its hte “pauls projects” one. http://www.paulsprojects.net/tutorials/smt/smt.html
Is that a real-time one?

Yeah, that’s a pretty good tutorial. Pretty good description of the concepts. Though its implementation uses the legacy fixed-function pipeline TEXGEN functionality to do the projective lookup into the shadow map. Works, but as a Phase 2 you might want to convert to using shaders as its much more flexible and more easily extended.

As in if there is a rotating object the shadows are also updated?

Exactly.

By the way, just so you don’t get confused by all the verbage in some tutorials, the basic algorithm is:

  1. Render a depth map of the scene from the light’s perspective
  2. Render the scene from the camera’s perspective, using the depth map to determine what’s “in shadow”

Step 1 is of course new. And Step 2 is what you’ve always been doing, but with the tweak of using that new “depth map” (aka “shadow map”).

Also, here’s another brief shadow mapping tutorial, but unlike Paul’s Shadow Mapping Tutorial Project, features shadow mapping with GLSL:

It’s not perfect, but it gives you some idea how you might do this with shaders.

Note that while his fragment shader references the depth texture (i.e. shadow map) using a sampler2D and does an depth comparison using explicit shader logic, he could just has well have used a sampler2DShadow and configured the GPU to do hardware-accelerated depth comparisons, either with or without PCF, even with the shader path. That can be even more efficient on some GPUs. But pay no attention to that until you understand what shadow depth comparisons and PCF are.

Also, on the subject of real-time shadowing algorithms, here is a very good (and recent) anthology of these techniques:

Wow, cheers for that! Very much appriciated and ready to give it a go. I like the idea of using a shader. Seems somewhat cleaner.

Anyways, ill have a read and a go and report my results!

Thanks
Andy