Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualtonemgub

Posted 11 April 2014 - 11:05 AM

It appears you're already using alpha-blending on the surface you want to "cut" with the "hole" texture. In order to add the "hole", you can use multi-texturing. Here's a simple OpenGL tutorial: http://www.clockworkcoders.com/oglsl/tutorial8.htm . In addition to what is explained there, you will also have to add a certain offset and a scale to the texture coordinates of the second texture (e.g., (gl_TexCoord[1] + offset) * scale), which is the position where you want the "hole" to appear, and the "size" of the hole (etc., etc.), and clamp the result to [0,1] (or was it [-1, 1] for OpenGL?), or use the "clamp" texture-addressing mode (this is what it's called in D3D - I don't know if OpenGL has it or what it's called).

 

You will also have to modify the gl_FragColor returned from the Fragment Program/Shader to something like this: gl_FragColor = texval1 * texval2; (just an "off the top of my head" example - if it doesn't work, try tweaking only the alpha value from texval1, with the average of the r, g and b values from texval2. etc... depends on the color format of your second texture).


#1tonemgub

Posted 11 April 2014 - 10:58 AM

It appears you're already using alpha-blending on the surface you want to "cut" with the "hole" texture. In order to add the "hole", you can use multi-texturing. Here's a simple OpenGL tutorial: http://www.clockworkcoders.com/oglsl/tutorial8.htm . In addition to what is explained there, you will also have to add a certain offset and a scale to the texture coordinates of the second texture (e.g., (gl_TexCoord[1] + offset) * scale), which is the position where you want the "hole" to appear, and the "size" of the hole (etc., etc.), and clamp the result to [0,1] (or was it [-1, 1] for OpenGL?), or use the "clamp" texture-addressing mode (this is what it's called in D3D - I don't know if OpenGL has it or what it's called).


PARTNERS