Apply texture with separate alpha mask

Started by
6 comments, last by V-man 14 years, 1 month ago
I've got a texture which looks ok but I also have a second texture which is meant to overlay the first to give it some 'depth'. The 1st texture is a full colour 'picture', the 2nd is just shades of grey. I've been back and forth through the Red book to no avail. Anyone got a clue I could use!? Thanks. [Edited by - FlyingSolo on February 22, 2010 7:46:56 PM]
Advertisement
Have you considered writing a shader to handle this? I'm not sure what functionality exists in plain openGL to achieve that effect, but with a shader I think that should be trivial (and a good learning exercise).

Also are you talking about an alpha map or a depth map? I think alpha channel is typically considered to be a transparency channel, but you sound like you are talking about a depth map or bump map.

If you just start flipping through a few GLSL articles you should be able to work it out I think.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game

I need to keep this as compatible as I can with old opengl so sadly, shaders are out.

The effect this 'mask' gives is one of light and dark areas (shadows) - if that helps !?
What exactly do you want to do? What does it look like mathematically?
(For the RGB and ALPHA)
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
They say a picture is worth a thousand words...

Looky here: www.aerobits.org/shade

the 'mask' image gives the center of the instrument some shading which gives the illusion that it's a sphere - like the real thing.

I've piddled about with blendfunc all evening and can't crack it.

Anyone?
How about multitexturing? I have never used it myself but it seems appropriate for your use:
http://jerome.jouvie.free.fr/OpenGl/Tutorials/Tutorial22.php
In graphics, a equation is worth more than a picture :)

A quick tought is use multitexturing (no blending required) and multiply (GL_MODULATE) both texture colors.
My guess is you need to multiply the texels together so my guess is GL_MODULATE for GL_TEXTURE0 and GL_TEXTURE1.
glActivateTexture(GL_TEXTURE0);
glTexEnv(........GL_MODULATE);
glActivateTexture(GL_TEXTURE1);
glTexEnv(........GL_MODULATE);
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement