Demo or Die #02
31 июля 1999

Demo-Building - Phong Shading.

<b>Demo-Building</b> - Phong Shading.
__________________________________________


   (C) by Wolf of eTc / Scene


  Phong Shading (fake phong - all just
and beautiful).


                Truth - is misleading,

      lasting for a century, the same error -

     it is the truth, which lasted a minute.

                             (C) Golovachev



   As told to me by a friend to Fido:
"True phong - tupizna, it certainly imho.
Fong - is the same Guro, only
interpolated intensity value is not
color, and the values ​​of the outward normal,
which is then used to calculate
color. "

   I would like to add that the interpolation of the vector
outward normal is in the range of
-1 To 1 (If the normal is normalized, ie
reduced to unit length).


   1. First of all, a little linear
algebra.


   Vector normal to the plane - it is such
vector that is perpendicular to the plane
about the origin.


   Normalization of the normal - this cast
normals to unit length, it can be
to do so:


   Len = sqrt (x * x + y * y + z * z)

   x = x / len

   y = y / len

   z = z / len


   x, y, z - coordinates of the normal.


   But I do not, it is best
ration is not between -1 and 1, and in some
other convenient limits, for example, from -64
to 64, then everything will look like this
as follows:


   Len = sqrt (x * x + y * y + z * z)

   x = x * 64/len

   y = y * 64/len

   z = z * 64/len



  Finally, it is the vector product.
The formula is certainly not without multiplication, but that
done:


   V3.x = V1.y * V2.z-V1.z * V2.y

   V3.y = V1.z * V2.x-V1.x * V2.z

   V3.z = V1.x * V2.y-V1.y * V2.x


   V3 - is the vector product
vectors V1 and V2.


   2. Precalculations for Phong Shading


   Based on the fact that any
three-dimensional object, the normal changes in
each face, we need to calculate
normal to each vertex of the object.

   Normal at the vertex is considered as the average
arithmetic mean of all normal to those
faces that belong to this
top.

   A normal to the face is this:


  Suppose we have three vertices
triangle defined in a clockwise direction:


   V1 (x, y, z)

   V2 (x, y, z)

   V3 (x, y, z),

then


   V1 '= V3-V1

   V2 '= V2-V1


   But she is already considered as normal
vector product of two vectors V1 'and
V2 ':


   normal = vector_mul (V1 ', V2') (the multiplication
described above:)



   Here is the procedure for the calculation of normals
each face in C, because on this Basic'e
will look extrim:


   / / Part of 3D-engine (c) by Wolf of eTc
group / Scene

   / / Calculating the normals to the faces of


  for (i = 0; i 
(Texture obtyanet "object, such as
stone) can be observed when the rotation
3D-object, we will rotate and the normal.
Only the best of these normal
standardize the calculation of the coordinates in the
texture.


   Alexander Kulik (Wolf) 2:4635 / 8.18
__________________________________________







Other articles:

Deathmatch Quake v. 2.00 - BRIEF manual on methods of deprivation life of their own kind.

Demo party - OFFICIAL results Chaos Construction 999 for the PC.

Demo party - OFFICIAL results Chaos Construction 999 for the ZX Spectrum.

Demo party - OFFICIAL Paradox'99 results for the PC.

Demo party - OFFICIAL Paradox'99 results for the ZX Spectrum.

Demo-Building - Phong Shading.

Demo-Building - Radial blur, blur effect around the bitmap.

Demo-Building - Generator table of squares.

Demo-Building - an ancient effect a tricky name Moving Shit.

Demo-Building - some of sorting method.

Demo-Building - The printing of chunks.

Demo-Building - The implementation of plasma sizes of 2x2.

NeOS FAQ - Frequently Asked vopposy operating system for ZX Spectrum - NeOS.

Interview - Interview with Dennis Ritchie (Dennis M. Ritchie) creator of the programming language "C".

Interview - an interview with a famous coder'om, one of the founders M & U Sinclair Club, and later eTc group - Lazy.

Interview - Interview with the encoder and zhelezyachnikom LD / X-Trade.

Criticism - Kartika at first nome.p zhypnala Demo or Die.

From the Editor - interface.

From the Editor - Epilogue.

Application - wrapper display files LazyPack 2.0.

Advertising - Advertising and announcements.


Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Similar articles:
Advertising - advertising and announcements.
Miscellaneous - Live to "Rusbata. The conflict in Kosovo.
Letter - lzb ^ j77: "Yo, Heisenberg!%)
Gluck - Bugs CDOS v1.32.

В этот день...   21 November