Jump to content
  • Advertisement
Sign in to follow this  
CNBABY

about glsl and shadow mapping .please hlep me

This topic is 4832 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

hello everybody, recently ,I am trying to get shadow mapping to work in my GLSL application.so i must send a shadowproj_matrix to set the position value of a vertex in the light space. now,i want a 3d object could moving in my scene and others couldn't .so they have different modelview matrix in the light space,and it will result different shadowproj_matrix. but in my shader,i just use only one shdowproj_matrix.if i move the 3d object in my application,it will produce wrong shadow. how can i do .could you help me?please.... Any help would be apreciated. please please............................................... [Edited by - CNBABY on August 21, 2005 1:24:50 AM]

Share this post


Link to post
Share on other sites
Advertisement
why,why,why.why nobody?
may be i couldn't describe it clearly.if you don't understand my question ,please tell me.
i think that you just understand shadow mapping ,may be you could help me!
please.

Share this post


Link to post
Share on other sites
Quote:
moving in my scene and others couldn't .so they have different modelview matrix in the light space,and it will result different shadowproj_matrix

u want a different shadowmap matrix per light wether or not the shapes are moving or not is irrelevant

Share this post


Link to post
Share on other sites
i just have one light.so just one shadow map(depth map).
shadowmap matrix =project_matrix*modelview_matrix
i want use my mouse to control the object to rotate or shift,but other object ,for example floor and wall,hold in line.then they have different modelview_matrix.
if i use the modelview_matrix of floor to compute shadowmap matrix,the moving object get the wrong position value in the light space,if i use the modelview_matrix of the moving object,the floor get the wrong position value in the light space.anyway,get the wrong shadow information.


my vertex shader

varying float Diffuse;
varying vec4 frag_positon;
uniform vec3 LightDirection;

void main(void)
{
vec3 realNorm = gl_NormalMatrix * gl_Normal;
Diffuse = max(dot(-LightDirection, realNorm), 0.0);
TexCoord = gl_MultiTexCoord0;
frag_positon = gl_Vertex;
gl_Position = ftransform();
}

my fragment shader
uniform sampler2D Checker;
uniform sampler2DShadow ShadowMap;
uniform mat4 shadow_matrix;

varying vec4 frag_position;
varying float Diffuse;
varying vec2 TexCoord;

void main (void)
{
vec4 ProjShadow= shadowmap_matrix * frag_positon;//get the fragment position in the light space

vec3 color = texture2D(Checker, TexCoord).stp;
color *= shadow2DProj(ShadowMap, ProjShadow).r;
color *= Diffuse;
gl_FragColor = vec4(color, 1);
}

ok


Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!