You are not logged in.

#1 2012-01-01 12:18:42

wilco2009
Member

Using specular lights with textured objects

I'm trying to use a specular light with a textured object and I get a crazy black&white image. If I use the same object but without textures, specular light works as expected.

Somebody knows what could be wrong.

My code as follows:

Code:

       GRRLIB_SetLightSpot(1, (guVector){ 5.0f, 0.8f, 0 }, (guVector){  0.0f, 0.0f, cubeZ }, -4.0f, 5.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0xFFFFFFFF);

        GRRLIB_3dMode(0.1,1000,45,1,1);
        GRRLIB_ObjectView(0,0,cubeZ, a,a*2,a*3,2,2,2);
        
       GRRLIB_SetTexture(tex_girl,0);
    GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
        // cara trasera
        // coordenada x de textura se aplica sobre la coordenada x del poligono
        // coordenada y de textura se aplica sobre la coordenada y del poligono
        GX_Position3f32(-0.5f,+0.5f,-0.5f);
        GX_Normal3f32(+0.0,+0.0,-1.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(-0.5f,-0.5f,-0.5f);
        GX_Normal3f32(+0.0,+0.0,-1.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(+0.5f,-0.5f,-0.5f);
        GX_Normal3f32(+0.0,+0.0,-1.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32(+0.5f,+0.5f,-0.5f);
        GX_Normal3f32(+0.0,+0.0,-1.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,1.0f);

        // cara delantera
        // coordenada x de textura se aplica sobre la coordenada x del poligono
        // coordenada y de textura se aplica sobre la coordenada y del poligono
        GX_Position3f32(-0.5f,+0.5f,+0.5f);
        GX_Normal3f32(+0.0,+0.0,+1.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(+0.5f,+0.5f,+0.5f);
        GX_Normal3f32(+0.0,+0.0,+1.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(+0.5f,-0.5f,+0.5f);
        GX_Normal3f32(+0.0,+0.0,+1.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32(-0.5f,-0.5f,+0.5f);
        GX_Normal3f32(+0.0,+0.0,+1.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,1.0f);

        // cara superior
        // coordenada x de textura se aplica sobre la coordenada x del poligono
        // coordenada y de textura se aplica sobre la coordenada z del poligono
        GX_Position3f32(-0.5f,+0.5f,+0.5f);
        GX_Normal3f32(+0.0,+1.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(+0.5f,+0.5f,+0.5f);
        GX_Normal3f32(+0.0,+1.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(+0.5f,+0.5f,-0.5f);
        GX_Normal3f32(+0.0,+1.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32(-0.5f,+0.5f,-0.5f);
        GX_Normal3f32(+0.0,+1.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,1.0f);

        // cara inferior
        // coordenada x de textura se aplica sobre la coordenada x del poligono
        // coordenada y de textura se aplica sobre la coordenada z del poligono
        GX_Position3f32(-0.5f,-0.5f,+0.5f);
        GX_Normal3f32(+0.0,-1.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(+0.5f,-0.5f,+0.5f);
        GX_Normal3f32(+0.0,-1.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(+0.5f,-0.5f,-0.5f);
        GX_Normal3f32(+0.0,-1.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32(-0.5f,-0.5f,-0.5f);
        GX_Normal3f32(+0.0,-1.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,1.0f);
            
        // cara izquierda
        // coordenada x de textura se aplica sobre la coordenada z del poligono
        // coordenada y de textura se aplica sobre la coordenada y del poligono
        GX_Position3f32(-0.5f,+0.5f,+0.5f);
        GX_Normal3f32(-1.0,+0.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(-0.5f,+0.5f,-0.5f);
        GX_Normal3f32(-1.0,+0.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(-0.5f,-0.5f,-0.5f);
        GX_Normal3f32(-1.0,+0.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32(-0.5f,-0.5f,+0.5f);
        GX_Normal3f32(-1.0,+0.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,1.0f);

        // cara derecha
        // coordenada x de textura se aplica sobre la coordenada z del poligono
        // coordenada y de textura se aplica sobre la coordenada y del poligono
        GX_Position3f32(+0.5f,+0.5f,+0.5f);
        GX_Normal3f32(+1.0,+0.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,0.0f);
        GX_Position3f32(+0.5f,+0.5f,-0.5f);
        GX_Normal3f32(+1.0,+0.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,0.0f);
        GX_Position3f32(+0.5f,-0.5f,-0.5f);
        GX_Normal3f32(+1.0,+0.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(1.0f,1.0f);
        GX_Position3f32(+0.5f,-0.5f,+0.5f);
        GX_Normal3f32(+1.0,+0.0,+0.0);
        GX_Color1u32(col);
        GX_TexCoord2f32(0.0f,1.0f);
    GX_End();

Last edited by wilco2009 (2012-01-01 12:19:57)

Offline

 

#2 2012-01-09 14:03:25

NoNameNo
Administrator

Re: Using specular lights with textured objects

hi,

i already talk to shagkur about specular bug :

http://devkitpro.org/viewtopic.php?f=7&t=1933

Offline

 

Board footer

Powered by FluxBB