Question

I can't figure out the problem, but may be the problem with either blending or depth-testing.

The blending function i'm using is

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

These are the output without glDepthFunc functions

Getting this as output Output

enter image description here

This should be like this

Was it helpful?

Solution

The clear color that shows through is indicative that it draw the stem of the stawberry first, followed by the berry itself. As a rule of thumb, you should render opaque surfaces, before semi-opaque surfaces, the leafs of the stem are semi-opaque (the leafs are not actual polygons). While you draw you have the depth-buffer enabled. This causes fragments of bery to be rejected on the grounds that the 'translucent' fragments of leaf/stem are already drawn (and closer to the camera/view).

Changing the order around is a simple step to stop it from producing the illustrated artifact, because the fragments of the objects with the 'furtest' depth are rendered before the fragments with the 'nearest' depth. In other words, the depth buffer causes the fragments to be accepted, instead of rejected.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top