Page 121 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 121

Unit 7: Implementation of Hidden Surface in 2D



                If Depth is less than a maximum value                                             Notes
                   Generate two rays Refl and Refr in the reflected and refracted directions,
                   Starting from Pt
                   Call RayTrace with arguments Refl and Depth + 1
                   Add (the return value * reflectivity of Obj) to C
                   Call RayTrace with arguments Refr and Depth + 1
                   Add (the return value * transmittivity of Obj) to C
                End if
             Else
                Set the total colour C to the background colour
             End if
             Return C
            End Procedure

            The Post-Rendering Section
            This section is also more or less programmer dependent, but the functions performed usually
            fall into one or more of the following groups
               •  Memory cleanup: The space taken up for the scene and rendering data is released.
               •  Applying post-process filters: Special effects such as blur, edge highlighting, suppression
                 of colour channels, gamma correction etc. may be added to the picture after the actual
                 rendering has taken place. Anti aliasing, motion blur etc. are usually a part of the main
                 rendering section.
               •  Freeing output devices: If the output device is a file, it is closed. If it is a hardware device,
                 then any link established with it may be suspended.
               •  Displaying statistics and other user data: This is, of course, entirely up to the programmer.
                 But it is useful to know the details of the rendering process.
            7.2.5 The Warnock Algorithm

            The Warnock algorithm is a hidden surface algorithm invented by John Warnock that is typically
            used in the field of computer graphics. It solves the problem of rendering a complicated image
            by recursive subdivision of a scene until areas are obtained that are trivial to compute. In other
            words, if the scene is simple enough to compute efficiently then it is rendered; otherwise it is
            divided into smaller parts which are likewise tested for simplicity.
            Warnock’s Algorithm

            A divide and conquer algorithm
               •  Warnock(PolyList PL, ViewPort VP)
               •  If (PL simple in VP) then

               •   Draw PL in VP
               •  else
               •   Split VP vertically and horizontally into VP1,VP2,VP3,VP4
               •   Warnock(PL in VP1, VP1)

               •   Warnock(PL in VP2, VP2)



                                             LOVELY PROFESSIONAL UNIVERSITY                                   115
   116   117   118   119   120   121   122   123   124   125   126