thanks all,
but I’m not sure about this Alpha. To show you my problem more clearly, here is piece if my code (actually display() function):
void display()
{
glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
static float angle0=0.5f;
if(light_move)
angle0 += 0.01111f;
float position0[] = {sin(alpha0), cos(alpha0),1};
glLightfv(GL_LIGHT0, GL_POSITION, position0);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, bumpTex[0]);
glActiveTextureARB(GL_TEXTURE2_ARB);
glBindTexture(GL_TEXTURE_2D, bumpTex[1]);
glPushMatrix();
// parallax mapping
if(bump)
{
glEnable(GL_LIGHTING);
glEnable(GL_VERTEX_PROGRAM_ARB);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, vpid);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, fpid);
}
glActiveTextureARB(GL_TEXTURE0_ARB);
// here interpolation between different images using using blending is done
drawGeometry();
glPopMatrix();
if(bump)
{
glDisable(GL_VERTEX_PROGRAM_ARB);
glDisable(GL_FRAGMENT_PROGRAM_ARB);
glDisable(GL_LIGHTING);
}
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glutSwapBuffers();
glutPostRedisplay();
}
Finally I need to attach result of texture interpolation (produced by blending) to texture unit 0 (but how to do it???) and run following standard fragment program for parallax mapping. If I do it as above the parallax mapping works well but interpolation not :-(. If I set “bump=0” interpolation work well.
And may I ask you:
the result of the fragment program is written directly into framebuffer or to texture memory?
Thank you again for patience, I’m quite desperate already …
medva
Fragment program:
!!ARBfp1.0
PARAM light0color = state.light[0].diffuse;
PARAM light1color = state.light[1].diffuse;
PARAM ambient = state.lightmodel.ambient;
TEMP eyevects;
TEMP rgb, normal, height, temp, bump, total;
TEMP light0tsvec, light1tsvec;
TEMP newtexcoord;
# normalize tangent space eye vector
DP3 temp, fragment.texcoord[3], fragment.texcoord[3];
RSQ temp, temp.x;
MUL eyevects, fragment.texcoord[3], temp;
# calculate offset and new texture coordinate
TEX height, fragment.texcoord[0], texture[2], 2D;
MAD height, height, 0.04, -0.02; # scale and bias
MAD newtexcoord, height, eyevects, fragment.texcoord[0];
# get texture data
TEX rgb, newtexcoord, texture[0], 2D;
TEX normal, newtexcoord, texture[1], 2D;
# remove scale and bias from the normal map
MAD normal, normal, 2.0, -1.0;
# normalize the normal map
DP3 temp, normal, normal;
RSQ temp, temp.r;
MUL normal, normal, temp;
# normalize the light0 vector
DP3 temp, fragment.texcoord[1], fragment.texcoord[1];
RSQ temp, temp.x;
MUL light0tsvec, fragment.texcoord[1], temp;
# normal dot lightdir
DP3 bump, normal, light0tsvec;
# add light0 color
MUL_SAT total, bump, light0color;
# normalize the light1 vector
fragment.texcoord[2];
# add ambient lighting
ADD_SAT total, total, ambient;
# multiply by regular texture map color
MUL_SAT result.color, rgb, total;
END