POV-Ray : Newsgroups : povray.newusers : Translate colors Server Time
4 Nov 2024 23:15:41 EST (-0500)
  Translate colors (Message 1 to 10 of 10)  
From: Hershel Robinson
Subject: Translate colors
Date: 14 Aug 2001 07:06:22
Message: <3b79062e@news.povray.org>
Ray-tracers,

How do I translate colors from HTML format, i.e. color="#D5EAFF" to POV
format?

I, like any newbie, figured that D5 (213 in decimal) divided by 256 is 0.832
and likewise, EA becomes 0.914.  I naturally then tried

pigment { rgb <0.832 , 0.914, 1> }

and got a lovely gray nothing like the dull blue of my web page.  I would
like to make dull blue buttons to match the dull blue of the page (I didn't
choose the dull blue for the web page, that's what the boss likes).

Thanks,
Hershel


Post a reply to this message

From: Jérôme Grimbert
Subject: Re: Translate colors
Date: 14 Aug 2001 07:20:50
Message: <3B790A0C.A708C344@atosorigin.com>
Hershel Robinson wrote:
> 
> Ray-tracers,
> 
> How do I translate colors from HTML format, i.e. color="#D5EAFF" to POV
> format?
> 
> I, like any newbie, figured that D5 (213 in decimal) divided by 256 is 0.832
> and likewise, EA becomes 0.914.  I naturally then tried

Sorry, but you have to divide by 255  (not 256).
Pure White is 255, and in pov it's 1.


> 
> pigment { rgb <0.832 , 0.914, 1> }

Unless the ambient is 1 (which is not the default), 
the texture will only reflect part of the light it get,
multiplying by the pigment

(a reflected <1,1,1> would get out as desired, but it rarely 
happen)

Moreover, there is a gamma correction applied to the pov-output.
The default gamma is 2.2 (unless, like me, you have a custom built
pov so as to get a default gamma of 1, 
but then you wouldn't have posted here)


Post a reply to this message

From: ingo
Subject: Re: Translate colors
Date: 14 Aug 2001 08:54:51
Message: <Xns90FD97B75E4ADseed7@povray.org>


> Moreover, there is a gamma correction applied to the pov-output.
> The default gamma is 2.2 (unless, like me, you have a custom built
> pov so as to get a default gamma of 1, 
> but then you wouldn't have posted here)
> 

To get a gamma 1, just leave out assumed_gamma 1 from the default 
settings.

Ingo

-- 
Photography: http://members.home.nl/ingoogni/
Pov-Ray    : http://members.home.nl/seed7/


Post a reply to this message

From: Ken
Subject: Re: Translate colors
Date: 14 Aug 2001 09:48:21
Message: <3B792CAD.F833724B@pacbell.net>
Kari Kivisalo wrote:
> 
> Hershel Robinson wrote:
> 
> > How do I translate colors from HTML format, i.e. color="#D5EAFF" to POV
> > format?
> 
> #declare AG=1;
> #global_settings{assumed_gamma AG}
> 
> #macro G(Color)
>   #local DisplayGamma=2.2; // Display_Gamma from povray.ini
>   #local Gamma=DisplayGamma/AG;
>   <pow(Color.x,Gamma),pow(Color.y,Gamma),pow(Color.z,Gamma)>
> #end
> 
> #macro H2D(Hex)
>   #local H=strupr(Hex)
>   #local D1=asc(substr(H,1,1))-65;
>   #local D2=asc(substr(H,1,1))-65;
>   (D1<0 ? D1+17 : D1+10)*16 + (D2<0 ? D2+17 : D2+10)
> #end
> 
> #macro Hex2Color(C)
>   (<H2D(substr(C,1,2)),H2D(substr(C,3,2)),H2D(substr(C,5,2))>/255)
> #end
> 
> camera{location -3*z look_at 0}
> 
> box{-1,1
>  pigment{rgb G(Hex2Color("D5EAFF"))}
>  finish{diffuse 0 ambient 1}
> }

If that is your idea of a new user solution I would hate to see what you
provide for an advanced user :)

-- 
Ken Tyler


Post a reply to this message

From: Jaime Vives Piqueres
Subject: Re: Translate colors
Date: 14 Aug 2001 10:12:50
Message: <3B7931DD.EAA07078@ignorancia.org>
Ken wrote:
>
> >   [...]
> >   #local DisplayGamma=2.2; // Display_Gamma from povray.ini
> >   [...]
>
> If that is your idea of a new user solution I would hate to see what you
> provide for an advanced user :)

 The same, but without the comment... ;)

-- 
Jaime Vives Piqueres

La Persistencia de la Ignorancia
http://www.ignorancia.org/


Post a reply to this message

From: Kari Kivisalo
Subject: Re: Translate colors
Date: 14 Aug 2001 10:16:40
Message: <3B79336E.C99D20BD@pp.htv.fi>
Ken wrote:
>
> If that is your idea of a new user solution I would hate to see what you
> provide for an advanced user :)

Well, it works. The new version at least. I deleted the one you quoted
because of error in H2D().


_____________
Kari Kivisalo


Post a reply to this message

From: Kari Kivisalo
Subject: Re: Translate colors
Date: 14 Aug 2001 10:39:34
Message: <3B7938CF.7512C960@pp.htv.fi>
Hershel Robinson wrote:
>
> How do I translate colors from HTML format, i.e. color="#D5EAFF" to POV
> format?

When assumed_gamma isn't used drop G() because it's not needed.
Hex2Color does straight html color to pov color conversion.

#declare AG=1;

#global_settings{assumed_gamma AG}

#macro G(Color)
  #local DisplayGamma=2.2; //Display_Gamma from povray.ini
  #local Gamma=DisplayGamma/AG;
  <pow(Color.x,Gamma),pow(Color.y,Gamma),pow(Color.z,Gamma)>
#end

#macro H2D(Hex)
  #local H=strupr(Hex)
  #local D1=asc(substr(H,1,1))-65;
  #local D2=asc(substr(H,2,1))-65;
  (D1<0 ? D1+17 : D1+10)*16 + (D2<0 ? D2+17 : D2+10)
#end

#macro Hex2Color(C)
  (<H2D(substr(C,1,2)),H2D(substr(C,3,2)),H2D(substr(C,5,2))>/255)
#end

camera{location -3*z look_at 0}

box{-1,1
 pigment{rgb G(Hex2Color("D5EAFF"))}
 finish{diffuse 0 ambient 1}
}


_____________
Kari Kivisalo


Post a reply to this message

From: Hershel Robinson
Subject: Re: Translate colors
Date: 14 Aug 2001 14:45:07
Message: <3b7971b3$1@news.povray.org>
Thank you Kari for the detailed and reusable answer.

<editorial comments>
> If that is your idea of a new user solution I would hate to see what you
> provide for an advanced user :)

I am a new user to POV-Ray, but Kari probably noted that I mentioned that I
am a programmer so I actually appreciate the thorough answer.
</editorial comments>

Hershel


Post a reply to this message

From: Kari Kivisalo
Subject: Re: Translate colors
Date: 15 Aug 2001 00:16:37
Message: <3B79F84E.CA6CAAC1@pp.htv.fi>
Kari Kivisalo wrote:
> 
> #macro G(Color)
>   #local DisplayGamma=2.2; //Display_Gamma from povray.ini
>   #local Gamma=DisplayGamma/AG;
>   <pow(Color.x,Gamma),pow(Color.y,Gamma),pow(Color.z,Gamma)>
> #end

Here is a demo that shows how G() preserves colors when assumed_gamma
is used. Without G() gamma correction is applied twice to the colors
so they loose saturation and contrast.

http://www.pp.htv.fi/kkivisal/gamma_colors.jpg

When you design a cool color layout in an image editor the colors
you are viewing are gamma corrected. When assumed_gamma (1) is
present povray applies gamma correction to the whole image and
also to your carefully selected colors (which were already corrected).
G() macro applies inverse correction which cancels the povray gamma
correction. Or, as I like to say, converts a color to linear space :)


_____________
Kari Kivisalo


Post a reply to this message

From: Tom Melly
Subject: Re: Translate colors
Date: 15 Aug 2001 04:38:45
Message: <3b7a3515$1@news.povray.org>
"Jaime Vives Piqueres" <jai### [at] ignoranciaorg> wrote in message
news:3B7931DD.EAA07078@ignorancia.org...
>
>  The same, but without the comment... ;)

LOL


Post a reply to this message

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