Jump to content
  • Advertisement
Sign in to follow this  
DJLink

problem with glBlendFunc, 2d soft shadows, difference between ATI/NVIDIA Cards

This topic is 2333 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 there. I'm having this weird problem.
I've been working on some 2d soft shadows. It works ok on several ATI cards, tested on 4 different models so far.

But on NVIDIA (3 different models) it behaves differently

So first here's the problem

[attachment=7917:problem_ati_nvidia.png]

Here's how I'm doing it


//BeginDraw
//
// accumulate lighting in a texture
//
glClearColor(0.1f,0.1f,0.1f,0.0f);
// Set viewport to texture size
glViewport(0,0,512,512);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//loop all lights
glColorMask(false, false, false, true);
glClear(GL_COLOR_BUFFER_BIT);
// write shadow volumes to alpha
glBlendFunc(GL_ONE, GL_ONE);
glDisable(GL_TEXTURE_2D);

// Here I draw all the shadows projections
for (bsSize b = 0; b<_lightBlockers.size(); ++b)
{
renderShadow(light, _lightBlockers);
}

//// draw light
glColorMask(true, true, true, false);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE); // <--- I think this might be the problem
// Switching to glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); results in the image below this code
// I draw a quad with the light texture
//end loop lights

//
// copy lighting into a texture
//
glBindTexture(GL_TEXTURE_2D, texID);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 0, 0, 512, 512, 0);
// apply lighting by rending light texture on top
//
glBlendFunc(GL_DST_COLOR, GL_ZERO);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,texID);
// Simple quad drawing with the texture


However, switching to glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE); to glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);
gives me the same result on both cards, but obviously I don't want that effect, it's ugly :P

[attachment=7918:problem_ati_nvidia2.png]

Can anyone help me out?

Thanks

Share this post


Link to post
Share on other sites
Advertisement

Hmm... did you check if you really render to a RGBA target ?


Hum...I'm creating the context using SDL so I'm kind of lost on how to assure that, maybe I'll check on an SDL specific forum. Thanks

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!