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.

Posted on 2006-10-04 08:59:23 by tomart2005
Do you 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.
Posted on 2006-10-04 09:21:56 by f0dder
eh? Why was the link to the example removed? :|
Wont that make it a lot harder for anyone trying to answer the question?
Posted on 2006-10-04 09:45:26 by Nice Eddie

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 :)
Posted on 2006-10-04 10:02:10 by f0dder
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.
Posted on 2006-10-04 13:30:28 by Ultrano

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)

Posted on 2006-10-05 02:24:10 by daydreamer
SSE should be perfect for phongshading. Try first without the cos(angle) in the pixel-formula:

``// code for scanlineforeach(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;}``

Posted on 2006-10-05 08:25:39 by Ultrano
Ultrano, methinks you're preaching to the inverted..
Posted on 2006-10-05 09:35:10 by Homer

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

so I should take the name "THE reciprocal"? :)
Posted on 2006-10-07 02:42:55 by daydreamer