POV-Ray : Newsgroups : povray.general : remap RGBT color to anther RGBT color? Server Time
5 Nov 2024 03:19:37 EST (-0500)
  remap RGBT color to anther RGBT color? (Message 1 to 10 of 15)  
Goto Latest 10 Messages Next 5 Messages >>>
From: caduser
Subject: remap RGBT color to anther RGBT color?
Date: 10 Jul 2009 10:30:01
Message: <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)

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?

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?


Post a reply to this message

From: Chris B
Subject: Re: remap RGBT color to anther RGBT color?
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

From: clipka
Subject: Re: remap RGBT color to anther RGBT color?
Date: 10 Jul 2009 19:40:01
Message: <web.4a57d03abddeda8444f4a5670@news.povray.org>
"caduser" <nomail@nomail> wrote:
> 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.

Looks reasonable.

If you want to move a bit away from white as well, you may want to try this one:

  color rgbt <<%R%> * 0.6 + 0.2,<%G%> * 0.6 + 0.2,<%B%> * 0.6 + 0.2,<%A%>>

(Note that this just replaces the 0.8 in your above formula with 0.6.)

This will "compress" your color range to avoid both total black and total white,
using only the range 0.2 to 0.8 for each component.

Alternatively, you can use the clip() function to achieve the same color range,
but in this case black and almost-black will look alike:

  color rgbt <clip(<%R%>,0.2,0.8),clip(<%G%>,0.2,0.8),clip(<%B%>,0.2,0.8),<%A%>>


Post a reply to this message

From: Alain
Subject: Re: remap RGBT color to anther RGBT color?
Date: 10 Jul 2009 23:21:32
Message: <4a58053c$1@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)
> 
> 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?
> 
> 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?
> 
> 

If the rgbt<0,0,0,0> is generated by the external application, can you 
set it's palete? If you can, set "black" as something like 
rgb<0.1,0.1,0.1> or rgbt<0.1,0.1,0.1,0>
By the same way, you could redefine "white" as rgb<0.9,0.9,0.9> or 
rgbt<0.9,0.9,0.9,0>



Alain


Post a reply to this message

From: caduser
Subject: Re: remap RGBT color to anther RGBT color?
Date: 11 Jul 2009 00:50:03
Message: <web.4a5818d6bddeda84dbd439ba0@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:

>
> If the rgbt<0,0,0,0> is generated by the external application, can you
> set it's palete? If you can, set "black" as something like
> rgb<0.1,0.1,0.1> or rgbt<0.1,0.1,0.1,0>
> By the same way, you could redefine "white" as rgb<0.9,0.9,0.9> or
> rgbt<0.9,0.9,0.9,0>
>
>
>
> Alain

The colors are already chosen in the models, without editing each and every
model (which are all checked in and protected) this cannot be done. POV is just
one of many outputs but one that is best for photorendering, the rest are for 3D
use.

As for the color shift I really don't want to shift anything but the absolute
back and absolute white. The material file from what I understand call several
include files but I don't think the colors is really used (not until I manually
declared the gray20 that was me tinkering)

<%SCENE
#include "colors.inc"
#include "textures.inc"
#include "skies.inc"

The rest builds a sphere and Pseudo HDRI lighting texture to set the render
environment. I had been curious if I could leave the RGBT value alone but have
a macro or something that would pick up that value and force it to another
color. I tried upping lights and reflectivity (playing with values I am more
familiar with 3D studio and typically never use POV) they never really got
anything desirable for the black objects (had some success with other dark
components. Also I work with print and these would be used in print and as a
rule one never wants total black 255, 255, 255 you want to pull back just like
total white (total white means no ink laid down)


Post a reply to this message

From: caduser
Subject: Re: remap RGBT color to anther RGBT color?
Date: 11 Jul 2009 01:00:04
Message: <web.4a581c2bbddeda84dbd439ba0@news.povray.org>
If it helps our typical material file adds this to the start of a POV:


#include "colors.inc"
#include "textures.inc"
#include "skies.inc"

#declare light_mul = 0.3;
#declare plane_mul = 1.2;
#switch (3)
  #case (0)
    #declare light_mul = 1.6;
    #declare plane_mul = 1.2;
  #break
  #case (1)
    global_settings {
        max_trace_level 6
        assumed_gamma 2.2

        radiosity {
          pretrace_start 0.08
          pretrace_end   0.04
          count 50

          nearest_count 2
          error_bound 0.41
          recursion_limit 1
         normal on

          low_error_factor 0.2
          gray_threshold 0.0
          minimum_reuse 0.015
          brightness 2.5

          adc_bailout 0.01/2
        }
      }
  #break
  #case (2)
    global_settings {
        max_trace_level 6
        assumed_gamma 2.2

        radiosity {
          pretrace_start 0.08
          pretrace_end   0.01
          count 150

          nearest_count 3
          error_bound 0.31
          recursion_limit 1
         normal on

          low_error_factor 0.2
          gray_threshold 0.0
          minimum_reuse 0.015
          brightness 2.5

          adc_bailout 0.01/2
        }
      }
  #break
  #case (3)
    global_settings {
        max_trace_level 6
        assumed_gamma 2.2

        radiosity {
          pretrace_start 0.08
          pretrace_end   0.005
          count 250

          nearest_count 5
          error_bound 0.21
          recursion_limit 1
         normal on

          low_error_factor 0.2
          gray_threshold 0.0
          minimum_reuse 0.015
          brightness 2.5

          adc_bailout 0.01/2
        }
      }
  #break
#end

#declare CAP =
union
{
union
{
union{

------Then comes all the coordinates to make the object-------

texture {
    pigment
      {
          color rgbt <0.,0.,0.,0.>
      }
    finish
      {
        ambient 0
        diffuse 0.42
        roughness 0.03
        reflection
          {
           0.5, 0.6
           metallic
          }
        metallic
      }
  scale 3
  scale 280.
}

The last part seems to be the construct of the environment the camera position
and if blur statements etc finally the HDRI map and the light.

Just to be clear I did not write the materials or the objects I am an end user I
asked if the program that outputs the models can capture this value and change
it but that was involved and seemed a lost cause. I had managed to create
several new material files from reading and pocking around like copper and some
other basic edits and wanted to know if this could be done with an external file
with no modification to the original POV or if it is a lost cause.

I was frustrated I could not figure it out I usually manage to work something
out find a script to modify but this tool is new to me my background is CAD, 3D
Studio and Photo editing. It seems like just about anything can be achieved with
this tool with some know how and patience.


Post a reply to this message

From: Chris B
Subject: Re: remap RGBT color to anther RGBT color?
Date: 11 Jul 2009 03:34:54
Message: <4a58409e@news.povray.org>
"caduser" <nomail@nomail> wrote in message 
news:web.4a581c2bbddeda84dbd439ba0@news.povray.org...
> If it helps our typical material file adds this to the start of a POV:
>
>   ... snip ...
>
> texture {
>    pigment
>      {
>          color rgbt <0.,0.,0.,0.>
>      }
>
>   ... snip ...
>
> ... wanted to know if this could be done with an external file
> with no modification to the original POV or if it is a lost cause.
>

Once this POV output has been written to disk containing literal color 
definitions, I don't believe there's any practical way of changing the color 
without changing the file. Having said that;  changing the file should not 
be difficult as you can perform a global change in most editors (for example 
the POV-Ray for Windows editor). You have said that it's only two specific 
values (complete Black and complete White) that you want to change and, as 
these are written out by an application program they are presumably written 
in a consistent format.

Therefore, a global change of 'color rgbt <0.,0.,0.,0.>' to 'color rgbt 
<0.01,0.01,0.01,0.01>' should be quick and easy in any decent editor. If you 
need to make this change regularly you could use an editor with a macro 
recording facility, so it would be just one button press each time. The 
POV-Ray for Windows 'editor' menu contains a couple of macro recording 
options (though I've not used them myself).  If you need to do this with a 
large number of files you'd either want a short script to perform something 
like a 'grep' command (Unix style) or you could use an editor that supports 
a 'Replace in Files' sort of operation, eg UltraEdit, or the text editors in 
most IDEs.

Regards,
Chris B.


Post a reply to this message

From: Christian Froeschlin
Subject: Re: remap RGBT color to anther RGBT color?
Date: 11 Jul 2009 07:12:39
Message: <4a5873a7$1@news.povray.org>
caduser wrote:

> Just to be clear I did not write the materials or the objects I am an end user

Just out of curiosity: Does this mean your CAD program comes
with a POV-Ray export option built in?

As Chris has said, textually processing the generated sdl script
with an editor macro (or perl script or similar) is probably your
best option. Note that there is another way but it may be overkill:
The sources to POV-Ray are available and you can compile your own
binary. This, of course, could be patched to set a dark gray
internally whenever it parses "color rgbt <0.,0.,0.,0.>".


Post a reply to this message

From: caduser
Subject: Re: remap RGBT color to anther RGBT color?
Date: 11 Jul 2009 09:05:01
Message: <web.4a588d74bddeda84dbd439ba0@news.povray.org>
Christian Froeschlin <chr### [at] chrfrde> wrote:

> Just out of curiosity: Does this mean your CAD program comes
> with a POV-Ray export option built in?
Yes that is right it is one of our image output options.

> As Chris has said, textually processing the generated sdl script
> with an editor macro (or perl script or similar) is probably your
> best option.

So far I have been using a replace all batch but this was to test samples. The
program has 2 options one to output full size renders for use in print and
second to generate preview icons for browsing inside the application, this runs
it's own internal batch of generating a temp POV then rendering and can be run
on thousands of objects. If I have to edit them all I have to use the render
single image so I can uncheck start render and then keep all the POV files.


>Note that there is another way but it may be overkill:
> The sources to POV-Ray are available and you can compile your own
> binary. This, of course, could be patched to set a dark gray
> internally whenever it parses "color rgbt <0.,0.,0.,0.>".

hmm that might be interesting but how hard would that be?

It seems if there is a way it would be the material file not the inc file right?
When I tried my colleagues approach:

<%MATERIAL
texture {
    pigment
      {
          color rgbt <<%R%> * 0.8 + 0.2,<%G%> * 0.8 + 0.2,<%B%> * 0.8 +
0.2,<%A%>>

      }
It did work for Black but shifts every color if there was a way at this point to
just push one color value.
I also need to look more at the reflectivity discussed early see if I can make
Black reflect enough to not be pure black in the render.


Post a reply to this message

From: Chris B
Subject: Re: remap RGBT color to anther RGBT color?
Date: 11 Jul 2009 11:06:44
Message: <4a58aa84@news.povray.org>
"caduser" <nomail@nomail> wrote in message 
news:web.4a588d74bddeda84dbd439ba0@news.povray.org...
> It seems if there is a way it would be the material file not the inc file 
> right?
> When I tried my colleagues approach:
>
> <%MATERIAL
> texture {
>    pigment
>      {
>          color rgbt <<%R%> * 0.8 + 0.2,<%G%> * 0.8 + 0.2,<%B%> * 0.8 +
> 0.2,<%A%>>
>
>      }
> It did work for Black but shifts every color if there was a way at this 
> point to
> just push one color value.
> I also need to look more at the reflectivity discussed early see if I can 
> make
> Black reflect enough to not be pure black in the render.
>

So did you try the other suggestions for your 'material' file (min, max or 
clip)?
They would seem to be able to do exactly what you're asking for.


Post a reply to this message

Goto Latest 10 Messages Next 5 Messages >>>

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