POV-Ray : Newsgroups : povray.binaries.images : Journey to an Unknown region [ wip 3] : Re: Journey to an Unknown region [ wip 3] Server Time
31 Jul 2024 08:19:56 EDT (-0400)
  Re: Journey to an Unknown region [ wip 3]  
From: Christian Froeschlin
Date: 21 Dec 2009 17:18:29
Message: <4b2ff435@news.povray.org>
Thomas de Groot wrote:

> Your two ideas are interesting to pursue further. The first would be 
> difficult to get really right, but I shall nevertheless give it a thought. 

I just played a bit with adding sub-height_fields
on top of a main height_field and came up with this:

// *** SUB_HF *** Add detail to part of another height_field
//
// F_BASE:    Function describing the main height field
// F_SUB:     Structure of the overlaid subfield.
// F_MERGE:   Function for merging the seams. This should be smooth
//            and evaluate to 0 on the border of the unit square.
// SUB_SCALE: Strength of overlaid substructure for convenience
// SUB_?_???: Rectangle specifying the portion of the main field.
#macro SUB_HF(F_BASE,F_SUB,F_MERGE,SUB_SCALE,
               SUB_X_MIN,SUB_X_MAX,SUB_Z_MIN,SUB_Z_MAX)

   #local sub_x_min = SUB_X_MIN;
   #local sub_x_max = SUB_X_MAX;
   #local sub_z_min = 1-SUB_Z_MIN;
   #local sub_z_max = 1-SUB_Z_MAX;
   #local sub_x_ext = sub_x_max - sub_x_min;
   #local sub_z_ext = sub_z_max - sub_z_min;

   height_field
   {
     function 512, 512
     {
       0.5*f1(sub_x_min + x*sub_x_ext,sub_z_min+y*sub_z_ext) +
       0.5*SUB_SCALE*f_merge(x,y) * f2(x,y)
     }
     scale     <sub_x_ext,2,sub_z_ext>
     translate <sub_x_min,0.001,1-sub_z_max>
   }

#end



Sample usage:

#declare f1 = function(x,z) {f_bozo(x*10,0,z*10)};
#declare f2 = function(x,z) {f_bozo(x*50,0,z*50)};
#declare f_merge = function(x,z){f_spherical(2*(x-0.5),0,2*(z-0.5))};

union
{
   height_field {function 512, 512 {f1(x,y)}}
   object {SUB_HF(f1,f2,f_merge,0.3,0.6,0.7,0.1,0.3) pigment {color Red}}
   object {SUB_HF(f1,f2,f_merge,0.2,0.2,0.3,0.6,0.8) pigment {color 
Red}}
   scale 0.5 * y
   pigment {color White}
}


Post a reply to this message

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