shadow mapping
BlitzMax Forums/OpenGL Module/shadow mapping
| ||
I've been playing around with code taken from the More Opengl Programming book. It mostly works but areas outside of the shadow map after projection are also shaded. Is this to be expected ? I'd be lying if I said I understand everything the code is doing although I get the general principle |
| ||
Are the extra shaded areas just the shadow map tiled? Is the texture clamped? Got a screeny? :) |
| ||
heres the code. I warn you now its not pretty. I have been trying to get it to work before prettying it up. Mind you the source was pretty messed up with huge amounts of remmed out code and stuff. Not very helpful. There are 3 main functions init, render and GenerateShadowmap. Render also includes some stuff for displaying the shadowmap(possibly not working correctly) and turning off shadows. It seems to me that the error is in Render() as the shadow map seems to be generated ok. I'm not expecting anyone to plough through the code and correct,although that would be nice, but some pointers would be helpful. |
| ||
Hi, You need to use GL_CLAMP_TO_EDGE like this: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)GL_CLAMP doesn't use the edge color on most graphics cards. Oh, and it looks cool :) Any way to smooth the edges of the shadow, without shaders? |
| ||
ahah thanks,so simple. you can increase the shadowmaptexture size but this will kill the framerate. Storing the texture on the card itself might help this I guess. Reducing the viewing frustum size in the shadow generation helps as well . |
| ||
Its a pity this runs so slow. Doesn't seem like it would be practical to implement in a game or whatever. |
| ||
didnt seem slow at all on my machine, nice work Kronos! @fredborg if you make the shadow map 512 instead of 128 its a lot smoother... |
| ||
And 16 times larger |
| ||
curious this seems to run quicker on my laptop than my pc |
| ||
The reason it's dreadfully slow is because you draw 16 times more quads for the ground than you need :) Also pushing quads to the graphics card like this is not exactly a fast solution. Use this instead: For Local i = -50 To 50 Step 20 For Local j = -50 To 50 Step 20 glBegin(GL_QUADS) glNormal3f(0,1,0) glVertex3f(i+10,0,j+10) glVertex3f(i-10,0,j+10) glVertex3f(i-10,0,j-10) glVertex3f(i+10,0,j-10) glEnd() Next NextYou used Step 5 instead of 20, meaning you had massive overdraws. Yes, I know you can use a higher texture resolution, but the shadow edges are still very blocky. |