POV-Ray : Newsgroups : povray.newusers : bicubic patch editor : Re: bicubic patch editor Server Time
13 Apr 2025 07:21:45 EDT (-0400)
  Re: bicubic patch editor  
From: Tor Olav Kristensen
Date: 3 Apr 2025 19:30:00
Message: <web.67ef19a941fe04443a63f5189db30a9@news.povray.org>
Hi Gulino

Below is my suggestion for some code for you to start with.

The grass-like "texture" is made like Bald Eagle suggested,
but the shape of the terrain is made with a sum of some simpler
f_noise3d() functions at different sample frequencies.

--
Tor Olav
http://subcube.com
https://github.com/t-o-k


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#version 3.7;

#include "functions.inc"
#include "colors.inc"

global_settings {
    assumed_gamma 1.0
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare GrassFn =
    function {
        pattern {
            bumps
            scale <1.0e-8, 1.0, 1.0e-8>
        }
    }
;

// Frequency multipliers
#declare Ma = pow(2, 0);
#declare Mb = pow(2, 1);
#declare Mc = pow(2, 2);
#declare Md = pow(2, 3);

// Noise sampling offsets
#declare Ya =  0.0;
#declare Yb = -1.2; // +2.0
#declare Yc =  0.0;
#declare Yd =  0.0;

#declare FnA = function { f_noise3d(Ma*x, Ya, Ma*z) };
#declare FnB = function { f_noise3d(Mb*x, Yb, Mb*z) };
#declare FnC = function { f_noise3d(Mc*x, Yc, Mc*z) };
#declare FnD = function { f_noise3d(Md*x, Yd, Md*z) };

// Frequency amplitudes
#declare Ka = 0.0;
#declare Kb = 2.0;
#declare Kc = 0.3; // 1.6
#declare Kd = 0.1;

#declare GrassHeight = 0.04;

#declare K = 1.0 + Ka + Kb + Kc + Kd + GrassHeight;

#declare TerrainFn =
    function {
        (
            1.0*y
            + Ka*FnA(x, 0.0, z)
            + Kb*FnB(x, 0.0, z)
            + Kc*FnC(x, 0.0, z)
            + Kd*FnD(x, 0.0, z)
            + GrassHeight*GrassFn(x, 0.0, z)
        )/K // To avoid "wrap around"
    }
;

union {
    height_field {
        function 1000, 1000 { TerrainFn(x, 0.0, 1.0 - y) }
        smooth
        pigment {
            function { FnC(x, 0, z) }
            color_map {
                [ 0.1 color rgb <1.0, 0.7, 0.0> ]
                [ 0.6 color rgb <0.3, 0.5, 0.0> ]
            }
        }
        // pigment { color rgb <0.6, 0.8, 0.0> }
        // no_shadow
    }
    union {
        #for (X, 0, 1, 1/32)
            #for (Z, 0, 1, 1/32)
                #declare Y = TerrainFn(X, 0, Z);
                sphere { <X, Y, Z>, 0.005 }
            #end // for
        #end // for
        pigment { color White }
    }
    translate -<1, 0, 1>/2
    scale 1000*<1, 1, 1>
}

box {
    <-1e8, -10, -1e8>, <+1e8, 0, +1e8>
    pigment { color SeaGreen }
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

sky_sphere {
    pigment { color SkyBlue }
}

light_source {
    1e8*<-2, +1, -7>
    color White
}

#declare AspectRatio = image_width/image_height;

camera {
    right AspectRatio*x
    location < 0, +700, -1400>*0.8
    look_at < 0,  +450,  0>
    // angle 40
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

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