Sign in to follow this  
Sijmen

Alpha blending artefacts (images)

Recommended Posts

I'm trying out alpha blending with my terrain renderer. The scene is composed of 3 layers of terrain, with increasing alpha values (=decreasing opacity). However, it doesn't entirely work: Look somewhat right from the center of the image, and at the center right. There are two 'hilltops' that for some reason shine through. I have no idea where that is coming from. This is how the scene is set up: This is how I set up the blending:
gl.glEnable(GL.GL_DEPTH_TEST);
gl.glEnable(GL.GL_BLEND);

gl.glDepthFunc(GL.GL_LEQUAL);		
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);
The layers are drawn back-to-front. Any ideas on what the problem could be?

Share this post


Link to post
Share on other sites
Try disabling your depth test. If the zbuffer is on then it will not render pixels under your transparant objects which will result in alpha not really working as expected.

Share this post


Link to post
Share on other sites
Also, 66+33 is 99%. The 2nd layer will have 99% opacity since blending is additive. (Notice how the 3rd layer's opacity and the 2nd layer's opacity is the same)

Set the alpha levels to 33% on all of the layers, along with either disabling depth, or rendering back objects first then front ones, that should get it to work.

Regards,
DarkProphet

Share this post


Link to post
Share on other sites
Set the opacity to 33%, and it all looks good now:



The front layer, as an exception, has an opacity of 100% because we want that one to always be clearly visible.

Thanks for all the kind help!

Share this post


Link to post
Share on other sites

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