POV-Ray : Newsgroups : povray.advanced-users : HDR images as functions: is this right? : HDR images as functions: is this right? Server Time
27 Jun 2024 14:05:49 EDT (-0400)
  HDR images as functions: is this right?  
From: stbenge
Date: 27 Jan 2011 14:01:15
Message: <4d41c0fb@news.povray.org>
Hello,

I'm looking for a proper way to convert an HDR image into a function and 
then back into a pigment.

The problem:

  HDR images, when used as functions, produce color banding due to 
clipped (wrapped) color values. This is the typical behavior of 
functions, and should be expected.

My solution:

  Divide the image function by 255 and multiply each channel's color by 255:

  #declare F_IMG =
  function{
   pigment{
    image_map{ hdr "some_img.hdr" }
   }
  }
  average
  pigment_map{
   [1
    function{ F_IMG(x,y,0).x/255 }
    color_map{[0 rgb 0][1 rgb x*255*3]}
   ]
   [1
    function{ F_IMG(x,y,0).y/255 }
    color_map{[0 rgb 0][1 rgb y*255*3]}
   ]
   [1
    function{ F_IMG(x,y,0).z/255 }
    color_map{[0 rgb 0][1 rgb z*255*3]}
   ]
  }

I have constrasted the result against a PNG image using a reflective 
sphere, and also with with my lb7b file for adding glare to images. This 
solution seems to preserve the original range and intensity of the HDR 
image.

So my question is this: does this method seem alright to you? Is there a 
better way? Is my math faulty?

Sam


Post a reply to this message

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