POV-Ray : Newsgroups : povray.binaries.images : A Question : Re: A Question Server Time
2 Nov 2024 10:18:33 EDT (-0400)
  Re: A Question  
From: Samuel Benge
Date: 17 Jan 2011 18:15:01
Message: <web.4d34cca5a5aa5444312f6b340@news.povray.org>
Ack, there was a glaring error with the code I posted. Here's a fully-working
version (c:

/*

  basalt.pov

  2011 Samuel Benge

  A quick basalt height map generator. Render with +rng or hf_gray_16

*/

#include "functions.inc"
#include "math.inc"


// user variables

#declare N_Rows = 20;          // this determines the number of columns
#declare N_Extra_Columns = 0; // how many columns to randomly add
#declare Jitter    = .5;    // makes everything a bit more natural

#declare Height_Function = // your height function here
  function{
    f_ridged_mf(x*3, y*3, z*3, 0.6, 3, 7, 0.7, 0.7, 2)
  }

// ~user variables


#default{ finish{ ambient 1 } }

camera{
 orthographic
 right x*2 up y*2
 location -z*10
}

union{
  #declare R = seed(1001);
  #declare Z = -int(N_Rows*1.4/2);
  #while(Z<=int(N_Rows*1.4/2))
    #declare X = -int(N_Rows/2);
    #while(X<=int(N_Rows/2))
      cone{0,0,-y,2/N_Rows
        #local Vec =
          <
            X+odd(Z)/2+rand(R)*Jitter,
            0,
            Z+rand(R)*Jitter
          >/N_Rows*<1,1,sin(pi*2/3)>*2;
        #declare XV = Vec.x;
        #declare ZV = Vec.z;
        translate Vec
        pigment{rgb Height_Function(XV,0,ZV).x}
      }
      #declare X=X+1;
    #end
    #declare Z=Z+1;
  #end

  // extra columns
  #declare V=0;
  #while(V<N_Extra_Columns)
    cone{0,0,-y,2/N_Rows
      #local Vec = <-1+rand(R)*2, 0, -1+rand(R)*2>;
      #declare XV = Vec.x;
      #declare ZV = Vec.z;
      translate Vec
      pigment{rgb Height_Function(XV,0,ZV).x}
    }
    #declare V=V+1;
  #end
  rotate x*270
}

// ~basalt.pov


Post a reply to this message

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