Sign in to follow this  
stringa

ShadowMapping + FBO troubles

Recommended Posts

So, I finally got shadow mapping working like I wanted it to, but all the shadows look blocky... I currently have a 512 x 512 screen, I figured that if i render to a 2048 x 2048 texture, that they wouldn't look so blocky. I think I may be misunderstanding something... Here's what I'm doing... 1) Render Depth Values to the FBO 2) Setup Texture/Shadow Matrix and Shadow Shader 3) Run the Shader on the terrain The Shaders Vert Shader

void main(void)
{
	gl_Position = ftransform();
	
	gl_TexCoord[0] =  gl_TextureMatrix[1] * gl_Vertex;
	
	gl_TexCoord[1] = gl_MultiTexCoord0;
	
}

Frag Shader
uniform sampler2DShadow depth_texture;
uniform sampler2D model_texture;

const float ratio = 1.0 / 2048.0;

void main()
{
	vec4 result = vec4(1.0f, 0.0f, 0.0f, 0.0f); 
	
	vec4 model_color = texture2D(model_texture, gl_TexCoord[1].st );
	
        // This will fix the placement of the shadow
        // gl_TexCoord[0].xyz *= (512 / 2048 )

	result = shadow2DProj( depth_texture, gl_TexCoord[0] );
	
	gl_FragColor =  result * model_color ;
	
}






As stated above, if i use the commented line, that will fix the placement of the shadow to where it should actually be projected. As I said, currently the shadows are not placed in the correct position. I will fix the shadows with some extra sampling once if figure out how to fix the blocky nature of the current technique... Thanks for any help in advance stringa

Share this post


Link to post
Share on other sites
I'm hoping someone can correct me on this, but when rendering to a texture with the viewport set at say 2048x2048, clipping outside of the screen size will occur (no good when the user is running at say 1280x1024, or even mine maxed out at 1680x1050). Can anyone point out what to do in this case? Perhaps 'stitch' lots of 512x512 textures together? But surely that would be slow.

Btw OP, my shadowmaps are the old 3-pass method...perhaps things have evolved with FBOs ;)

Share this post


Link to post
Share on other sites
Quote:
Original post by jezham
I'm hoping someone can correct me on this, but when rendering to a texture with the viewport set at say 2048x2048, clipping outside of the screen size will occur (no good when the user is running at say 1280x1024, or even mine maxed out at 1680x1050).

No, it won't clip. FBOs are completely independent of the screen resolution. That's their entire point - they are offscreen surfaces, after all.

stringa: You left out the most important part: what's in gl_TextureMatrix[1] ? Post the code you used to generate that matrix.

Share this post


Link to post
Share on other sites
Quote:
Original post by jezham
I'm hoping someone can correct me on this, but when rendering to a texture with the viewport set at say 2048x2048, clipping outside of the screen size will occur (no good when the user is running at say 1280x1024, or even mine maxed out at 1680x1050). Can anyone point out what to do in this case? Perhaps 'stitch' lots of 512x512 textures together? But surely that would be slow.

Btw OP, my shadowmaps are the old 3-pass method...perhaps things have evolved with FBOs ;)


Hey jezham, I use FBO with cascading shadowmapping and I have run 4096x4096 hell even up to 8192x8192 and never had a problem, again this is on a GF8800. FBO's are the cat's ass when it comes to RTT anymore. Use them, know the force Luke! ;)

Share this post


Link to post
Share on other sites
Cool these FBOs are just what I need! Didn't think my 'early' X800 could handle them as it fails with sooo much, but looking good cheers all :) (and yes I'm upgrading very soon)

Glad part of my suggestion was helpful, I was feeling like an old school n00b!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this