|
|
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
|
|