home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!sol.ctr.columbia.edu!ira.uka.de!smurf.sub.org!incom!orfeo!hotb.sub.org!laire!sven
- From: sven@laire.hotb.sub.org (Sven Wachter)
- Newsgroups: alt.sys.amiga.demos
- Subject: Re: "Lightsourced" polygons?
- Distribution: world
- Message-ID: <sven.03e3@laire.hotb.sub.org>
- References: <117617@muvms3.bitnet>
- Date: 8 Sep 92 12:22:48 GMT
- Organization: Organization is a waste of energy!
- Lines: 50
-
- In article <117617@muvms3.bitnet> rcbi110@muvms3.bitnet (R. ALAN MONROE) writes:
- >Can someone explain how "lightsourced" polygons are done?
-
- I think you are talking of illuminated polygons. There is no simple answer
- to your question, because there are many ways to do it using different
- amounts of cpu-time.
-
- For simple shading with one Lightsource you may use the folowing
- pseudo-code called Flat Shading:
-
- for all polygons
- {
- Vector dl = Light-PolygonPoint;
- Vector norm = Normal(polygon);
-
- double light= (dl*norm)/(Length(norm)*Length(dl))
- // light is now in Range -1 to 1
-
- light = scale_light(light)
- // scale light to your colorrange
-
- set_color(light)
-
- draw_polygon(polygon)
- }
-
-
- Normal() calculates the surface normal of the polygon,
-
- set_color() sets the color according to the brightness of the polygon,
- to get more shades on the Amiga you may calculate a pattern
- to extend the available colors for the human eye (dithering)
-
- draw_polygon() draws the polygon using z-buffer or with z-sorted polygons
- using the simple subroutines from graphics.library.
-
- Please excuse my awful english, it's not my native language.
-
-
- Sven.
-
- BTW: Due to an unstable feed you may have to repeat mail to me.
- I read the group every day, but my feed eats sometimes news
- and mail of whole weeks ;-(
- --
- /////////////////////////////////////////////////////////////////
- // Sven Wachter, Neckarstr. 14, 6050 Offenbach, Germany //
- /////////////////////////////////////////////////////////////////
- // Sven_Wachter@f.maus.de /// sven@laire.hotb.sub.org //
- /////////////////////////////////////////////////////////////////
-