• Advertisement
Sign in to follow this  

Shadowmaps with fragment and vertex programs?

This topic is 4835 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am wondering is it possible to make a shadowmap completely in a fragment and vertex program without using glTexGen at all? If so does anyone know of a good tutorial on such a topic? Most tutorials I see are for FFP coding with glTexGen. Also I am going to assume this method would be faster due to its computed by the GPU? Thanks

Share this post


Link to post
Share on other sites
Advertisement
yes one possible way in glsl would be

--vertex shader--
projected_coord = gl_TextureMatrix[0] * gl_Vertex;


fragement shader--
uniform sampler2DShadow tex3;
vec4 shadow = shadow2DProj( tex3, projected_coord );


gl_TextureMatrix[0] is supplied with the stanadrad lightprojection matrix * lightmodelview matrix

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
yes one possible way in glsl would be

--vertex shader--
projected_coord = gl_TextureMatrix[0] * gl_Vertex;


fragement shader--
uniform sampler2DShadow tex3;
vec4 shadow = shadow2DProj( tex3, projected_coord );


gl_TextureMatrix[0] is supplied with the stanadrad lightprojection matrix * lightmodelview matrix


Thanks zedeek, but as of now I only have access to fragment program and vertex program. And I have a lot of my texturing and lighting done in a fragment program and dont' want to move it over to Glslang right now. I am assuming the shadow2DProj() is a built in function of GLSlang? Thanks again.

Share this post


Link to post
Share on other sites
its just a function which performs a texture lookup allowing for projection, i'm sure that the fragment program interface has the same thing

btw, you have to scale/bias the texture matrix/lookup as well or it will go wonky (you need the vertex to be in the range 0 -> 1 however post transform by the matrix the vertex can be in the range -1 => 1) so you need to add 1 and multiply by 0.5.

You should be able to compress that all down into the texture matrix, however I never got around to doing that myself, i might go back and look at it again this weekend...

Share this post


Link to post
Share on other sites
Quote:
Original post by _the_phantom_
its just a function which performs a texture lookup allowing for projection, i'm sure that the fragment program interface has the same thing

btw, you have to scale/bias the texture matrix/lookup as well or it will go wonky (you need the vertex to be in the range 0 -> 1 however post transform by the matrix the vertex can be in the range -1 => 1) so you need to add 1 and multiply by 0.5.

You should be able to compress that all down into the texture matrix, however I never got around to doing that myself, i might go back and look at it again this weekend...


Hey Phantom if you would I would appreciate it a lot. I am looking at doing the shadowmap totally with vertex/fragment program and not using any FFP code...

If it would be ok I would like to email you?

Thanks

Share this post


Link to post
Share on other sites
Also would I need to use two passes with a VP/FP like with FFP? As of now my FP uses seven texture units? so unless I can access more than eight I am thinking I will have to use two passes two add a shadowmap to my eight texture unit in my final FP? Thanks

Share this post


Link to post
Share on other sites
yes, you will, because the first pass is still required to construct the shadow map for later useage.

I'll see if I can get around to sorting out the matrix stuff later today...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement