POV-Ray : Newsgroups : povray.binaries.images : Homebrew heightfields Server Time
28 Mar 2024 08:30:13 EDT (-0400)
  Homebrew heightfields (Message 1 to 8 of 8)  
From: Bill Pragnell
Subject: Homebrew heightfields
Date: 21 Mar 2019 18:30:01
Message: <web.5c940f83e043b4691b6c6b3a0@news.povray.org>
I've been tinkering with homemade heightfield objects. I'm sure I had a specific
need at one point, but it soon became yet another project for its own sake.
Motivation: I don't really get on with the standard heightfield object, because
they're fiddly to transform into what/where you want, and I usually want to use
a function, which then has to get inversely transformed to keep pace etc.

I've knocked up my own version, creating a mesh2 between two points in the x-z
plane, optionally with sides, normals, gaussian smoothing, save out to .inc file
and an extra stage of perturbation based on a pigment (which might sound
familiar to some of you).

The image attached here also takes an extra step by using a (functionally
laborious) rounded rectangular dropoff and mating it with a rounded box to make
a tile.

Still work in progress. I can share the code once I've tidied it up if anybody's
interested.

Bill


Post a reply to this message


Attachments:
Download 'woodcrackle.jpg' (141 KB)

Preview of image 'woodcrackle.jpg'
woodcrackle.jpg


 

From: Bill Pragnell
Subject: Re: Homebrew heightfields
Date: 21 Mar 2019 18:50:00
Message: <web.5c9414596dda92c81b6c6b3a0@news.povray.org>
And here's an illustration of the other main heightfield type - an overlay onto
actual geometry using trace(). The macro takes an object identifier, and drops
vertices onto it instead of using a function, also employing the aforementioned
swathe of options.

Bill


Post a reply to this message


Attachments:
Download 'montage.jpg' (158 KB)

Preview of image 'montage.jpg'
montage.jpg


 

From: ingo
Subject: Re: Homebrew heightfields
Date: 22 Mar 2019 02:55:35
Message: <XnsAA1A50A25F90Fseed7@news.povray.org>
in news:web.5c940f83e043b4691b6c6b3a0@news.povray.org Bill Pragnell wrote:

> I've been tinkering with homemade heightfield objects

Mesh2 HF's can easily be done with meshmaker.inc use a parametric square 
plus pigment function. Here's a crackle cylinder 
http://chiselapp.com/user/ingo/repository/POV-Ray-
Various/artifact/d1ded5236d5a44f8

You may have to change it a bit as for the inclusion in the distrubution 
Friedrich changed a few things. For some reason the demoscenes where never 
included.

ingo


Post a reply to this message

From: ingo
Subject: Re: Homebrew heightfields
Date: 22 Mar 2019 05:15:52
Message: <XnsAA1A686B3BD7Cseed7@news.povray.org>
in news:web.5c9414596dda92c81b6c6b3a0@news.povray.org Bill Pragnell wrote:

> using trace()

For fun, trace not straight down but with an angle, you'll get strange 
skewed HF's,

ingo


Post a reply to this message

From: Bill Pragnell
Subject: Re: Homebrew heightfields
Date: 22 Mar 2019 06:00:00
Message: <web.5c94b1c06dda92c81b6c6b3a0@news.povray.org>
ingo <ing### [at] tagpovrayorg> wrote:
> Mesh2 HF's can easily be done with meshmaker.inc use a parametric square
> plus pigment function. Here's a crackle cylinder
> http://chiselapp.com/user/ingo/repository/POV-Ray-
> Various/artifact/d1ded5236d5a44f8

Ha, not an option I'd considered. Looks like quite a roundabout way of doing it,
although I guess it's far less code than I've ended up with.

I might mess with the trace rays to see what it looks like. Could do the
something similar with the gaussian or the final perturbation too.

Bill


Post a reply to this message

From: ingo
Subject: Re: Homebrew heightfields
Date: 23 Mar 2019 04:03:36
Message: <XnsAA1B5C2AAB745seed7@news.povray.org>
in news:web.5c94b1c06dda92c81b6c6b3a0@news.povray.org Bill Pragnell
wrote: 

> Ha, not an option I'd considered. Looks like quite a roundabout way
> of doing it, 

The other option is to use TwoVarSurf from meshmaker.inc

an example:
http://chiselapp.com/user/ingo/repository/POV-Ray-
Various/artifact/537ee12ca557206e

I.i.r.c you can also declare a macro (with trace) as __Fuv. You may have 
to fiddle a bit with that though.

ingo


Post a reply to this message

From: ingo
Subject: Re: Homebrew heightfields
Date: 23 Mar 2019 04:26:19
Message: <XnsAA1B6004EE959seed7@news.povray.org>
in news:XnsAA1B5C2AAB745seed7@news.povray.org ingo wrote:

> I.i.r.c you can also declare a macro (with trace) as __Fuv. You may
> have to fiddle a bit with that though.
> 
> 

Had a quick look. TwoVarSurf part of makesmesh.inc has to changed a bit 
for that, file below. It doesn't change anything for existing scenes, but 
makes it possible to declare the macor __Fuv and use that together with 
TwoVarSurfCalc().
Also added the documentation that is missing in the distribution.


---%<------%<------%<---
// former "twovar.inc"

TwoVarSurf(__Fuv, Urange, Vrange, Iter_U, Iter_V, FileName): Builds a 
mesh2 surface of
           a function with two variables (u,v).
__Fuv    : the function to be turned into a mesh2.
Urange   : A 2-D vector that gives the boundaries of u.
Vrange   : A 2-D vector that gives the boundaries of v. These are the 
ranges
           within whitch the surface is calculated. 
Iter_U   : Sets the resolution of the mesh in the u range.
Iter_V   : Sets the resolution of the mesh in the v range.
FileName : The name of the file to whitch the mesh will be written. If is 
an
           empty string (""), no file will be written.
           If the file extension is 'obj' a Wavefront objectfile will be 
written.
           If the extension is 'pcm' a compressed mesh file is written.
           If a file name is given, the macro will first check if it 
already exists.
           If that is so, it will try to parse the existing file unless 
it's a '*.obj',
           '*.pcm' or '*.arr' file as POV-Ray can not read them directly. 
In this case a new
           mesh will be generated, but the existing files will _not_ be 
over-written.
Use:

   #include twovar.inc
   
   #declare __Fuv=function(u,v){(10*sin((u^2+v^3)^0.5))/(2+cos((u^2+y^2)^
0.5))}
   
   object {
      TwoVarSurf(<-6,6>,<-6,6>,20,20,"")
      uv_mapping
      pigment{checker color rgb <0,0,0.2> color rgb <1,0.85,0.85> scale 
0.5}
      finish{specular 0.4}
      rotate <-110,45,0>
   }           
*/

#macro TwoVarSurf(__Fuv__, Urange, Vrange, Iter_U, Iter_V, FileName)
   #ifdef(__Fuv) #undef __Fuv #end
   #declare __Fuv= function(u,v){__Fuv__(u,v)} 
   TwoVarSurfCalc(Urange, Vrange, Iter_U, Iter_V, FileName)
#end

#macro TwoVarSurfCalc(Urange, Vrange, Iter_U, Iter_V, FileName)
   #declare Build=CheckFileName(FileName);
   #if(Build=0)
      #debug concat("\n Parsing mesh2 from file: ", FileName, "\n")
      #include FileName
      object{Surface}
   #else
      #local Umin=Urange.u;
      #local Umax=Urange.v;
      #local Vmin=Vrange.u;
      #local Vmax=Vrange.v;
      #local dU=Umax-Umin;
      #local dV=Vmax-Vmin;
      #local iU=dU/Iter_U;
      #local iV=dV/Iter_V;
      #local NumVertices=(Iter_U+1)*(Iter_V+1);
      #declare NumFaces=Iter_U*Iter_V*2;
      #debug concat("\n Calculating ",str(NumVertices,0,0)," vertices for 
", str(NumFaces,0,0)," triangles\n\n")
      #local VecArr=array[NumVertices] 
      #local NormArr=array[NumVertices] 
      #local UVArr=array[NumVertices]
      #local Count=0;   
      #local I=0;  
      #while (I<Iter_V+1)
         #local V=RangeMM(I,0,Iter_V,Vmin,Vmax);
         #local J=0;
         #while (J<Iter_U+1)
            #local U=RangeMM(J,0,Iter_U,Umin,Umax);
            #if(J=0)
               #local P0=<U,V,__Fuv(U,V)>;
               #local P2=<U-iU,V,__Fuv(U-iU,V)>;
            #else
               #local P0=P1;
               #local P2=P0;
            #end
            #local P1=<U+iU,V,__Fuv(U+iU,V)>;
            #local P3=<U,V+iV,__Fuv(U,V+iV)>;
            #local P4=<U,V-iV,__Fuv(U,V-iV)>;
            #local B1=P4-P0;
            #local B2=P2-P0;
            #local B3=P3-P0;
            #local B4=P1-P0;
            #local N1=vcross(B1,B2);
            #local N2=vcross(B2,B3);
            #local N3=vcross(B3,B4);
            #local N4=vcross(B4,B1);
            #local Norm=vnormalize((N1+N2+N3+N4));
            #local VecArr[Count]=P0;  
            #local NormArr[Count]=Norm;  
            #local UVArr[Count]=<(U-Umin)/dU,(V-Vmin)/dV>;
            #local Count=Count+1;
            #local J=J+1;            
         #end
         #debug concat("\r Done ", str(Count,0,0)," vertices : ",str(100
*Count/NumVertices,0,2)," %")
         #local I=I+1;
      #end
      BuildWriteMesh2(VecArr, NormArr, UVArr, Iter_U, Iter_V, FileName)
   #end
#end


Post a reply to this message

From: Paolo Gibellini
Subject: Re: Homebrew heightfields
Date: 25 Mar 2019 10:09:17
Message: <5c98e10d$1@news.povray.org>
Bill Pragnell wrote on 21/03/2019 23:46:
> And here's an illustration of the other main heightfield type - an overlay onto
> actual geometry using trace(). The macro takes an object identifier, and drops
> vertices onto it instead of using a function, also employing the aforementioned
> swathe of options.
> 
> Bill
> 
Well, it could be useful for a lot of interesting works: the Barbapapa 
home, a Hobbit hole, the Dark Crystal village, Tatooine homes...
I like it,
;-)
Paolo


Post a reply to this message

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