, , .
1
, (x, y). X (x + 1/width, y) y (x, y + 1/height), - . gluUnProject , {A, B, C}. , :
A = ObjectCoordinates(x+1/width, y)
B = ObjectCoordinates(x, y)
C = ObjectCoordinates(x, y+1/height)
BA = (A-B)/|A-B|
BC = (C-B)/|C-B|
N = BA cross BC
| X | - X
N
, , A, B C ( , , ). .
2
, , . . . , . , .
. (r, g, b) , (x, y, z). . . , , (u, v) , , .
, , , , .
Here is a slightly outdated but free book on GLSL in the Shading Language OpenGL that describes how you are going to build some of these shaders.
Here is a tutorial on loading and compiling shaders.
Here is the pseudo-code for calculating normal.
Cheers, ned
source
share