POV-Ray : Newsgroups : povray.newusers : Assigning sphere colours using rgb Server Time: 16 Dec 2018 02:01:30 GMT
  Assigning sphere colours using rgb (Message 1 to 5 of 5)  
From: david
Subject: Assigning sphere colours using rgb
Date: 22 Aug 2017 22:10:01
Message: <web.599cab5be8844a66c326978c0@news.povray.org>
I am trying to plot spheres with positions and colours taken from a text file.

This message (
">3Cweb.4f05a8fc1cabb177be8719c80@news.povray.org%3E/" target="_new">http://news.povray.org/povray.general/thread/%3Cweb.4f05a8fc1cabb177be8719c80@news.povray.org%3E/
) has helped with the initial plotting, but I cannot get the colours to render.
What am I doing wrong please?

Example code

#include "colors.inc"

global_settings {
 assumed_gamma 1.0
 ambient_light White
}

light_source { <50,50,-50> color White }

camera {
  sky <0, 0, -1>
  look_at <0, 0, 0>
  location <-25, 10,-25>
}

plane { <0,0,-1>, 0
  pigment { color White }
}

#fopen FileHandle1 "coords1.txt" read
#while (defined(FileHandle1))
     #read (FileHandle1, v1, v2, v3, v4, v5, v6)
     sphere { <v1, v2, v3>,    2
      texture { pigment{ rgb <v4, v5, v6> }
                finish { reflection 1  }}}
#end

------------------------------------------------------------------
And the coords1.txt file

10,0,-10,0,178,238,
-10,10,-10,238,174,238,
-10,-10,-10,176,196,222,

(I got the rgb colours from using `col2rgb(c("deepskyblue2", "plum2",
"lightsteelblue"))` in the R software)


Post a reply to this message

From: Alain
Subject: Re: Assigning sphere colours using rgb
Date: 22 Aug 2017 23:32:06
Message: <599cbef6@news.povray.org>
Le 17-08-22 à 18:08, david a écrit :
> I am trying to plot spheres with positions and colours taken from a text file.
> 
> This message (
>
">3Cweb.4f05a8fc1cabb177be8719c80@news.povray.org%3E/" target="_new">http://news.povray.org/povray.general/thread/%3Cweb.4f05a8fc1cabb177be8719c80@news.povray.org%3E/
> ) has helped with the initial plotting, but I cannot get the colours to render.
> What am I doing wrong please?
> 
> Example code
> 
> #include "colors.inc"
> 
> global_settings {
>   assumed_gamma 1.0
>   ambient_light White
> }
> 
> light_source { <50,50,-50> color White }
> 
> camera {
>    sky <0, 0, -1>
>    look_at <0, 0, 0>
>    location <-25, 10,-25>
> }
> 
> plane { <0,0,-1>, 0
>    pigment { color White }
> }
> 
> #fopen FileHandle1 "coords1.txt" read
> #while (defined(FileHandle1))
>       #read (FileHandle1, v1, v2, v3, v4, v5, v6)
>       sphere { <v1, v2, v3>,    2
>        texture { pigment{ rgb <v4, v5, v6> }
>                  finish { reflection 1  }}}
> #end
> 
> ------------------------------------------------------------------
> And the coords1.txt file
> 
> 10,0,-10,0,178,238,
This one show as cyant
> -10,10,-10,238,174,238,
> -10,-10,-10,176,196,222,
Those two show as pure white.
In a radiosity scene, they'll have a huge impact on any neibouring tints.

> 
> (I got the rgb colours from using `col2rgb(c("deepskyblue2", "plum2",
> "lightsteelblue"))` in the R software)
> 
> 
> 
> 
> 

In POV-Ray, all colours are in the 0..1 range. Anything larger than that 
gets shown as if they where set at 1.
If you see those on a slightly reflective surface, then, you'll be able 
to see the actual colours. Try a plane with this texture:
texture{pigment{rgb 0} finish{reflection 1/200 diffuse 0 ambient 0}}

What you need is to divide your 0..255 range values by 255 as follow:
texture { pigment{ rgb <v4/255, v5/255, v6/255> }

OR, use this shorter form :
texture { pigment{ rgb <v4, v5, v6>/255 }

As those are probably gamma precomputed, using srgb is probably beter :
texture { pigment{ srgb <v4, v5, v6>/255 }


Alain


Post a reply to this message

From: david
Subject: Re: Assigning sphere colours using rgb
Date: 23 Aug 2017 14:00:00
Message: <web.599d89b160abce79c326978c0@news.povray.org>
Thanks Alain, also for the extra info
david

Alain <kua### [at] videotronca> wrote:
> Le 17-08-22 à 18:08, david a écrit :
> > I am trying to plot spheres with positions and colours taken from a text file.
> >
> > This message (
> >
">3Cweb.4f05a8fc1cabb177be8719c80@news.povray.org%3E/" target="_new">http://news.povray.org/povray.general/thread/%3Cweb.4f05a8fc1cabb177be8719c80@news.povray.org%3E/
> > ) has helped with the initial plotting, but I cannot get the colours to render.
> > What am I doing wrong please?
> >
> > Example code
> >
> > #include "colors.inc"
> >
> > global_settings {
> >   assumed_gamma 1.0
> >   ambient_light White
> > }
> >
> > light_source { <50,50,-50> color White }
> >
> > camera {
> >    sky <0, 0, -1>
> >    look_at <0, 0, 0>
> >    location <-25, 10,-25>
> > }
> >
> > plane { <0,0,-1>, 0
> >    pigment { color White }
> > }
> >
> > #fopen FileHandle1 "coords1.txt" read
> > #while (defined(FileHandle1))
> >       #read (FileHandle1, v1, v2, v3, v4, v5, v6)
> >       sphere { <v1, v2, v3>,    2
> >        texture { pigment{ rgb <v4, v5, v6> }
> >                  finish { reflection 1  }}}
> > #end
> >
> > ------------------------------------------------------------------
> > And the coords1.txt file
> >
> > 10,0,-10,0,178,238,
> This one show as cyant
> > -10,10,-10,238,174,238,
> > -10,-10,-10,176,196,222,
> Those two show as pure white.
> In a radiosity scene, they'll have a huge impact on any neibouring tints.
>
> >
> > (I got the rgb colours from using `col2rgb(c("deepskyblue2", "plum2",
> > "lightsteelblue"))` in the R software)
> >
> >
> >
> >
> >
>
> In POV-Ray, all colours are in the 0..1 range. Anything larger than that
> gets shown as if they where set at 1.
> If you see those on a slightly reflective surface, then, you'll be able
> to see the actual colours. Try a plane with this texture:
> texture{pigment{rgb 0} finish{reflection 1/200 diffuse 0 ambient 0}}
>
> What you need is to divide your 0..255 range values by 255 as follow:
> texture { pigment{ rgb <v4/255, v5/255, v6/255> }
>
> OR, use this shorter form :
> texture { pigment{ rgb <v4, v5, v6>/255 }
>
> As those are probably gamma precomputed, using srgb is probably beter :
> texture { pigment{ srgb <v4, v5, v6>/255 }
>
>
> Alain


Post a reply to this message

From: Le Forgeron
Subject: Re: Assigning sphere colours using rgb
Date: 27 Aug 2017 13:31:40
Message: <59a2c9bc$1@news.povray.org>
Le 23/08/2017 à 01:33, Alain a écrit :
> Le 17-08-22 à 18:08, david a écrit :
>> I am trying to plot spheres with positions and colours taken from a
>> text file.
>>

>> ) has helped with the initial plotting, but I cannot get the colours
>> to render.
>> What am I doing wrong please?

>> global_settings {
>>   assumed_gamma 1.0
>>   ambient_light White
>> }


> As those are probably gamma precomputed, using srgb is probably beter :
> texture { pigment{ srgb <v4, v5, v6>/255 }
> 

If you intend to do a "2D like" picture with exact match of the colour,
you should use also "assumed_gamma srgb" in global settings and "finish
{ ambient 1 diffuse 0 reflection 0}".

no need of light source in such settings.

And do not forget to start with a #version 3.7;


Post a reply to this message

From: clipka
Subject: Re: Assigning sphere colours using rgb
Date: 27 Aug 2017 14:15:20
Message: <59a2d3f8@news.povray.org>
Am 27.08.2017 um 15:31 schrieb Le_Forgeron:

>>> global_settings {
>>>   assumed_gamma 1.0
>>>   ambient_light White
>>> }
> 
> 
>> As those are probably gamma precomputed, using srgb is probably beter :
>> texture { pigment{ srgb <v4, v5, v6>/255 }
>>
> 
> If you intend to do a "2D like" picture with exact match of the colour,
> you should use also "assumed_gamma srgb" in global settings

`assumed_gamma srgb` is never a good idea. If you're using `srgb` for
the pigment and `File_Gamma=srgb` you should be fine in terms of input
colour = output colour. If you're only using `emission` or `ambient`,
the `assumed_gamma` setting should actually be irrelevant.

> and "finish
> { ambient 1 diffuse 0 reflection 0}".

with v3.7 you should better use

    finish { ambient 0 emission 1 diffuse 0 reflection 0}


Post a reply to this message

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