POV-Ray : Newsgroups : povray.general : 24 bit heightfields : Re: 24 bit heightfields Server Time
30 Jul 2024 20:30:31 EDT (-0400)
  Re: 24 bit heightfields  
From: SharkD
Date: 11 Dec 2008 20:10:00
Message: <web.4941b8ef869f689fb47ee9210@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> Nicolas Alvarez <nic### [at] gmailcom> wrote:
> > SharkD wrote:
> > > I generated the following heightfield in some program or other. It uses
> > > all 24 bits for elevation information. My question is, how are the
> > > colors/height data organized? I would like to create a pigment that
> > > produces similar maps.
> >
> > Seems similar to the POV-Ray TGA heightfields, except using all three
> > channels instead of two.
> >
> > Basically, red*256*256 + green*256 + blue = 24-bit grayscale value.
>
> How would I create this type of pigment? Thanks.
>
> -Mike

OK, here's the pigment:

#local hf_pigment_function_pow = function {y * pow(256,3)}
#local hf_pigment_function_b = function {mod(hf_pigment_function_pow(x,y,z),
pow(256,1))}
#local hf_pigment_function_g = function {mod(hf_pigment_function_pow(x,y,z) -
hf_pigment_function_b(x,y,z), pow(256,2))}
#local hf_pigment_function_r = function {mod(hf_pigment_function_pow(x,y,z) -
hf_pigment_function_b(x,y,z) - hf_pigment_function_g(x,y,z), pow(256,3))}

#local hf_pigment_b = pigment
{
 function {hf_pigment_function_b(x,y,z) / pow(256,1)}
 color_map {[0 rgb 0][1 rgb z]}
}
#local hf_pigment_g = pigment
{
 function {hf_pigment_function_g(x,y,z) / pow(256,2)}
 color_map {[0 rgb 0][1 rgb y]}
}
#local hf_pigment_r = pigment
{
 function {hf_pigment_function_r(x,y,z) / pow(256,3)}
 color_map {[0 rgb 0][1 rgb x]}
}

// This is the one you want
#local hf_pigment_rgb = pigment
{
 average
 pigment_map {[3 hf_pigment_b][3 hf_pigment_g][3 hf_pigment_r]}
}


Post a reply to this message

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