POV-Ray : Newsgroups : povray.programming : patch: smooth_color_triangle : patch: smooth_color_triangle Server Time
28 Jul 2024 20:34:58 EDT (-0400)
  patch: smooth_color_triangle  
From: Ansgar Philippsen
Date: 28 Jul 1999 13:02:50
Message: <379F381D.ADDF4AE4@ubaclu.unibas.ch>
Suggesting a patch for "smooth_color_triangle"

In my efforts to generate POV-ray output from an OpenGL program, I have
come across the problem of specifying normals AND colors for each
triangle vertex. Since this cannot be done directly with POV-ray (3.1g),
I first used a macro provided by Chris Colefax
(http://www.geocities.com/SiliconValley/Lakes/1434/), but my scenes are
easily above 50'000 triangles and the memory requirements were just too
much with this macro.

SO, I have written a patch which implements a new object type into a
triangle mesh (and _only_ in the mesh). You can find it at

http://www.bioz.unibas.ch/~xray/dino/pov

First thing I did was to add color to the mesh_triangle, similar as
vertex and normal are already implemented. Then I modified the
parse_mesh routine. A flag is set for each triangle that uses the color
information. Pretty straightforward up to now.

Next, I realized (maybe falsly) that in POV-ray the texture handling is
independent of the object coordinates and only depends on the
intersection coordinates (correct ?). Anyway, I inserted sort of a
catch-point into "Determine_Apparent_Colour" (found in lighting.c)
-> documented in detail on the webpage.
I basically check wether the intersected object is a mesh, the triangle
in the mesh has the smooth-color flag set and then interpolate the color
from the intersection point IPoint, the three triangle vertices and the
respective colors. This interpolated color is then forced as the
texture->pigment->color, while texture->pigment->type is set to
PLAIN_PATTERN

Possible problems:

 a) what happens if there are multiple layers, which layer should
actually be forced to the interpolated color ?

 b) when using predefined textures this obviously goes bad. Saving the
texture->pigment and restoring could work

All tests I have done so far indicate that it runs stable, does not
impact normal POV-ray functionality and allows to render large scenes
with smooth_color_triangles. These tests were not exhaustive!

I did briefly check wether such a functionality is under production, but
I did not find anything.

Any comments on this patch are of course appreciated, I am especially
curious if such a patch could be incorporated into the next 'official'
POV-ray release.

Ansgar

---

aphilipp at bioz dot unibas dot ch


Post a reply to this message

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