🔒 Locked
Simultaneously Shadowmapping and Texturing
Advertisement
Original Post
Hi, The problem here is not shadowmapping nor texturing, but doing the two together. The shadowmapping algorithm I have renders to a texture (obviously) and uses the texture to make the shadows. It works in three passes--one to generate the appropriate texture matrix, one to render in light, and one to render in shadow. The problem arises when trying to combine the two. The shadowmapping works fine when using color materials, but it does not work at all if any of the occluding or shadowed objects are textured. (This means, by the way, that the program runs, I just don't see any shadows). My guess about this is that when the object's texture is bound to, the shadowmap is unbound. That means that the shadowmap is no longer available to be used for shadowing, so no shadows appear. So, what is a workaround to this? Thanks, G
Did you check your blending function?
Btw, if your problem is multi texturing (which I don't think it really is), you can use GL_ARB_multitexture to bind several textures.
Btw, if your problem is multi texturing (which I don't think it really is), you can use GL_ARB_multitexture to bind several textures.
Yes.
It is first set with: then disabled with:Here's what I get visually:

The demo draws that object shadowing the landscape. The fish texture is supposed to be mapped over the landscape itself, but instead, it is being used as a shadowmap, perhaps?
The object and light are moveable, and the light's view always centers closely around the object. Moving either moves the fishes over the map.
G
It is first set with:
glBlendFunc(GL_SRC_COLOR,GL_DST_COLOR)glEnable(GL_BLEND)glDisable(GL_BLEND)glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
The demo draws that object shadowing the landscape. The fish texture is supposed to be mapped over the landscape itself, but instead, it is being used as a shadowmap, perhaps?
The object and light are moveable, and the light's view always centers closely around the object. Moving either moves the fishes over the map.
G
I think you should set
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
before the blending.
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
before the blending.
That doesn't work either. Basically I see the same thing, but now the texture is darker (opaque).
Assuming the first texture is the diffuse map (actual texture), the second is the shadow map and you want the final color to be tex1 x tex2, you could use glBlendFunc(GL_DST_COLOR, GL_ZERO).
The blending equation is colorsource*factorsource+colordest*factordest so using factorsource = GL_DST_COLOR and factordest = GL_ZERO would result in the final color being multiplied with the shadow/light map (dark areas being the shadows).
The blending equation is colorsource*factorsource+colordest*factordest so using factorsource = GL_DST_COLOR and factordest = GL_ZERO would result in the final color being multiplied with the shadow/light map (dark areas being the shadows).
That doesn't work either--but again, I think the problem is using the shadowmap and the diffuse texture simultaneously. I need to have both going together. How do I do that?
Thanks,
-G
Thanks,
-G
Thank you.
As far as disabling textures for the shadowmap generation--I don't see how that is possible, as the shadowmap is itself a texture...
I think you're right about solving this with multitexturing. I think I can figure out how to work multitexturing into the shadowmapping algorithm if I knew how to do multitexturing. Anyone have good examples of multitexturing (not using shadowmapping)?
Thank you,
-G
As far as disabling textures for the shadowmap generation--I don't see how that is possible, as the shadowmap is itself a texture...
I think you're right about solving this with multitexturing. I think I can figure out how to work multitexturing into the shadowmapping algorithm if I knew how to do multitexturing. Anyone have good examples of multitexturing (not using shadowmapping)?
Thank you,
-G
it's quite simple, conceptually.
there are N texture units on your videocard (can use OpenGL primitives to enumearate them).
you can assign textures to them by using
glActiveTexture (GL_TEXTUREn); // change n with the texture unit number you want
glEnable (GL_TEXTURE_2D); // from here on it's the common texturing code you already know
...
In SM, the third pass is, usually, when you need multitexturing. I do it this way (pseudocode):
edit: I forgot mentioning you must specify your (multi)texture coordinates using glMultiTexCoord2f().
[Edited by - aresio on October 14, 2008 6:08:39 AM]
there are N texture units on your videocard (can use OpenGL primitives to enumearate them).
you can assign textures to them by using
glActiveTexture (GL_TEXTUREn); // change n with the texture unit number you want
glEnable (GL_TEXTURE_2D); // from here on it's the common texturing code you already know
...
In SM, the third pass is, usually, when you need multitexturing. I do it this way (pseudocode):
glAlphaFunc(GL_GREATER, 0.99f); glEnable(GL_ALPHA_TEST); activeTextureUnit(LAST_AVAILABLE_TEXTURE_UNIT);setupShadowMapTextures(); // tex genactiveTextureUnit(0); // can be anyone but LAST_AVAILABLE_TEXTURE_UNITsetupObjectsTextures();turnOnLights();drawPrimitives();edit: I forgot mentioning you must specify your (multi)texture coordinates using glMultiTexCoord2f().
[Edited by - aresio on October 14, 2008 6:08:39 AM]
I feel foolish. I can't seem to get it working. I don't really know how to implement the multitexturing at all in shadowmapping, although from the look of it, it should be simple.
I know people aren't very receptive to downloadable code, but I think the only way to fix this is to actually work with the code we're talking about. Here it is: http://www.geometrian.com/1.5.2.zip. The shadow file is "10 -- ShadowExample.py" and the shadow functions file is "OpenGLLibrary/glLibShadow.py"
Please have a look at this; I think it will make discussions much easier.
Thank you so very much,
Geometrian
I know people aren't very receptive to downloadable code, but I think the only way to fix this is to actually work with the code we're talking about. Here it is: http://www.geometrian.com/1.5.2.zip. The shadow file is "10 -- ShadowExample.py" and the shadow functions file is "OpenGLLibrary/glLibShadow.py"
Please have a look at this; I think it will make discussions much easier.
Thank you so very much,
Geometrian
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement