OpenGL How to use a invisible mask to hide objects behind it -


i have opengl problem solve. have object/mesh a, object/mesh b , background texture c.

initially framebuffer filled background texture c. draw both & b in framebuffer. want keep object visible, , object b invisible.

in beginning, in front of b. during rotation, @ angle, b in front of based on depth test result, since b invisible, b's part should filled background c.

does know simple approach solve issue?

is stencil test approach? set object b color, compare color of b background c, , show background c when test fail.

does have sample code can read?

the easiest solution to:

  1. draw c;
  2. draw b colour mask preventing writes frame buffer (but don't touch depth mask, writes still made depth buffer);
  3. draw a, subject depth test.

the specific thing use glcolormask — if supply gl_false each channel via subsequent geometry won't write colour output. assuming haven't touched gldepthmask it'll still write depth output.

so, you've got code:

drawbackground(c); render(a); render(b); 

you'd adapt to:

drawbackground(c); glcolormask(gl_false, gl_false, gl_false, gl_false); render(b); glcolormask(gl_true, gl_true, gl_true, gl_true); render(a); 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -