home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / alt / sys / amiga / demos / 1121 < prev    next >
Encoding:
Internet Message Format  |  1992-09-09  |  2.0 KB

  1. Path: sparky!uunet!usc!sol.ctr.columbia.edu!ira.uka.de!smurf.sub.org!incom!orfeo!hotb.sub.org!laire!sven
  2. From: sven@laire.hotb.sub.org (Sven Wachter)
  3. Newsgroups: alt.sys.amiga.demos
  4. Subject: Re: "Lightsourced" polygons?
  5. Distribution: world
  6. Message-ID: <sven.03e3@laire.hotb.sub.org>
  7. References:  <117617@muvms3.bitnet>
  8. Date: 8 Sep 92 12:22:48 GMT
  9. Organization: Organization is a waste of energy!
  10. Lines: 50
  11.  
  12. In article <117617@muvms3.bitnet> rcbi110@muvms3.bitnet (R. ALAN MONROE) writes:
  13. >Can someone explain how "lightsourced" polygons are done?
  14.  
  15. I think you are talking of illuminated polygons.  There is no simple answer
  16. to  your  question,  because  there  are many ways to do it using different
  17. amounts of cpu-time.
  18.  
  19. For   simple  shading  with  one  Lightsource  you  may  use  the  folowing
  20. pseudo-code called Flat Shading:
  21.  
  22. for all polygons
  23. {
  24.     Vector dl = Light-PolygonPoint;
  25.     Vector norm = Normal(polygon);
  26.     
  27.     double light= (dl*norm)/(Length(norm)*Length(dl))
  28.     // light is now in Range -1 to 1
  29.     
  30.     light = scale_light(light)
  31.     // scale light to your colorrange
  32.     
  33.     set_color(light)
  34.     
  35.     draw_polygon(polygon)
  36. }
  37.  
  38.  
  39. Normal() calculates the surface normal of the polygon,
  40.  
  41. set_color() sets the color according to the brightness of the polygon,
  42.             to get more shades on the Amiga you may calculate a pattern
  43.             to extend the available colors for the human eye (dithering)
  44.  
  45. draw_polygon() draws the polygon using z-buffer or with z-sorted polygons
  46.                using the simple subroutines from graphics.library.
  47.  
  48. Please excuse my awful english, it's not my native language.
  49.  
  50.  
  51. Sven.
  52.  
  53. BTW: Due to an unstable feed you may have to repeat mail to me.
  54.      I read the group every day, but my feed eats sometimes news
  55.      and mail of whole weeks ;-(
  56. --
  57. /////////////////////////////////////////////////////////////////
  58. //   Sven Wachter,  Neckarstr. 14,  6050 Offenbach,  Germany   //
  59. /////////////////////////////////////////////////////////////////
  60. //   Sven_Wachter@f.maus.de   ///   sven@laire.hotb.sub.org    //
  61. /////////////////////////////////////////////////////////////////
  62.