POV-Ray : Newsgroups : povray.advanced-users : Finding Pigment / color of an object : Re: Finding Pigment / color of an object Server Time
3 Jul 2024 05:37:09 EDT (-0400)
  Re: Finding Pigment / color of an object  
From: Chris B
Date: 1 Mar 2009 08:40:47
Message: <49aa905f@news.povray.org>
<use### [at] domaininvalid> wrote in message news:49aa8650$1@news.povray.org...
> Hi,
> 1) How can I know the pigment/color of a given object ?

Hi,

Objects can be multicoloured. POV-Ray pigments can define complex colour 
patterns. The colour of an object is determined by the pigment assigned to 
that object at the particular location on the object you're interested in. 
The eval_pigment function can used to 'read' that colour from any pigment 
that you've assigned to an identifier.

> 2) What is the format of a pigment variable ? How can I extract each 
> component ?

Pigments can be assigned to identifiers in the standard way. You can use 
eval_pigment to determine the colour at a specific location in the pigment. 
The color value returned by the eval_pigment function is a standard rgb 
colour value. You can index individual RGB colour components using the 
identifier suffixes red, green and blue. So something like:

#declare MyPigment = pigment {rgb <0.1,0.2,0.3>}
#declare MyLocation = <1,2,3>;
#declare MyColour = eval_pigment(MyPigment,MyLocation);
#debug concat("Red: ",str(MyColour.red,3,3),"Green: 
",str(MyColour.green,3,3),"Blue: ",str(MyColour.blue,3,3),"\n")

Note, I didn't try running this, so keep your eyes open for syntax errors.

The colour you'll actually get in the rendered image can clearly be very 
different due to many factors, including the colours of any lights and other 
factors controlling the texture applied to the object.

Regards,
Chris B.

ps. It's more usual to see this sort of question on povray.newusers than on 
povray.advanced-users.


Post a reply to this message

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