POV-Ray : Newsgroups : povray.binaries.images : Cloudscape : Re: Cloudscape Server Time
23 Apr 2024 22:14:11 EDT (-0400)
  Re: Cloudscape  
From: Bruno Cabasson
Date: 7 Dec 2019 11:00:01
Message: <web.5debcaa65bb70f08dc39a140@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Bruno Cabasson" <bru### [at] cabassoncom> wrote:
> > ... I was lacking specific built-in functions that can
> > express density for the medias involed within a spherical shell.
>
> > ... (wish it were native ...).
>
> > -) Another would be a series of classical patterns (wrinkles works quite fine),
> > but contained in a spherial shell. I hope it can be expressed mathematically.
>
> I think all of that is certainly doable.
>
> If you take whatever pattern you want to use, you can wrap it around into a
> sphere using polar coordinates, as Mike Williams shows here:
>
> #declare F=function {f_mesh1
>   (x, y, z, 0.15, 0.15, 1, 0.02, 1) - 0.03}
>
> isosurface {
>   function { F(f_ph(x,y,z), f_r(x,y,z)-1, f_th(x,y,z)) }
>   ...
>
> http://www.econym.demon.co.uk/isotut/substitute.htm
>
>
> and as I'm sure you already know, all manner of new functions can obviously be
> integrated into a scene, if you try hard enough, for long enough.
>
>
http://news.povray.org/povray.binaries.images/thread/%3Cweb.5d3c5fe27be432e04eec112d0%40news.povray.org%3E/?ttop=4289
26
>
>
>
> Perhaps you could start by making a proof-of-concept include file with the
> density functions, and then maybe that could be translated to source by Jerome
> Grimbert, Bill Pokorny, or someone else who understands the necessary changes
> and additions to be done in the various places.
>
> If there's a simple density pattern that you'd like to try in source, maybe see
> about just replacing the definition for one of the native POV-Ray patterns that
> is redundant (there are 2 or 3) and use that as your cloud pattern.  Then just
> make a POV-Ray build with those edits and see how it works.
>
> If I understand things correctly, the new source is hellish to follow, due to
> the the threading, but the older versions are simpler and more straightforward.
>
> Bill

Since all that time, I never dared to really dive into POV-Ray source code and
make a build ... Maybe I'll give it a try someday.

Mike William's tutorial is nothing but marvelous. However, I don't thing a
coordinate change will make much difference and I guess this will lead to a
scaling problem. I try to model real world and my Earth is a sphere of 6378 km
in radius. Size of clouds is some 100's meters ...


As my scene file is quite short, I produce the code here. Perhaps one can
play with the (quite numerous) tweaking variables, in the "USER DECLARATIONS"
section, in particular the SUN_ELEVATIONS array (change first value), and the
USE_LAYER_xxx variables.


// Persistence of Vision Ray Tracer Scene Description File
// File: cloudscape.pov
// Vers: 3.8
// Desc: Cloudscape experiment
// Date: 2019
// Auth: Bruno Cabasson
// +bs8 +a0.05 +am3 +ac0.99 +r4


#version 3.8

#include "colors.inc"

global_settings
{
  assumed_gamma 1
  max_trace_level 50
}

#default {finish{ambient 0}}

// ======================== ENGINE DECLARATIONS ===============================
// General constants
#declare m = 1;
#declare km = 1000*m;
#declare cm = 0.01*m;

// Earth
#declare Re = 6378*km;

// Cameras
#declare VIEW_CAM = 0;
#declare FISHEYE_CAM = 1;
#declare ALTITUDE_CAM = 2;

// Atmosphere density function A*exp(-kh/T), h being height wrt ground (whish it
were native ...).
#declare shell_exp = function (x, y, z, _h, _t, _a, _k, _R)
{
    _a*exp(-_k*(sqrt(x*x+(y+_R)*(y+_R)+z*z) - (_h + _R))/_t)
}
// ====================== END OF ENGINE DECLARATIONS ==========================


// ======================== USER DECLARATIONS ===============================
#declare QUICK = yes;

// Camera
#declare CAM_HEADING = 0;
#declare CAM_ELEVATION = 10;
#declare CAM_ANGLE = 80;
#declare CAM_H = 2*m;
#declare CAM = VIEW_CAM;

// Radiosity
#declare USE_RAD = yes;
#declare RAD_BRIGHTNESS = 1.5;
#declare RAD_QUICK_COUNT = 50;
#declare RAD_COUNT = 400;
#declare RAD_USE_NOCACHE = no;
#declare RAD_START = 0.08;
#declare RAD_PASSES = 4;
#declare RAD_RECURSION_LIMIT = 2;

// Sun
#declare SUN_ELEVATIONS = array [7] {1.5, 3, 12, 20, 5, 0.5, -0.5};
#declare SUN_HEADING = 0;
#declare SUN_POWER = 0.5;

// Atmosphere
#declare Ta = 50*km;
#declare Ha = -1*cm;
#declare LAMBDA_VIOLET = 380;
#declare LAMBDA_BLUE = 440;
#declare LAMBDA_GREEN = 510;
#declare LAMBDA_RED = 650;
#declare BASE_SKY_COLOR = rgb vnormalize(<pow(LAMBDA_VIOLET/LAMBDA_RED, 4),
pow(LAMBDA_VIOLET/LAMBDA_GREEN, 4),  pow(LAMBDA_VIOLET/LAMBDA_BLUE, 4)>);
#declare DENSITY_POWER_FACTOR = 1;
#declare ATMO_INTERVALS = 1;
#declare ATMO_SAMPLES = 20;
#declare ATMO_QUICK_INTERVALS = 1;
#declare ATMO_QUICK_SAMPLES = 5;
#declare TURBIDITY = 1;

// Layers
#declare USE_LAYER_1 = no;
#declare USE_LAYER_2 = yes;
#declare USE_LAYER_3 = no           ;
#declare USE_LAYER_FOG = yes;

// Layer 1: high low-density clouds
#declare L1_H = 8000*m;
#declare L1_T = 800*m;
#declare L1_SCATTERING_TYPE = 3;
#declare L1_SCATTERING = 3;
#declare L1_SCATTERING_COLOR = White;
#declare L1_ABSORPTION = 0.1;
#declare L1_ABSORPTION_COLOR = White;
#declare L1_METHOD = 3;
#declare L1_INTERVALS = 3;
#declare L1_SAMPLES = 5;
#declare L1_QUICK_INTERVALS = 1;
#declare L1_QUICK_SAMPLES = 5;
#declare L1_DENSITY = density
{
    granite
    scale <40, 1, 10>
    warp {turbulence 0.1 octaves 10 lambda 2 omega 0.65}
    scale L1_T
    rotate 30*y
    translate 5500*m*x
    color_map {[0.12 rgb 1][0.17 rgb 0]}
}

// Layer 2: main clouds : normal height quite opaque cloud cover
#declare L2_H = 800*m;
#declare L2_T = 400*m;
#declare L2_SCATTERING_TYPE = 2;
#declare L2_SCATTERING = 0.5;
#declare L2_SCATTERING_COLOR = White;
#declare L2_ABSORPTION = 0.1;
#declare L2_ABSORPTION_COLOR = White;
#declare L2_METHOD = 3;
#declare L2_INTERVALS = 3;
#declare L2_SAMPLES = 30;
#declare L2_QUICK_INTERVALS = 1;
#declare L2_QUICK_SAMPLES = 50;
#declare L2_DENSITY = density
{
    wrinkles translate <3, 6, 9>
    scale <10, 1, 10>
    warp {turbulence 0.2 octaves 10 lambda 2.1 omega 0.65}
    scale L2_T
    translate 6500*m*z + 8500*m*x
    color_map {[0.15 rgb 0.08/L2_T][0.6 rgb 0.3/L2_T][0.7 rgb 1]}
}

// Layer 3: Ground-to-Layer2 haze for scattering beams
#declare L3_H = 1*cm;
#declare L3_T = L2_H - L3_H - 1*m;
#declare L3_SCATTERING_TYPE = 2;
#declare L3_SCATTERING = 1;
#declare L3_SCATTERING_COLOR = White;
#declare L3_ABSORPTION = 0.1;
#declare L3_ABSORPTION_COLOR = White;
#declare L3_METHOD = 3;
#declare L3_INTERVALS = 1;
#declare L3_SAMPLES = 20;
#declare L3_QUICK_INTERVALS = 1;
#declare L3_QUICK_SAMPLES = 10;
#declare L3_DENSITY = density
{
    function {shell_exp(x, y, z, L3_H, L3_T, 0.1, 1.5, Re)}
}

// Fog layer
#declare FOG_H =  1*cm;
#declare FOG_T = 50*m;
#declare FOG_SCATTERING_TYPE = 1;
#declare FOG_SCATTERING = 1;
#declare FOG_SCATTERING_COLOR = White;
#declare FOG_ABSORPTION = 0.2;
#declare FOG_ABSORPTION_COLOR = White;
#declare FOG_METHOD = 3;
#declare FOG_INTERVALS = 1;
#declare FOG_SAMPLES = 40;
#declare FOG_QUICK_INTERVALS = 1;
#declare FOG_QUICK_SAMPLES = 20;
#declare FOG_DENSITY = density
{
    function{shell_exp(x, y, z, FOG_H, FOG_T, 0.15, 1.5, Re)}
}

// ====================== END OF DECLARATIONS ==========================


// ====================== ENGINE ==========================

// Radiosity
#if (USE_RAD)
global_settings
{
  radiosity
  {
    media on
    brightness RAD_BRIGHTNESS
    #if (QUICK)
        count RAD_QUICK_COUNT
        recursion_limit 1
    #else
        count RAD_COUNT
        recursion_limit RAD_RECURSION_LIMIT
    #end
    #if (RAD_USE_NOCACHE)
        no_cache
    #else
        pretrace_start RAD_START
        pretrace_end RAD_START/pow(2, RAD_PASSES - 1)
        nearest_count 20
        error_bound 1
        low_error_factor 0.8
        minimum_reuse 0.25
        adc_bailout 0.01/2
    #end
  }
}
#end

#if (clock_on)
    #declare SUN_ELEVATION = SUN_ELEVATIONS[frame_number-1];
#else
    #declare SUN_ELEVATION = SUN_ELEVATIONS[0];
#end


#declare ViewCam = camera
{
  location  0
  angle CAM_ANGLE
  right     x*image_width/image_height
  look_at   z
  rotate -CAM_ELEVATION*x
  rotate CAM_HEADING*y
  translate CAM_H*y
}

#declare FisheyeCam = camera
{
  fisheye
  location  0
  angle 180
  right     x*image_width/image_height
  look_at   z
  rotate -90*x
  rotate CAM_HEADING*y
  translate CAM_H*y
}

#declare AltitudeCam = camera
{
  location  0
  angle CAM_ANGLE
  right     x*image_width/image_height
  look_at   -y
  translate 100*Ta*y
}

#declare Cams = array[3] {ViewCam, FisheyeCam, AltitudeCam}
camera {Cams[CAM]}


// Ground
#declare Earth = sphere
{
    0, Re
    pigment {White}
    finish {diffuse 1}
    translate -Re*y
}

//Sun
#declare SUN_BASE_POWER = 1;
#declare SUN_COLOR = White;
#declare Sun = light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb SUN_BASE_POWER*SUN_POWER*SUN_COLOR  // light's color
  //area_light 3800*x, 3800*y, 6, 6  adaptive 1 circular orient
  looks_like {sphere{0, 2000*km pigment{color rgb 1} finish {diffuse 0 emission
10}}}
  translate 150000*km*z
  media_attenuation on
  parallel point_at -z
  rotate -SUN_ELEVATION*x
  rotate SUN_HEADING*y
}

// Atmosphere
#declare DENSITY_BASE_POWER = 4;
#declare AtmoScatterColor = BASE_SKY_COLOR;

#if (QUICK)
    #declare AtmoIntervals = ATMO_QUICK_INTERVALS;
    #declare AtmoSamples = ATMO_QUICK_SAMPLES;
#else
    #declare AtmoIntervals = ATMO_INTERVALS;
    #declare AtmoSamples = ATMO_SAMPLES;
#end

#declare M_Rayleigh = media
{
    method 3 intervals AtmoIntervals samples AtmoSamples jitter 0 variance 1/256
    scattering {4, color AtmoScatterColor/Ta extinction 1}
    density
    {
        function{shell_exp(x, y, z, Ha, Ta, TURBIDITY,
DENSITY_POWER_FACTOR*DENSITY_BASE_POWER, Re)}
    }
}


#declare Atmo = difference
{
    difference
    {
        sphere {0, Re + Ha + Ta translate -Re*y}
        sphere {0, Re + 0.01*m  translate -Re*y}
    }

    hollow
    pigment {rgbt 1}
    interior
    {
        media {M_Rayleigh}
    }
}

// Layers
#macro MakeLayer (_h, _thick, _type, _scatter, _scatter_color,  _absorb,
_absorb_color, _density, _method, _intervals, _samples)
    #local _ret = difference
    {
        sphere {0, Re + _h + _thick translate -Re*y}
        sphere {0, Re + _h translate -Re*y}
        hollow
        pigment {rgbt 1}
        interior
        {
            media
            {
                method _method
                intervals _intervals
                samples max(_samples/5, 5), _samples
                jitter 0
                variance 1/1024
                confidence 0.99
                #if (_scatter != 0) scattering {_type,
_scatter*_scatter_color/_thick extinction 0.25 } #end
                #if (_absorb != 0) absorption _absorb*_absorb_color/_thick #end
                density {_density}
            }
        }
    }
    _ret
#end

#if (QUICK)
    #declare L1Intervals = L1_QUICK_INTERVALS;
    #declare L1Samples = L1_QUICK_SAMPLES;
    #declare L2Intervals = L2_QUICK_INTERVALS;
    #declare L2Samples = L2_QUICK_SAMPLES;
    #declare L3Intervals = L3_QUICK_INTERVALS;
    #declare L3Samples = L3_QUICK_SAMPLES;
    #declare FOGIntervals = FOG_QUICK_INTERVALS;
    #declare FOGSamples = FOG_QUICK_SAMPLES;
#else
    #declare L1Intervals = L1_INTERVALS;
    #declare L1Samples = L1_SAMPLES;
    #declare L2Intervals = L2_INTERVALS;
    #declare L2Samples = L2_SAMPLES;
    #declare L3Intervals = L3_INTERVALS;
    #declare L3Samples = L3_SAMPLES;
    #declare FOGIntervals = FOG_INTERVALS;
    #declare FOGSamples = FOG_SAMPLES;
#end

#declare L1 = MakeLayer (L1_H, L1_T, L1_SCATTERING_TYPE, L1_SCATTERING,
L1_SCATTERING_COLOR, L1_ABSORPTION, L1_ABSORPTION_COLOR, L1_DENSITY, L1_METHOD,
L1Intervals, L1Samples)
#declare L2 = MakeLayer (L2_H, L2_T, L2_SCATTERING_TYPE, L2_SCATTERING,
L2_SCATTERING_COLOR, L2_ABSORPTION, L2_ABSORPTION_COLOR, L2_DENSITY, L2_METHOD,
L2Intervals, L2Samples)
#declare L3 = MakeLayer (L3_H, L3_T, L3_SCATTERING_TYPE, L3_SCATTERING,
L3_SCATTERING_COLOR, L3_ABSORPTION, L3_ABSORPTION_COLOR, L3_DENSITY, L3_METHOD,
L3Intervals, L3Samples)
#declare FOG = MakeLayer (FOG_H, FOG_T, FOG_SCATTERING_TYPE, FOG_SCATTERING,
FOG_SCATTERING_COLOR, FOG_ABSORPTION, FOG_ABSORPTION_COLOR, FOG_DENSITY,
FOG_METHOD, FOGIntervals, L3Samples)

// Scene setup
light_source {Sun}
object {Earth}
object {Atmo}
#if (USE_LAYER_1) object {L1} #end
#if (USE_LAYER_2) object {L2} #end
#if (USE_LAYER_3) object {L3} #end
#if (USE_LAYER_FOG) object {FOG} #end
// ====================== END OF ENGINE ==========================

// User objects
#declare Dome = sphere
{
    0, 2.5*m
    pigment {White}
}

#declare Slate = box
{
    -1.5*m, 1.5*m
    scale 0.05*y
    pigment {White}
}

object {Dome translate 17*m*z - 3*m*x}
object {Slate translate 2.75*m*y rotate 10*x translate 17*m*z - 3*m*x}


Post a reply to this message

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