Buzz #17
10 апреля 1999

GOURAUD - Likbez in 3D-shading (shading algorithm faces by GOURAUD).

<b>GOURAUD</b> - Likbez in 3D-shading (shading algorithm faces by GOURAUD).
(C) 1999 SaiR00S/EI


    The aim of this paper (and, perhaps, a series of articles, 
if you All this seems not without interest) is to conduct

small literacy classes in the 3D-shading, for me, softly
for instance, got sayings on this issue in the style:
"Pah-fa-a, aa-and hde moge? etc.

    Okay, enough about sad things, we go directly to the subject
today's story.

    Gouraud shading - a method of filling 3D
surface based on Lambertovskoy lighting model, and
which is its refinement (for details, anyone interested,
read about it in the literature on this topic or Clarify
the matter to full-time meeting with me for a couple of 
beers:). Well duck Now, with this model, light, light intensity,

incident on the plane determined by the angle between the light
and the vector normal to the surface. Bare podnapryagshis in
mathematics, we recall that the cosine of the angle between the 
two vectors defined as follows:


cos (AB) = (Xa * Xb + Ya * Yb + Za * Zb) / (| A | * | B |)

 where Xa, Xb, Ya, Yb, Za, Zb - the coordinates of all vectors
                         ditch A and B;

     | A |, | B | - the lengths of these vectors are computed

               quite simple:), as summa goemetricheskaya to
               ordinates Xa .. Za:


               | A | = sqrt (Xa ^ 2 + Ya ^ 2 + Za ^ 2),

               Similarly, we find | B |.


    In relation to Gouraud, it gives us information on how to
what color to paint over the ground.

    So what, do we need for the formation of surface
method of Gouraud:

    - Firstly - the coordinates of the vertices of the projected
landfill (we'll use the triangle as it is
the most simple, fast and it is the most mathematically correct,
For its three vertices can not lie in different planes, which
can not be said about other types of polygons);

    - Secondly - this is the value of light intensity in each 
of the vertices.



    To learn how to project the top of the plane, I
I will not tell, but on how to get the value
light intensity at the vertices, I shall detail.
Thus, for each face 3D object known, we have a normal. In each
top of the object known, we raiseth normal, which is the sum
normals of the faces surrounding the vertex. Then, we normalize
received normal, and taking any of the coordinate
light intensity about the axis formed by this
coordinate and the origin, we get the color value
this point.

    The following picture will help a little bit to understand 
the reading. 


                  (X1, Y1), a1

                    /

                  / \ A1 .. a3 - values
                / Radiation colors

              / / Points with coordinates
            / Coordinate of X1-X3,
(X2, Y2), a2 / \ Y1-Y3.

          \

            \ \

              \

                \ \

                  \

                    \ \

                      \

                        \ \

                          \

                            \ \

                           (X3, Y3), a3


    Further, linearly interpolated color from a1 to a2, a2 
​​from to a3, and from a1 to a3, we get the color values ​​for 
each vertical line. Who are not lazy, interpolation can spend

by straight-line equation:


                          Y = A * X + B,

resulting in a small brake. Much more convenient
interpolate on Brezenhemu (this you will get rid of the 
division). 

    After this interpoliruete color on each horizontal
line and at the same time draws a polygon:


           LD A, H; Writes a value of A
                     ; Of color

           ADD HL, DE; interpolate the color

                     ; On the horizontal

                     ; Line

           LD (BC), A; throw color

                     ; Buffer

           INC C; Proceed to the next
                     ; Yuschey point.


    That's it! Get a nice (as far as it can be beautiful
on the Spectrum) Gouraud shading.

    Before you throw it all kodit can be viewed as
it looks at VAV'a in Refresh (the part where a bagel Dangle
against the background of the eye), or on the AMIGA (although 
there is a net Gouraud rarity, all Phong, yes Phong ...) in the 
last demah from Ramses, but with Texture Mapping'om (strongly 
recommended view all of the best demos for 97-98 years, so for 
general development ...).


    For sim goodbye, success on the demoscene!







Other articles:

AGA - Graphic editor 3 color'nyh screenshots AGA v1.0.

ASCII graphics - How do I view ASCII? How to learn to ASCII. Are there helper programs for ASCII.

BLOB the COP - Text of the inner game firms Players to Hacker.

C. Expirience - Cheat for the game Space Crusade.

DOS PRO - The fastest procedure, the disk: read / write sectors without monitoring and controlling errors reading sectors monitoring of the serviceability of reading, reading / writing sectors with the control interrupts the ignition / quenching lamp drive spinning and braking disc, reset VG13, positioned at 0 track, protection from Magic Button, blanking lamp drive, check what the current, control the availability of the disk in the drive.

Eternal News - News from the Kovrov spektrumistov (Ash, Proxima, EI)

GOURAUD - Likbez in 3D-shading (shading algorithm faces by GOURAUD).

Hard Life - On creating a new DOS for the Speccy.

HDD Autodetect - FDD & HDD loader.

Heroes of M & M II - The presentation of the game: Heroes of might & magic II.

MMA in Kovrov - great and terrible in the city where never made carpets.

Modern Word - The description text editor Modern Word v1.3

Parties?! - FunTop'99 vs Chaos Construction'99: Point of view.

Program BOX - New unusual boot - Program BOX v2.0.

Rants & Raves - How to get on the train with forged tickets.

Switch 3.5 ' - As juzat 3.5 drive after it is connected.

various shots - Extracts from the book of Guinness World Records.

various shots - Ultrosovremennaya tale about near the end of the world.

Zhiztyanka - Life issues SPY.

Contacts - contact details.

crisis - tales in the style of the game world from him.

Toy Review - Overview of Game Software: Figus, Mirror, Iron Man, Gyron Atrium, Homer Simpson in Russia, Golovobol, Monster Land, Devil's course, Astro Ball, Net Walk, Nexus.

Review sistemok - Overview of system software: Text Maker v0.12c, Excess Sample Editor v1.4, Best View v2.6, DOS2DOS COPYv2.0, Excess Deluxe Paint v1.0 demo, Laser Compact v5.0, Consul Commander v3.33, DCM Protection KIT v4.1b, Modern Word v1.3, E-Mage Work Statio, PKZIP.

From the authors - On changes in the shell of the newspaper.

About Cruise - Novella to the game "Escape to Harhan.

Advertising - Advertisements and announcements ...

Viewpoint - On writing Softa for the Spectrum.

Authors newspapers


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

Similar articles:

В этот день...   29 April