Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL glBlendFuncSeparate
    primarykey
    data
    text
    <p>I need some help with OpenGL textures masking. I have it working but need to find some other blending function parameters to work in other way. Now I have:</p> <pre><code>//Background ...code... glBlendFunc(GL_ONE, GL_ZERO); ...code //Mask ...code... glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_DST_COLOR, GL_ZERO); ...code... //Foreground ...code glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA); ...code </code></pre> <p>Now it sets foreground's opacity to 0 (fills with background texture) where mask is transparent. I need it to react to mask's colors. I mean something like setting foregrounds opacity depending on mask's color. For example if mask is black (0.0,0.0,0.0) then the opacity of that place in foreground is 0 (is filled with background), and if mask is white (1.0,1.0,1.0) then the opacity of foreground is 1 (not filled with background). It can be in reverse consequence (white = opacity 0, black = opacity 1). I just need it to work depending on color.</p> <p>My current result's visualization bellow.</p> <hr> <p>Background:<br> <img src="https://i.stack.imgur.com/hJIWh.png" alt="enter image description here"></p> <p>Mask (circle is transparent):<br> <img src="https://i.stack.imgur.com/ELd1J.png" alt="enter image description here"></p> <p>Foreground:<br> <img src="https://i.stack.imgur.com/pMEWt.png" alt="enter image description here"></p> <p>Result:<br> <img src="https://i.stack.imgur.com/bI1Eb.png" alt="enter image description here"></p> <hr> <p>And I want it to work like this:</p> <p>Background:<br> <img src="https://i.stack.imgur.com/hJIWh.png" alt="enter image description here"></p> <p>Mask (circle is white, background is black):<br> <img src="https://i.stack.imgur.com/ELd1J.png" alt="enter image description here"></p> <p>Foreground:<br> <img src="https://i.stack.imgur.com/pMEWt.png" alt="enter image description here"></p> <p>Result:<br> <img src="https://i.stack.imgur.com/bI1Eb.png" alt="enter image description here"></p> <hr> <p>So that later it could be used like this:</p> <p>Background:<br> <img src="https://i.stack.imgur.com/hJIWh.png" alt="enter image description here"></p> <p>Mask (circle is white, background is black):<br> <img src="https://i.stack.imgur.com/M8vaz.png" alt="enter image description here"></p> <p>Foreground:<br> <img src="https://i.stack.imgur.com/pMEWt.png" alt="enter image description here"></p> <p>Result:<br> <img src="https://i.stack.imgur.com/qJGnM.png" alt="enter image description here"></p> <hr> <p>Attempt with @Gigi solution:<br> <img src="https://i.stack.imgur.com/4bIXc.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload