POV-Ray : Newsgroups : povray.general : Random colors or textures on mesh triangles? : Re: Random colors or textures on mesh triangles? Server Time
18 Nov 2024 23:30:31 EST (-0500)
  Re: Random colors or textures on mesh triangles?  
From: Christopher James Huff
Date: 5 Jul 2002 18:23:22
Message: <chrishuff-7830FA.17204805072002@netplex.aussie.org>
In article <eNglPZHxUJU++7jXESWFJ=KRzx6A@4ax.com>,
 Glen Berry <7no### [at] ezwvcom> wrote:

> Using POV 3.5, is it possible to randomly color each triangle in a
> mesh? I thought I had done this in earlier versions of POV, but can't
> seem to get it to work now.
> 
> Ideally, I'd want each triangle's RGB color values to be selected from
> the full RGB gamut, and not to be selected from a list of sample
> colors or textures.

Making each triangle a random solid color? Just generate a unique 
texture for each triangle. The only restriction is that you have to 
declare the texture before you can use it in the mesh triangle. 
Something like this should work:

#declare RS = seed(328947);

#macro RColorTri(ptA, ptB, ptC)
    #local triTex =
    texture {pigment {color rgb < rand(RS), rand(RS), rand(RS)>}}
    
    triangle {ptA, ptB, ptC texture {triTex}}
#end

Actually, this should probably work:
#macro RColorTri()
    #local triTex =
    texture {pigment {color rgb < rand(RS), rand(RS), rand(RS)>}}
    
    triTex
#end

mesh {
    triangle {ptA, ptB, ptC texture {RColorTri()}}
}

This will increase memory usage quite a bit though...if you used a list 
of textures instead of having a separate texture for every triangle, it 
would cut this down. You might also use the color macros in colors.inc 
to make only the hue random, making all the random colors of the same 
saturation and brightness.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

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