Shadow projection mapping - ATI clamp bug & how to blur shadow

Hi,

Been working on getting basic shadow projection mapping working. The results so far have been good. It works great on my GF2, but my Radeon9800 exhibits issues with clamping the shadow texture to stop it repeating.

You can see the bug here http://www.noisecrime.com/temp/radeonbug.jpg
What i’ve done is add a spotlight texture mask in the camera that renders the light POV. This means the edges of the texture should all be black. But no matter what I try on the Radeon outside the texture area is not black but grey.

I’ve tried using CL_CLAMP, GL_CLAMP_EDGE, and numerous other things with no success. I was wondering about GL_BORDER, but not sure how to set that up correctly.

If I remove the spotlight mask, so the edges of the texture are white, then all is well, and whilst I imagine this is how i’d used Shaodw mapping most of the time, i’d still like to be able to do the spotlight effect.

Was wondering if there is something i’m missing?

I would also like to be able to blur the shadow texture before its rendered but unsure how to go about this. Let me explain.

I set up the shadow scene (white background, black models), and place the camera at the POV of the light. I render this into the viewport. I then do
glBindTexture(GL_TEXTURE_2D, tTargetID);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, tWidth, tWidth, 0);
to place the rendered shadow view into a texture without mipmapping.

After which I clear the viewport and render the real scene, where I use mutli-texturing to apply the shadow texture over the scenery models.

So I’d like to somehow blur the openGL shadow texture but i’m not sure of the best approach. I doubt using openGL’s pixel functions are a good idea, but can’t think of anything else. I’d appricate some ideas.

thanks

Doh!
Don’t you just love it when immediately after posting you have a blinding flash of inspiration

Fixed the clamping issue. I was looking in the wrong place, it had nothing to do with the clamping of the shadow rendered texture. Instead it was becuase the spotlight mask I used had mipmapping, which caused its edges to go to grey, hence getting grey edges in the shadow texture!

So one problem fixed. Still been interested in any ideas for blurring the shadow texture though.

Thanks

The mipmapping case is exactly why GL_CLAMP_TO_BORDER should be used. Just set the border color to black and call it good.

GLfloat color_black[4] = {0.0, 0.0, 0.0, 1.0};
glTexParameteri( GL_TEXTURE_2D, GL_TEXUTRE_WRAP_S, GL_CLAMP_TO_BORDER );
glTexParameteri( GL_TEXTURE_2D, GL_TEXUTRE_WRAP_T, GL_CLAMP_TO_BORDER );
glTexParameterfv( GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, color_black );