Jump to content
  • Advertisement
Sign in to follow this  

Blending two textures ( depth map with a alpha map )

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

Hey, This is the situation, I have a tree with a foliage texture, and i have the depth shadowmap of that tree. I want to do self shadowing with the tree itself, so i want to apply the shadowmap only where the alpha test passes in the foliage texture. I think this should be working, but it ins't, tex0 has the shadowmap, tex1 has the foliage alpha map texture This is my vertex shader : varying vec4 projCoord; void main() { vec4 realPos = gl_ModelViewMatrix * gl_Vertex; projCoord = gl_TextureMatrix[0] * realPos; gl_TexCoord[1] = gl_MultiTexCoord1; gl_Position = ftransform(); } This is my fragment shader : uniform sampler2DShadow shadowMap; uniform sampler2D textureMap; varying vec4 projCoord; void main () { const float kTransparency = 0.3; vec4 color = tex2D(textureMap, gl_TexCoord[1].xy); //alpha map vec3 shadowUV = projCoord.xyz / projCoord.q; float mapScale = 1.0 / 2048.0; vec4 shadowColor = shadow2D(shadowMap, shadowUV); if(shadowUV.x >= 0.0 && shadowUV.y >= 0.0 && shadowUV.x <= 1.0 && shadowUV.y <= 1.0 && color.w >= 0) { gl_FragColor = color * shadowColor; } else { discard; } } Both texture units are set. Am i doing anything wrong here ? thanks, Bruno

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!