How to use NVs HILO textures for BM?

oops, yes, the texture setup should look like this:

tex0: normal map
tex1: nothing
tex2: lookup table
tex3: decal

Hmmm, I think there is something wrong with my vectors.
Because I don´t use Cubemap Normalisation, I have to normalize them myself (don´t use VertexPrograms).

Could you have a look, please.

For the lightvector:
// Light Vector berechnen (Light Position - Vertex Position)
Vector_3D_Subtract(fLightPosition_OS, fQuad_XYZ[i], fLightVector_OS);
// Light Vector normalisieren (nicht bei CM Normalisation)
Vector_3D_Normalize(fLightVector_OS);

// Light Vector per Tangent Matrix in Tangent Space umwandeln
Vector_3D_Matrix_3x3_Multiply(fLightVector_OS, fTangentMatrix[i], fLightVector_TS);

// scale and bias (stellt sicher, dass Farbwert zwischen 0 und 1 liegt - nicht bei CM Normalisation)
fLightVector_TS[0] = fLightVector_TS[0] * 0.5 + 0.5;
fLightVector_TS[1] = fLightVector_TS[1] * 0.5 + 0.5;
fLightVector_TS[2] = fLightVector_TS[2] * 0.5 + 0.5;

The stuff for the Half-Angle vector looks similar.

I´m sure, that the lookuptexture is correct and the normalmap is generated like you told me.

Here is a picture (only RGB Part - diffuse): http://Phil.Kaufmann.bei.t-online.de/OGL/wrong_result_TS.jpg

Here is a picture with the RCs and Cubemap Normalisation: http://Phil.Kaufmann.bei.t-online.de/OGL/good_result_RC.jpg

Diapolo

[This message has been edited by Diapolo (edited 01-29-2003).]

That looks more like a problem with the normal map than with the light/halfangle vectors. Can you post the code that you use to create the HILO normalmap?

Here is it.
It´s only hacked into the normal loading function, but it should do it.

GLshort *HILO = NULL;
HILO = new GLshort[(iWidth * iHeight * 2)];
GLshort * sip = HILO;

    for(int i = 0; i < iHeight; i++)
    {
        for(int j = 0; j < iWidth; j++)
        {
         	fread(&rgbTexComponents, sizeof(uRGB), 1 , FilePtr);
            memcpy(&Normalmap[iIndex], &rgbTexComponents, sizeof(uRGB));
            Normalmap[iIndex].mag = 255;

            *sip++ = (GLshort)(rgbTexComponents.glubRed * 32767);
            *sip++ = (GLshort)(rgbTexComponents.glubGreen * 32767);

            iIndex++;
        }
    }

But are you sure the Vector stuff is correct, too? Is scale and bias really needed?

Diapolo

That looks correct.

No, the scale+bias isn’t needed.

Are you putting the light and halfangle vectors into the appropriate texture coordinates?

*127 instead of *32767

Here are my TexCoords:

// decal
glMultiTexCoord2fvARB(GL_TEXTURE0_ARB, fQuad_ST[i]);
// normalmap
glMultiTexCoord2fvARB(GL_TEXTURE1_ARB, fQuad_ST[i]);
// L
glMultiTexCoord3fvARB(GL_TEXTURE2_ARB, fLightVector_TS);
// H
glMultiTexCoord3fvARB(GL_TEXTURE3_ARB, fHalfAngleVector_TS);

By the way, here an image with *127 and without the scale and bias (still wrong g):
http://Phil.Kaufmann.bei.t-online.de/OGL/wrong_result_2_TS.jpg

Diapolo

PS.: gettin crazy

Whats it look like with the normal map multiplied by 32767?

With 32767 and without the scale and bias it looks like that: http://Phil.Kaufmann.bei.t-online.de/OGL/wrong_result_3_TS.jpg

Here is a shoot of the diffuse lookup: http://Phil.Kaufmann.bei.t-online.de/OGL/diffuse_lookup.jpg

Here is a shoot of the specular lookup: http://Phil.Kaufmann.bei.t-online.de/OGL/specular_lookup.jpg

Here is the TS code:

glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, gluiBaseTexture);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, texobj);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE2_ARB);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_NV);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE1_ARB);

glActiveTextureARB(GL_TEXTURE3_ARB);
glBindTexture(GL_TEXTURE_2D, make_lookup_texture(128));
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_DOT_PRODUCT_TEXTURE_2D_NV);
glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE1_ARB);

And here the RC code for only outputting Tex3:

glCombinerParameteriNV(GL_NUM_GENERAL_COMBINERS_NV, 1);

glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_A_NV, GL_TEXTURE0_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glCombinerInputNV(GL_COMBINER0_NV, GL_RGB, GL_VARIABLE_B_NV, GL_TEXTURE3_ARB, GL_SIGNED_IDENTITY_NV, GL_RGB);
glCombinerOutputNV(GL_COMBINER0_NV, GL_RGB, GL_DISCARD_NV, GL_DISCARD_NV, GL_DISCARD_NV, GL_NONE, GL_NONE, GL_FALSE, GL_FALSE, GL_FALSE);

glFinalCombinerInputNV(GL_VARIABLE_A_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_C_NV, GL_ZERO, GL_UNSIGNED_IDENTITY_NV, GL_RGB);
glFinalCombinerInputNV(GL_VARIABLE_D_NV, GL_TEXTURE3_ARB, GL_UNSIGNED_IDENTITY_NV, GL_RGB);

Diapolo

[This message has been edited by Diapolo (edited 01-30-2003).]

What should the register combiner compute? You are discarding all three outputs.

kon

I only use the D variable in the final combiner, it should output the diffuse part of my lighting equation.

Diapolo

jra101?
Any new hints for me?

Diapolo

I’m not sure why this is failing for you, can you send me a zip of the source to your app so I can debug it and figure out whats going wrong?

I sent you an email .

Diapolo