Python Shadows

OK, so that’s one way to do it. Any others?

I know, it just adds another level of complexity to an already difficult problem. If there was a tutorial, and I couldn’t get it to work, or my grfx card doesn’t support it, I wouldn’t know that until I translated it to Python.

Ok… C and Python are just 2 languages. There’re not so many differences between the two.
Doing such a distinction is definitely not a professional way. What, braces vs tabs+column? Please! As a programmer you’re supposed to see those languages as tools, not as goal. [/QUOTE]Yep. You’re right. I like Python b/c it is simpler to use and more intuitive. Python is based on C++, though, so of course they’re similar.

Like I’ve said, you’re the experts, so you would probably be able to tell what’s appropriate and not overkill. What exactly do you mean by engine info.?

What exactly do you mean by engine info.?

Well, to start with, what exactly are you trying to shadow? You said earlier “but right now, I’m concerned with just projecting the shadow on the ground.” I take it that means the the shadow the plane casts due to the sun? Nehe’s tutorial should cover a version of that using the stencil buffer.

You mentioned that you couldn’t get that tutorial to work. This forum probably has people that can help you figure out why! (Even if you port it to Python)

Like I said, choose a technique (I’d suggest the stencil one since there’s a tutorial) and plug away at it for a while. Come back with questions.

I wouldn’t imagine you could get away with planar shadows, not unless your ground is just a flat plane - if it is, you’re not going to sell your sim/game to anyone. If it’s a heightmap, and you only care about shadows on the ground, not on trees or buildings, then you could easily get away with a simple projected texture. That projected texture could be a simple blob that you knock up in photoshop, or it could be dynamically generated by rendering your aircraft into a texture using an orthographic projection matrix.
Anyway, here’s an nice overview to give you some terminology to help your search:
http://www.devmaster.net/articles/shadows/
http://www.devmaster.net/articles/shadow_techniques/

From this, I think I want to do “Depth Shadow Mapping” because it is fast and meets all my other requirements. Also, since the shadow of the plane won’t be very large, the texture size drawback doesn’t apply. All the links were broken though…

That’s a fine choice you’ve made there.

Links work fine for me.

(Working) Links:

http://www.cs.ualberta.ca/~ghali/courses/texts/redbook/html/09-10-shadowmap.c.html
http://developer.nvidia.com/object/robust_shadow_volumes.html

Another tutorial on shadow mapping:
http://www.paulsprojects.net/tutorials/smt/smt.html

Links work fine for me.

I believe he was talking about the secondary links from the main article which are no longer valid. :slight_smile:

My bad.

The nvidia link I saw seemed to work alright so I cut my clicking adventure short with that.

P.S. Anyone played with VSMs?

I think a PSSM-VSM combo would be pretty sweet, but I haven’t gotten around to trying it yet…

Seems like if you can get past the light bleeding in VSMs you’d be home free.

Anyways, back to my biscuits…

I converted http://www.cs.ualberta.ca/~ghali/courses/texts/redbook/html/09-10-shadowmap.c.html
to Python, in two versions. One, which I converted to not use GLUT does not seem to draw shadows- I don’t think I did it right. At least GLUT works. The other, which I’m trying to convert now doesn’t run because I can’t figure out what kind of argument glutInit() wants. It crashes.

I can’t figure out what kind of argument glutInit() wants.

The parameters to glutInit() aren’t important, as passing is perfectly valid and not critical to a functioning program.
(2.1 glutInit)

You crash is elsewhere.

It crashes when there’s any keyboard input.
I think I’m getting some sort of shadow, but the framerate is really slow, like .33fps. Also, it’s not rotating.

Commenting out this line:
glDrawPixels(SHADOW_MAP_WIDTH, SHADOW_MAP_HEIGHT, GL_LUMINANCE, GL_FLOAT, depthImage)

makes it fast, but then the shadows are not displayed.

Yet another choice link from the OpenGL gallery…

http://www.opengl.org/resources/libraries/

Try using a texture to display/debug your depthmaps.

DrawPixels can be a bit on the slow side at times…

“Copyright (c) 1993-2003” You are porting what looks like an old example :slight_smile:
I guess DrawPixels called from python code can be even slower, as it transfers quite a lot of data from GPU to CPU.

Maybe try to port this sample instead, as it seems to be more modern :
http://http.download.nvidia.com/developer/SDK/Individual_Samples/samples.html#hw_shadowmaps_simple

Seems odd.  The "Simple" tutorial-example-thingie is many pages long and has many errors.  Really frustrating.  

I don't want to give up on the old tutorial yet.  Now that it's in Python, I can really manipulate it.  Perhaps the slowness problem is due to depthImage being in a Numpy style array?  What format is it supposed to be in?

I find it hard to believe that such a tutorial could run on the old hardware it was designed for, but barely move on my new laptop.

We told you shadows are hard.

Perhaps the slowness problem is due to depthImage being in a Numpy style array?

I don’t know the relative performance of python arrays
Python has a crappy slow virtual machine. Too bad Jython seem almost abandonned. But anyway, the readpixel/drawpixels pair is not useful for having shadows, just to debug the depthmap rendering.

About perf on the old example, I tried compiling it in C, it is blazingly fast.