Hi, is it possible to generate a surface and make it visible only within a 2d mask (b/w texture) with glBlend I suppose ? Can it be repeated x times : {1 surface + 1 application mask} x times with non overlapping masks. Then, what would be the best solution go get a blending effect with a background image which goal would be to keep only the shades of this 2d texture and make them appears into the surfaced textures (blend or shader..??).

tonyo_au

03-18-2013, 05:25 PM

If I understand you correctly you wish to create a mask from some geometry and use it to control texturing. If so yes you can but it requires a few steps.

step 1. Create an offset screen texture buffer
step 2. Clear this buffer to white
step 3 render your geometry in black to this buffer
step 4 render to screen with background image, foreground and mixing with the mask image ( you need a shader for this step)

openk3

03-18-2013, 06:07 PM

990

Thanks, well I've done a graphic it will be easier. The idea is to have a delimited zone MASK over a background picture (4) which is mainly a b/w picture with shades that I want to see on the final image. Texture (1) is deformed (2) thanks to a Bezier surface to simulate the volume of the background image (4). Then texture (3) (deformed, masked delimited) must be applied on top of (4) : shader or blend overlayer ? The only point would be to keep colors of (3) but get them darker from the shades of background image (4). I need an offset buffer I suppose so ? Shading (3) on (4) compels to have (3) beeing transparent ? I just manage to make the Bezier surface (2) and I'm trying to blend it on a black mask with glBlendFunc(GL_ONE_MINUS_DST_COLOR , GL_ZERO) on the scene but I get some black on the non masked parts and I have until now no texture buffer experience nor shader. Is it a long piece of work ?

tonyo_au

03-18-2013, 10:56 PM

Is it a long piece of work
Off screen render buffer are easy to create and use. I find shaders save a lot of time when I want to do something clever or a bit different. They don't take that long to learn and there are excellent tutorials on the web.

For what you have shown I would use slightly different logic to what I just described.

step 1 Create an off screen texture buffer
step 2 Clear the buffer to a background colour
step 3 render your Bezier surface with texture to this buffer
step 4 create a texture for your mask with the same dimensions as the render texture
step 5 render to screen the background image, texture buffer from step 3, blended using the mask image as the blend amount. (the shader instruction is called "mix" search on "glsl mix")