Draw a coloured stencil mask
BlitzMax Forums/OpenGL Module/Draw a coloured stencil mask
| ||
Hey, I would like know, whether there is an easy-ish OpenGL way to do this. Here is an illustration of my problem: ![]() Please consider I want to avoid using shaders too. |
| ||
So you basically want to draw all colored pixels as white pixels? |
| ||
So you basically want to draw all colored pixels as white pixels? Not necessarily white, but uniform. Its for a secondary support buffer in a 2.5D game, where a pixel should identify the object occupying it by its color. |
| ||
Hmm. One way it so use the stencil buffer. Set it to draw to the stencil where there are accepted alpha values in your image, then use the stencil and draw a solid-color rectangle over the top of the sprite to fill it in. |
| ||
That seems like a rather good idea! So heres some pseudocode assembled from my understanding of your idea: 'Initialization '-------------- - Create Stencil Buffer - Clear Stencil Buffer 'Main Loop '--------- - For Each visible "Object" - Set Stencil Buffer drawing Mode to Alpha Stencil or something - Draw the Image of the "Object" (to the stencil buffer or straight to the backbuffer?) - Make the stencil buffer stenciling - set an FBO for the target buffer - Draw a rect with the individual color of "Object" - close the FBO - Clear the stencil buffer |