POV-Ray : Newsgroups : povray.general : Crepuscular rays/God Rays tips? Server Time
22 Feb 2025 12:50:12 EST (-0500)
  Crepuscular rays/God Rays tips? (Message 1 to 5 of 5)  
From: 00face
Subject: Crepuscular rays/God Rays tips?
Date: 13 Feb 2025 22:50:00
Message: <web.67aebce941372cd0cc29aad0aef99e11@news.povray.org>
Anybody have any good recommendations or pointers for rendering crepuscular rays
/ god rays?


Post a reply to this message


Attachments:
Download 'shutterstock-137349635.webp.dat' (28 KB)

From: Bald Eagle
Subject: Re: Crepuscular rays/God Rays tips?
Date: 14 Feb 2025 10:15:00
Message: <web.67af5cd32f4892fea911b6e125979125@news.povray.org>
"00face" <adc### [at] gmailcom> wrote:
> Anybody have any good recommendations or pointers for rendering crepuscular rays
> / god rays?

http://www.povcomp.com/entries/161.php

Bob Hughes and others have made some scenes if you search, but nothing that I
found with attached code.

https://news.povray.org/povray.advanced-users/thread/%3Cweb.6490ca4b9e00c62a74554476df9b2273%40news.povray.org%3E/

and links therein.

- BE


Post a reply to this message

From: Alain Martel
Subject: Re: Crepuscular rays/God Rays tips?
Date: 14 Feb 2025 11:48:58
Message: <67af73fa$1@news.povray.org>
Le 2025-02-13 à 22:47, 00face a écrit :
> Anybody have any good recommendations or pointers for rendering crepuscular rays
> / god rays?
Use a parallel light.
Use some scattering media.
Use one of the Mie scattering models.


Post a reply to this message

From: Bald Eagle
Subject: Re: Crepuscular rays/God Rays tips?
Date: 17 Feb 2025 09:20:00
Message: <web.67b345772f4892fe1f9dae3025979125@news.povray.org>
So, I was playing with the basics of setting up the media for such a scene, and
although I could get the effect to generally work, I was puzzled by the fact
that no light came through the box that I was using as the sky/clouds - even
though I was using an rgbt pigment.
Light seemed to only come through the fully differenced holes.
It took me a bit of trial-and-error to get the media to look smooth, rather than
jaggy / layers of disks of light / or just not appearing when the camera looked
through the light at the horizon.


#version 3.7;
global_settings {assumed_gamma 1.0}
camera {
   location <0, 90, -500>
   look_at <0, 0, 0>
}

light_source {< 0, 500, 0> rgb 1000}

// Sky
sky_sphere {pigment {rgb 0.2}}

#declare M = 1;
#declare MM = 10;
// Cloud plane
difference {
 box {<-250, -0.02, -250>*MM, <250, 0.02, 250>*MM}
 // Cloud holes
 union {
  sphere { <-200, 0, -200>/M, 5}
  sphere { < 200, 0, -150>/M, 6}
  sphere { < 0.0, 0,  0.0>/M, 4}
  sphere { <-150, 0,  100>/M, 5}
  sphere { < 150, 0,  150>/M, 4}
  sphere { <-300, 0, -100>/M, 6}
  sphere { < 300, 0,   50>/M, 5}
  sphere { <-100, 0, -300>/M, 4}
  sphere { < 100, 0,  300>/M, 5}
  sphere { <-250, 0,  200>/M, 6}
  sphere { < 250, 0, -200>/M, 5}
  sphere { <- 50, 0,  250>/M, 4}
  sphere { <  50, 0, -250>/M, 5}
  sphere { <-175, 0, -175>/M, 4}
  sphere { < 175, 0,  175>/M, 6}
  sphere { <-225, 0,   75>/M, 5}
  sphere { < 225, 0, - 75>/M, 4}
  sphere { <- 75, 0, -225>/M, 5}
  sphere { <  75, 0,  225>/M, 6}
  sphere { <-125, 0,  175>/M, 5}
 }
 pigment {rgb y+z}
 #declare T = 0;
 texture {
  pigment {bozo turbulence 0.76
   color_map {
    [0.5 rgbft <0.20, 0.20, 1.00, T, 1>]
    [0.6 rgbft <1.00, 1.00, 1.00, T, 0.5>]
    [1.0 rgbft <0.50, 0.50, 0.50, T, 1>]
   }
  }
  scale 10
  finish {diffuse 1 emission 0.5}
 }
 translate y*100
}

#declare MM = 10;
box {
 <-270, -5, -270>*MM, <270, 5, 270>*MM
 pigment {rgbt 1}
 hollow
 interior {
  media {
   method 3
   density {rgb 0.0001}
   scattering {2, 1}

   samples 500
   //confidence 0.9999
   //variance 1/1000
   //ratio 0.9
  }
 }
 translate y*50
}

plane {y, 0
 pigment {rgb x+y*0.2}
}

plane { y, 0.1
        texture{ pigment{ color rgb<0.35,0.65,0.0>*0.9 }
          normal { bumps 0.75 scale 0.015 }
                 finish { phong 0.1 }
               } // end of texture
      } // end of plane


Post a reply to this message


Attachments:
Download 'crepuscularrays1.png' (332 KB)

Preview of image 'crepuscularrays1.png'
crepuscularrays1.png


 

From: 00face
Subject: Re: Crepuscular rays/God Rays tips?
Date: 18 Feb 2025 12:00:00
Message: <web.67b4bc092f4892fe1011a97eaef99e11@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> So, I was playing with the basics of setting up the media for such a scene, and
> although I could get the effect to generally work, I was puzzled by the fact
> that no light came through the box that I was using as the sky/clouds - even
> though I was using an rgbt pigment.
> Light seemed to only come through the fully differenced holes.
> It took me a bit of trial-and-error to get the media to look smooth, rather than
> jaggy / layers of disks of light / or just not appearing when the camera looked
> through the light at the horizon.
>
>
> #version 3.7;
> global_settings {assumed_gamma 1.0}
> camera {
>    location <0, 90, -500>
>    look_at <0, 0, 0>
> }
>
> light_source {< 0, 500, 0> rgb 1000}
>
> // Sky
> sky_sphere {pigment {rgb 0.2}}
>
> #declare M = 1;
> #declare MM = 10;
> // Cloud plane
> difference {
>  box {<-250, -0.02, -250>*MM, <250, 0.02, 250>*MM}
>  // Cloud holes
>  union {
>   sphere { <-200, 0, -200>/M, 5}
>   sphere { < 200, 0, -150>/M, 6}
>   sphere { < 0.0, 0,  0.0>/M, 4}
>   sphere { <-150, 0,  100>/M, 5}
>   sphere { < 150, 0,  150>/M, 4}
>   sphere { <-300, 0, -100>/M, 6}
>   sphere { < 300, 0,   50>/M, 5}
>   sphere { <-100, 0, -300>/M, 4}
>   sphere { < 100, 0,  300>/M, 5}
>   sphere { <-250, 0,  200>/M, 6}
>   sphere { < 250, 0, -200>/M, 5}
>   sphere { <- 50, 0,  250>/M, 4}
>   sphere { <  50, 0, -250>/M, 5}
>   sphere { <-175, 0, -175>/M, 4}
>   sphere { < 175, 0,  175>/M, 6}
>   sphere { <-225, 0,   75>/M, 5}
>   sphere { < 225, 0, - 75>/M, 4}
>   sphere { <- 75, 0, -225>/M, 5}
>   sphere { <  75, 0,  225>/M, 6}
>   sphere { <-125, 0,  175>/M, 5}
>  }
>  pigment {rgb y+z}
>  #declare T = 0;
>  texture {
>   pigment {bozo turbulence 0.76
>    color_map {
>     [0.5 rgbft <0.20, 0.20, 1.00, T, 1>]
>     [0.6 rgbft <1.00, 1.00, 1.00, T, 0.5>]
>     [1.0 rgbft <0.50, 0.50, 0.50, T, 1>]
>    }
>   }
>   scale 10
>   finish {diffuse 1 emission 0.5}
>  }
>  translate y*100
> }
>
> #declare MM = 10;
> box {
>  <-270, -5, -270>*MM, <270, 5, 270>*MM
>  pigment {rgbt 1}
>  hollow
>  interior {
>   media {
>    method 3
>    density {rgb 0.0001}
>    scattering {2, 1}
>
>    samples 500
>    //confidence 0.9999
>    //variance 1/1000
>    //ratio 0.9
>   }
>  }
>  translate y*50
> }
>
> plane {y, 0
>  pigment {rgb x+y*0.2}
> }
>
> plane { y, 0.1
>         texture{ pigment{ color rgb<0.35,0.65,0.0>*0.9 }
>           normal { bumps 0.75 scale 0.015 }
>                  finish { phong 0.1 }
>                } // end of texture
>       } // end of plane
Thank you for all your help so  far:
#version 3.7;
global_settings {
    assumed_gamma 1.0
    radiosity {
        pretrace_start 0.08
        pretrace_end   0.01
        count 50
        nearest_count 5
        error_bound 0.5
        recursion_limit 1
        low_error_factor 0.5
        gray_threshold 0.0
        minimum_reuse 0.015
        maximum_reuse 0.2
        brightness 0.8
        adc_bailout 0.01/2
    }
    max_trace_level 5        // Reduce from default 5 to improve speed
    adc_bailout 0.01/2      // Increase threshold slightly for speed
}
#default { finish { ambient 0.1 diffuse 0.9 } }
//--------------------------------------------------------------------------
#include "colors.inc"
#include "textures.inc"
#include "glass.inc"
#include "metals.inc"
#include "golds.inc"
#include "stones.inc"
#include "woods.inc"
#include "shapes.inc"
#include "shapes2.inc"
#include "functions.inc"
#include "math.inc"
#include "transforms.inc"

//--------------------------------------------------------------------------
// Optimize media settings
// Camera
#declare Optimized_Media = media {
    scattering { 1, 0.17 extinction 0.01 }
    samples 35, 75        // Reduced from 100, 500
    intervals 1
    method 3             // More efficient media sampling method
    confidence 0.9999
    variance 1/1000
}

#declare Camera_1 = camera {
    angle 50
    location  <2.20, 0.75, 0.05>
    right     x * image_width / image_height
    look_at   <2.85, 0.75, 2.00>
    aperture 0.0        // Disable DOF for faster rendering
    blur_samples 1
}
camera { Camera_1 }

//--------------------------------------------------------------------------
// Suns

// North (Front) - Red light
light_source { <666, 400, -10> color rgb <1, 0, 0> * 1.2 }

// South (Back) - Blue light
light_source { <666, 400, 10> color rgb <0, 0, 1> * 1.2 }

// East (Right) - Green light
light_source { <10, 400, 400> color rgb <0, 1, 0> * 1.2 }

// West (Left) - Orange light
light_source { <-10, 400, 400> color rgb <1, 0.5, 0> * 1.2 }

// Top (Ceiling) - White light
light_source { <666, 10, 400> color rgb <1, 1, 1> * 1.2 }


//--------------------------------------------------------------------------
// Sky
plane {
  <0,1,0>, 1
  hollow
  texture {
    pigment { color rgb <0.20, 0.20, 1.0> }
    finish  { ambient 0.25 diffuse 0 conserve_energy}
  }
  scale 10000
}
plane {
  <0,1,0>, 1
  hollow
  texture {
    pigment {
      bozo turbulence 0.76
      color_map {
         [0.5 rgbf <1.0, 1.0, 1.0, 1.0> ]
         [0.6 rgb  <1.0, 1.0, 1.0>     ]
         [1.0 rgb  <0.5, 0.5, 0.5>     ]
      }
    }
    finish { ambient 0.25 diffuse 0 conserve_energy}
  }
  scale 800
}


//--------------------------------------------------------------------------
// Ground
plane {
  <0,1,0>, 0
  texture {
    pigment { color rgb <0.35, 0.65, 0.0> * 0.72 }
    normal  { bumps 0.75 scale 0.015 }
    finish  { phong 0.1 conserve_energy}
  }
}

//--------------------------------------------------------------------------
// Textures
#declare Wall_Texture =
    texture {
        pigment { color White * 0.75 }
        finish  {
            ambient 0.15
            diffuse 0.85
            phong 0.5    // Reduced from 1
            phong_size 40
        }
    }

#declare Hole_Texture =
      texture {
        pigment { color White * 0.85 }
        finish  { ambient 0.15 diffuse 0.85 phong 1 }
      };

//--------------------------------------------------------------------------
// Room dimensions and wall thickness
#declare R_x = 15.00;
#declare R_y = 12.50;
#declare R_z = 17.00;
#declare Wall_D = 0.25;
#declare epsilon = 0.01;  // Extra extension so holes cut fully through

// A constant for converting degrees to radians:
#declare RAD = pi / 180;

//--------------------------------------------------------------------------
// Room:
//    0: Left wall (x from -Wall_D to 0)
//    1: Right wall (x from R_x to R_x+Wall_D)
//    2: Back wall (z from -Wall_D to 0)
//    3: Front wall (z from R_z to R_z+Wall_D)
//    4: Ceiling (y from R_y to R_y+Wall_D)
// Hole sizes.
#declare Holes = union {
  #for (i, 0, 1999)
    // pseudo random numbers
    #declare r0 = abs(sin((i * 12.9898 + 1) * RAD) * 43758.5453 - floor(sin((i *
12.9898 + 1) * RAD) * 43758.5453));
    #declare r1 = abs(sin((i * 12.9898 + 2) * RAD) * 43758.5453 - floor(sin((i *
12.9898 + 2) * RAD) * 43758.5453));
    #declare r2 = abs(sin((i * 12.9898 + 3) * RAD) * 43758.5453 - floor(sin((i *
12.9898 + 3) * RAD) * 43758.5453));
    #declare r3 = abs(sin((i * 12.9898 + 4) * RAD) * 43758.5453 - floor(sin((i *
12.9898 + 4) * RAD) * 43758.5453));
    #declare r4 = abs(sin((i * 12.9898 + 5) * RAD) * 43758.5453 - floor(sin((i *
12.9898 + 5) * RAD) * 43758.5453));

    // Use r0 to select the surface (0 to 4)
    #declare surface_index = floor(r0 * 5);

    #if (surface_index = 0)
      // Left wall: x fixed from -Wall_D to 0.
      // Free dimensions: y (vertical) and z (horizontal).
      #declare hole_height = 0.01 + r3 * 0.1;  // ~0.1 to 0.5
      #declare hole_width  = 0.01 + r4 * 0.1;  // ~0.1 to 1.0
      #declare y0 = r1 * (R_y - hole_height);
      #declare z0 = r2 * (R_z - hole_width);
      box { < -Wall_D - epsilon, y0, z0>, < 0 + epsilon, y0 + hole_height, z0 +
hole_width> }

    #elseif (surface_index = 1)
      // Right wall: x fixed from R_x to R_x+Wall_D.
      #declare hole_height = 0.1 + r3 * 0.4;
      #declare hole_width  = 0.1 + r4 * 0.9;
      #declare y0 = r1 * (R_y - hole_height);
      #declare z0 = r2 * (R_z - hole_width);
      box { < R_x - epsilon, y0, z0>, < R_x + Wall_D + epsilon, y0 +
hole_height, z0 + hole_width> }

    #elseif (surface_index = 2)
      // Back wall: z fixed from -Wall_D to 0.
      // Free dimensions: x and y.
      #declare hole_height = 0.1 + r3 * 0.4;
      #declare hole_width  = 0.1 + r4 * 0.9;
      #declare y0 = r1 * (R_y - hole_height);
      #declare x0 = r2 * (R_x - hole_width);
      box { < x0, y0, -Wall_D - epsilon>, < x0 + hole_width, y0 + hole_height, 0
+ epsilon> }

    #elseif (surface_index = 3)
      // Front wall: z fixed from R_z to R_z+Wall_D.
      #declare hole_height = 0.1 + r3 * 0.4;
      #declare hole_width  = 0.1 + r4 * 0.9;
      #declare y0 = r1 * (R_y - hole_height);
      #declare x0 = r2 * (R_x - hole_width);
      box { < x0, y0, R_z - epsilon>, < x0 + hole_width, y0 + hole_height, R_z +
Wall_D + epsilon> }

    #else
      // Ceiling: y fixed from R_y to R_y+Wall_D.
      // Free dimensions: x and z.
      #declare hole_width  = 0.1 + r3 * 0.9;  // x dimension ~0.1 to 1.0
      #declare hole_height = 0.1 + r4 * 0.9;  // z dimension ~0.1 to 1.0
      #declare x0 = r1 * (R_x - hole_width);
      #declare z0 = r2 * (R_z - hole_height);
      box { < x0, R_y - epsilon, z0>, < x0 + hole_width, R_y + Wall_D + epsilon,
z0 + hole_height> }
    #end
  #end
};

//--------------------------------------------------------------------------
// Build the room.
union {
  difference {
    // Outer box (including wall thickness)
    box { < -Wall_D, -Wall_D, -Wall_D>, < R_x + Wall_D, R_y + Wall_D, R_z +
Wall_D> }
    // Inner room box
    box { < 0, 0, 0>, < R_x, R_y, R_z> }
    // Subtract the union of random holes.
    object { Holes }
    hollow
    texture { Wall_Texture }
  }


  light_source { < R_x / 2, R_y - 0.5, 0.5>, 0.15 media_interaction off }

  // Scattering media inside the room:
box {
    < 0, 0, 0>, < R_x, R_y, R_z>
    pigment { rgbt 1 }
        finish {
      conserve_energy
    }
    hollow
    interior {
        media {
            scattering { 1, 0.17 extinction 0.01 }
            samples 35, 75        // Reduced from 100, 500
            intervals 1
            method 3             // More efficient media sampling method
            confidence 0.9999
            variance 1/1000
        }
    }
    translate < 0, 0.01, 0>
}
}

text {
  ttf "timrom.ttf" "DELL" 1, 0  // Very small size
  texture {
    pigment { rgbt 1 filter 0.45}
    finish {
      specular 0.2 roughness 0.001
      ambient 0 diffuse 0
      reflection { 1 fresnel }
      conserve_energy
    }
  }
  interior {
    ior 2.4
    fade_color rgb <0.196, 0.529, 0.757>
    fade_distance 0.2  // Reduced for smaller text
    fade_power 1001

    media {
      scattering {
        1,
        rgb <0.196, 0.529, 0.757>
        extinction 0.5  // Slightly less extinction for visibility
      }

      density {
        gradient y
        turbulence 0.2
        frequency 1.5
        scale <1, 1, 1>
        color_map {
          [0.0 rgb 0.08]
          [0.3 rgb 0.12]
          [0.7 rgb 0.15]
          [1.0 rgb 0.18]
        }
      }

      samples 10, 30
      method 3
    }
  }

  // Place very close to camera
  scale 0.002

  // Place just in front of camera
  translate <2.20, 0.75, 0.058>  // Just in front of camera
}


Post a reply to this message

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