POV-Ray : Newsgroups : povray.binaries.images : rendering height fields with overhangs : Re: a less buggy hf_slicer Server Time
22 Jun 2024 23:45:24 EDT (-0400)
  Re: a less buggy hf_slicer  
From: Tor Olav Kristensen
Date: 18 Dec 2009 19:15:00
Message: <web.4b2c1ab75f6b9df6a049a19e0@news.povray.org>
stbenge <UN### [at] hotmailcom> wrote:
> 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.

Hi Samuel

I had a look at your macro to see if I could make it more efficient.
Here's what I came up with:


#macro SliceHF(HeightField, ControlPigment, NrOfSlices)

  #local Step = 1/NrOfSlices;
  #local M_Fn = function { pigment { ControlPigment } }
  #local N_Fn = function(_C) { M_Fn(0, _C*Step, 0).gray }

  union {
    #local Cn = 0;
    #local Dn = N_Fn(Cn);
    #while (Cn < NrOfSlices)
      #local Cp = Cn;
      #local Cn = Cn + 1;
      #local Dp = Dn;
      #local Dn = N_Fn(Cn);
      #if (Dn != Dp)
        intersection {
          object { HeightField }
          box { <0, Dp, 0>, <1, Dn, 1> }
          translate -Dp*y
          scale <1, Step/(Dn - Dp), 1>
          translate Cp*Step*y
        }
      #end // if
    #end // while
  }

#end // macro SliceHF


But I'm not sure if it still works like you intended.

--
Tor Olav
http://subcube.com


Post a reply to this message

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