Sign in to follow this  

fragment shader messes up blending (?)

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

This topic is 4198 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this