POV-Ray : Newsgroups : povray.general : remap RGBT color to anther RGBT color? : Re: remap RGBT color to anther RGBT color? Server Time
30 Jul 2024 06:20:05 EDT (-0400)
  Re: remap RGBT color to anther RGBT color?  
From: Chris B
Date: 10 Jul 2009 14:29:25
Message: <4a578885@news.povray.org>
"caduser" <nomail@nomail> wrote in message 
news:web.4a574f3ea2e71d6edbd439ba0@news.povray.org...
>I am working with an application that produces POV files of 3D objects from 
>a
> library. The problem I am facing is when the objects are colored black. We
> render most objects to Steel and when an item is absolute black it does 
> not
> render well as there is no reflectivity of course (I understand why this
> occurs)
>

Black objects can be reflective. The reflection setting is part of the 
finish definition, so the following code produces a completely black, 
reflective plane.

camera {location <-5, 5, -5> look_at <0,0,0>}
light_source {<2,20,-4> color rgb 1}

plane {-z,-0.6 pigment {rgbt 0} finish {reflection 1}}
sphere {0,1 pigment {rgb <1,0,0>}}


> The value in the POV file is:
>
> texture {
>    pigment
>      {
>          color rgbt <0.,0.,0.,0.>
>      }
>
> I found if I manually changed to:
>
> texture {
>    pigment
>      {
>          color Gray20
>      }
>
> Then it rendered just as I want. What I am trying to accomplish is a way 
> to
> remap these colors with one of the include files. We currently point to a
> material ppv file which has color.inc, skies.inc and textures.inc. Is it
> possible to either add to one of these or add a new inc file that would 
> run a
> macro to remap that absolute black to a dark gray?

Your first example above specifies the RGB and the transparency values 
directly, so it doesn't use color.inc. The second example does use the 
Gray20 identifier, which is declared in color.inc. It is technically 
possible to create your own include file to override color definitions from 
colors.inc, but I don't think this is a good way to achieve what you want, 
particularly if you are currently generating the colors from an external 
program.



>
> One of my colleagues suggested we take this approach:
>
> color rgbt <<%R%> * 0.8 + 0.2,<%G%> * 0.8 + 0.2,<%B%> * 0.8 + 0.2,<%A%>>
>
> But that also forces light gray to white by pushing every color and this 
> has the
> same problem pure white and pure black are not good in renderings and also 
> not
> desirable in print. SO ultimately I would like 2 macros I guess, one to 
> push
> pure white to light gray and pure black to dark gray. I looked through the
> macro documents but could only see how to push one colors space e.g. RGB 
> to
> another e.g. HSL and not how to map RGB to RGB (or RGBT to RGBT). I see 
> the
> fine folks here accomplishing some very cool things so figured this would 
> be
> the place to find out. IS this possible?
>

I assume that the '<%R%>' is how you are performing variable substitution 
from your application code. This is probably the best approach to take, but 
you are not limited to the sort of calculation you have given in your 
example, because POV-Ray supports various functions that you can build into 
the equation.

For example, there is a min() function and a max() function that can be used 
to limit the values to a particular range.

color rgbt <max(<%R%>,0.2),  etc... >

can be used to make sure the color value never goes below 0.2, but this does 
mean that all values below 0.2 would be clipped to the same value. 
Conversely the  min()  function selects the minimum of two values, so it can 
be used to similarly constrain the upper limit (min(<%R%>,0.8))

Alternatively:

<%R%>*0.6+0.2

would give you a value that transitioned smoothly from 0.2 to 0.8 (assuming 
that R is in the range 0 to 1).

Regards,
Chris B.


Post a reply to this message

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