POV-Ray : Newsgroups : povray.binaries.images : rendering height fields with overhangs : a less buggy hf_slicer Server Time
22 Jun 2024 23:02:28 EDT (-0400)
  a less buggy hf_slicer  
From: stbenge
Date: 17 Dec 2009 20:40:28
Message: <4b2add8c@news.povray.org>
Those other ones were quite buggy. Odd numbers wouldn't work, the 
function for testing the control pigment wasn't accurate, and the thing 
was not filling a unit cube correctly.

While testing this, also I realized that the more it stretches a 
height_field, the slower it becomes. I wish I could make it more 
efficient somehow.

#macro hf_slicer(hfs, hfs_control_pigment, hfs_n_slices)
  #local hfs_n_slices=hfs_n_slices-1;
  #local hfs_incre=1/(hfs_n_slices+1.001);
  #local hfs_function=function{pigment{hfs_control_pigment}}
  #local hfs_p1=0;
  #local hfs_V=0;
  union{
   #local hfs_counter=0;
   #while(hfs_counter<=hfs_n_slices)
    #local hfs_pv=hfs_function(0,(hfs_V+1/hfs_n_slices),0).x;
    #local hfs_p2=hfs_p1;
    #local hfs_p1=hfs_pv;
    object{hfs
     #if(hfs_p1>hfs_p2)
      clipped_by{plane{y,hfs_p1}} clipped_by{plane{y,hfs_p2 inverse}}
     #else
      clipped_by{plane{y,hfs_p1 inverse}} clipped_by{plane{y,hfs_p2}}
     #end
     translate -y*hfs_p2
     scale<1,hfs_incre/(hfs_p1-hfs_p2),1>
     translate y*hfs_V
    }
    #local hfs_V=hfs_V+hfs_incre;
    #local hfs_counter=hfs_counter+1;
   #end
  }
#end


Post a reply to this message


Attachments:
Download 'hf_slicer_5_27.jpg' (35 KB)

Preview of image 'hf_slicer_5_27.jpg'
hf_slicer_5_27.jpg


 

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