Jump to content
  • Advertisement
Sign in to follow this  
Geometrian

Texture Blending

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

Hi, I finally have a working shadowmap implementation! Naturally, the next thing to do was to make it support multiple shadows from multiple lights. I took a stab at it and arrived at the following: I've color coded the two shadows to see them separately better. Unfortunately, they don't blend nicely together like they should. Here's some code:
glEnable(GL_TEXTURE_2D)
glEnable(GL_TEXTURE_GEN_S)
glEnable(GL_TEXTURE_GEN_T)
glEnable(GL_TEXTURE_GEN_R)
glEnable(GL_TEXTURE_GEN_Q)
#Evaluate where to draw shadows using ARB extension        
glBindTexture(GL_TEXTURE_2D, ShadowMap[0])
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)
glTexGenfv(GL_S, GL_EYE_PLANE, TextureMatrix[0])
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)
glTexGenfv(GL_T, GL_EYE_PLANE, TextureMatrix[1])
glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)
glTexGenfv(GL_R, GL_EYE_PLANE, TextureMatrix[2])
glTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR)
glTexGenfv(GL_Q, GL_EYE_PLANE, TextureMatrix[3])
#Enable shadow comparison
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB)
#Shadow comparison should be True (in shadow) if r > texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_GREATER)
#Shadow comparison should generate an INTENSITY result
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY)
#Set alpha test to discard false comparisons
glAlphaFunc(GL_EQUAL, 1.0)

Any way to get these to blend together? Thanks, G

Share this post


Link to post
Share on other sites
Advertisement
Nevermind, I figured it out. The key lines are:

glBlendFunc(GL_SRC_COLOR,GL_DST_COLOR)
glEnable(GL_BLEND)
#Draw with shadows
glDisable (GL_BLEND)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

Thanks, G

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!