Jump to content
  • Advertisement
Sign in to follow this  
outKast

fragment shader messes up blending (?)

This topic is 4451 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 all. I'm having some problems with blending working with a simple pass-color fragment shader applied. Without fragment shader everything looks fine, but after enabling the shader, blending no longer works. From what I understand, blending is done after the fragment shader runs, so what's going on here? Here is the code of the shader, as basic as it can be I guess: !!ARBfp1.0 MOV result.color, fragment.color.primary; END and this is the code for drawing one frame:
{
	if (shaders)
	{
		glEnable (GL_FRAGMENT_PROGRAM_ARB);
		glBindProgramARB (GL_FRAGMENT_PROGRAM_ARB, fprog);
	}

	bugle_draw_cube (90);

	glEnable (GL_BLEND);
	glBlendFunc (GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
	bugle_draw_cube (150);
	glDisable (GL_BLEND);

	if (shaders)
		glDisable (GL_FRAGMENT_PROGRAM_ARB);
}

First it draws a small cube without blending, and then a bigger one with blending. The results are as seen on these screenshots (with the shader applied, second cube is fully opaque): without shader (correct) with shader (incorrect) If anyone's interested in looking at the full source code: demo.c (tar.bz2) Everything else with shaders works as expected on my setup. Am I forgetting about something here? Any help would be really appreciated. Paul

Share this post


Link to post
Share on other sites
Advertisement
have u disable depthwrites (perhaps )
also try a different alpha color value eg glColor4f(1,1,1,0.5);

Share this post


Link to post
Share on other sites
Thanks. I've tried this, as many other things, even though this shouldn't make shaders/noshaders results look different. Can someone confirm that the results should be identical? Or test the source and see if the results are same as here? (written for linux, needs sdl) I don't understand why this simple case doesn't work.

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!