Sign in to follow this  
stringa

ShadowMapping + FBO troubles : Crosspost in OpenGL Forum

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
Guest
This topic is now closed to further replies.
Sign in to follow this