开发者

OpenGL Blending problem with transparent skybox + transparent heightmap

Here's my problem.

I'm rendering an orthogonal quad (filling the viewport) before everything (with vertex coloring at each corner), right after I'm rendering a cube skybox with 6 transparent polygons (GL_BLEND, source GL_ONE, dest GL_ONE). That works perfectly, the skybox is half-colored by the underneath quad and half-colored by it's own UV mapped textures.

The problem comes when I add the height-map (GL_BLEND, GL_ONE, ...) The height map blends with the skybox under + with the quad.

What I want is the height map to be blended with the ortho quad but not with the skybox. I don't want to see the skybox through the height map.

I'm sure there's another way for doing this.

Is it possible to render the ortho quad first and th开发者_高级运维e skybox (like it's now) THEN the height map with a special blending that substract the skybox but not the ortho quad with some kind of multipass blending ?

Thank you very much !

Dimitri


Your glBlendFunc with GL_ONE, GL_ONE is called additive blending, and has the nice property (like any addition) to be commutative, that is to say A+B = B+A.

You could then draw your things in the other order, and your blending would give the same result.

In your case, you could draw your height map, and your skybox, without blending ; then your fullscreen quad with blending.

To prevent the height map and skybox to overlap, you could either :

  • draw your skybox first, and then your height map
  • draw the other way around, with GL_DEPTH_TEST enabled to let the Z buffer sort the pixels visibility for you

Hope this helps


OpenGL is no a scene graph, so after each rendering step all further commands on all the existing contents. glBlendFunc(GL_ONE, GL_ONE); doesn't sound right anyway, unless you really want to add the values. I think you're looking for glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜