hello,

I would like to apply a lighting effect has a cube by using the GDI and the API as in this example:

EDIT: trainer URL removed

I already have program the rotation of the cube, but I have problem to apply the light by using the lambert-shading method there asm.

Thank you for your reponses

I would like to apply a lighting effect has a cube by using the GDI and the API as in this example:

EDIT: trainer URL removed

I already have program the rotation of the cube, but I have problem to apply the light by using the lambert-shading method there asm.

Thank you for your reponses

Do you

There's a lot of information about various shading models out there on the net, source code as well as math and more "human" descriptions as well.

**understand**lambert shading, do you**want to**understand it, or do you just want**ready-made code**?There's a lot of information about various shading models out there on the net, source code as well as math and more "human" descriptions as well.

eh? Why was the link to the example removed? :|

Wont that make it a lot harder for anyone trying to answer the question?

Wont that make it a lot harder for anyone trying to answer the question?

eh? Why was the link to the example removed? :|

Wont that make it a lot harder for anyone trying to answer the question?

The link was to a game trainer, which is at the edge of what we allow here. Besides, people who know about shading already know what shading is, and should be able to help anyway :)

For each of the 6 faces, compute the dot product (of their normal) against the normal vector of the (directional) light.

dot = ( a.x * b.x ) + ( a.y * b.y ) + ( a.z * b.z );

you can use the value of "dot" directly as "light intensity". Or you can arctan it for more correct results. For flat-shading, simply draw the cube's whole face in that color.

For gouraud shading, you take 8 vectors, instead of 6. Simple googling will lead you directly to the answers of such basic questions.

dot = ( a.x * b.x ) + ( a.y * b.y ) + ( a.z * b.z );

you can use the value of "dot" directly as "light intensity". Or you can arctan it for more correct results. For flat-shading, simply draw the cube's whole face in that color.

For gouraud shading, you take 8 vectors, instead of 6. Simple googling will lead you directly to the answers of such basic questions.

For each of the 6 faces, compute the dot product (of their normal) against the normal vector of the (directional) light.

dot = ( a.x * b.x ) + ( a.y * b.y ) + ( a.z * b.z );

you can use the value of "dot" directly as "light intensity". Or you can arctan it for more correct results. For flat-shading, simply draw the cube's whole face in that color.

For gouraud shading, you take 8 vectors, instead of 6. Simple googling will lead you directly to the answers of such basic questions.

I want to write phongshading with help of SSE, shouldnt RSQRTPS be perfect for phongshading?(it produces 1/sqrt)

SSE should be perfect for phongshading. Try first without the cos(angle) in the pixel-formula:

// code for scanline

foreach(pixel in the scanline){

vlen = sqrt(nx1 * nx1 + ny1 * ny1 + nz1 * nz1);

color = (light.x * nx1 + light.y * ny1 + light.z * nz1) / vlen;

if (color < 0) color = 0;

out_Blue = color * in_Blue;

out_Green= color * in_Green;

out_Red = color * in_Red;

nx1 += ix;

ny1 += iy;

nz1 += iz;

}

Ultrano, methinks you're preaching to the inverted..

Ultrano, methinks you're preaching to the inverted..

so I should take the name "THE reciprocal"? :)