Python Shadows

Yeah, I tried it. I couldn’t compile it though. How would one modify the Python version. Something like:
if shadowRender:
#What do I put here?

I edited my previous post. No need for drawpixels.

So I just get rid of it? Also, why does it crash when I press any button?

In the Pygame (not GLUT) version, I can get the shadows to work by disabling the textures. I see a blue cube and a red torus at the bottom left of the screen. The torus is rotating, not around the cube, but in front of it. The light appears to be coming from the viewpoint, but the shadows are projected on a white quad on the bottom right of the screen.

Here’s the Python source for this this screenshot:
http://www.geometrian.com/Shadows3D_3_1.py

So, the shadows are being rendered incorrectly. First, where did the white quad come from, and second, why is the light, shining from the right casting a shadow on the right? As you can see from the marks on the torus and cube, the light is coming from right about where the shadow is- from the right.

Well, if you disabled texture mapping, no shadow mapping !
Actually what you are seeing there are :
left: scene as seen from the light
right: associated depthmap

What is missing the scene from the camera point of view, whith the depth compare between the shadow map and the scene.

I didn’t follow that, sorry.

The white quad, and it’s contents, are the depthmap. If you were to visualize what was rendered to the depth buffer that’s what you’d see. That’s why the quad is white, because it’s uniform depth (1.0). The contents of the white quad are not the torus and cube’s shadow.

The shadow, as you can plainly see in the image on the left, is now correctly applied to the torus (red, with shadow) and cube (blue, with shadow).

Basically, you got the demo to work (minus the texturing). Congrats.

It’s shadowing?! YAY! Now I need to figure out how it works…

I still don’t see how it’s shadowing though–I zoomed in, but the torus doesn’t cast a shadow on itself or the cube at any point–I thought it was the normals causing the light/dark areas…

Thanks,
G

Alas no in fact, it is not working, Geometrian is right. The are no cast shadows on the colored image. And the point of view is the one from the light.
You are still missing the main view. The only texture on this sample is the shadow map, so you need to make it work.

I found a strange (but modern) example using shadow maps with GLSL.
It uses an external framework apparently, but the GL code seem here.
http://wiki.vrmedia.it/index.php?title=Shadow_Mapping

This, from the link at the bottom of the page, looks promising for the theory. http://www.cs.cmu.edu/afs/cs/academic/class/15462/web.06s/asst/project3/shadowmap/index.html

How should I modify the source I provided to make the shadows work?

So, like, it doesn’t crash. When I enable textures, it runs really slowly, but the shadow still looks the same. What, then is the point of them? In the course of another problem, I found that glReadPixels() in PyOpenGL (current version) returns the wrong type of data as opposed to the right one in the previous version. Is there an alternate function?

I think I’m onto something with this other tutorial:
http://www.paulsprojects.net/tutorials/smt/smt.html
I’ve translated it from the C++ it’s in to Python. I think that these lines don’t work:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL)
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY)

I see the torus and the spheres, but no shadow.