POV-Ray : Newsgroups : povray.newusers : Scanline rendering? : Re: Scanline rendering? Server Time
5 Sep 2024 16:18:38 EDT (-0400)
  Re: Scanline rendering?  
From: Warp
Date: 24 Jan 2001 08:17:25
Message: <3a6ed5e5@news.povray.org>
Peter J. Holzer <hjp### [at] sikituwsracat> wrote:
: Actually, basic scanline rendering is quite simple, even simpler than
: raytracing.

  It depends on whether you want a working scanline rendering or not.

  For example, I consider hidden surface removal to be essential in
scanline rendering (if you don't remove hidden surfaces your image will look
just plain wrong).
  The simplest way of making this is to order the polygons by depth and
draw them from the farthest to the closest.
  This method, however, is far from perfect, even if the polygons don't
intersect. It's very far from trivial to get a perfect sorting algorithm
like this. There are cases where almost any algorithm will give you a
wrong result (that is, a polygon which should be in front of another polygon
is drawn in the wrong order with the other polygon).
  Making a perfect sorting algorithm is probably a lot more work than using
just another way of drawing the polygons (such as z-buffering). And of course
sorting does not work if the polygons intersect each other.
  Z-buffering is a working solution, but it's quite elaborated if you want
it to work well. Each pixel of each polygons must have a depth information
which has to be calculated from the depth information of the vertices of the
polygon. This depth information has to be perspective corrected if you want
it to look right (if you just interpolate linearly you'll get a wrong result;
your polygons will look like they were bended in the depth direction, and
the bending amount will change depending on the orientation of the polygon).
Calculating perspective correct interpolation of depth information is not
what I consider trivial.

  Constant-colored polygons look just horrible (specially if your whole object
is of the same color because then you'll get just the silhouette of the
object and no inner details), so some type of shading is in place if
you want your renderer to look any good. You'll need light sources and your
polygons will need to be shaded according to them.
  Flat-shading is the easiest to calculate. You just calculate the orientation
of the normal vector of the polygon with respect to all light sources and
then brighten/darken the color of the polygon according to that.
  This way you only get flat polygons and it works only for light sources
at infinity (for point light sources the shading would be just plain wrong).
  Even flat polygons need to be shaded in a pixel-by-pixel basis if there
are point lights. And of course if you want smooth surfaces (that is, the
normal vector changes along the polygon). Also here you have to use perspective
correction if you want to get a correct result (specially with big polygons).

  If you want any texturing at all on your polygons, that's a whole story
in itself. Perspective correction, mipmapping, bilinear or trilinear
filtering... The list of features is endless.

  With raytracing you get things almost for free that are extremely complicated
to make with scanline raytracing.
  For example shadows. In raytracing they are laughably trivial. In scanline
rendering they are a real headache. The algorithms for shadows are quite
complicated (shadow volumes, light mapping, etc).
  Reflection and refraction is also very easy in raytracing and very
complicated in scanline rendering (if you want to look them right; basic
environment mapping is a very poor approximation).

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.