POV-Ray : Newsgroups : povray.binaries.images : Sci-Fi Scene Assets : Re: Sci-Fi Scene Assets Server Time
18 Apr 2024 07:08:45 EDT (-0400)
  Re: Sci-Fi Scene Assets  
From: Robert McGregor
Date: 19 Feb 2021 20:40:00
Message: <web.603067eaa906d8e387570eab0@news.povray.org>
William F Pokorny <ano### [at] anonymousorg> wrote:
> Cool. :-)
>
> The hint of atmosphere in the star field - is that something added to
> the star field, added as fog or is it related to the added luminous bloom?

It's just running some pigments through a couple of compositing macros and
building an averaged texture to "project" onto a background sky plane, something
like this:

#macro Pigment_Attenuate(p1, amt, rgb_clr)

   #local p2 = pigment { rgb rgb_clr }

   // return the new attenuated pigment
   #local pgmt_Attenuated = pigment {
      average
      pigment_map {
         [amt   p1]
         [1-amt p2]
      }
   }
   pgmt_Attenuated
#end

#macro Pigment_Overlay(pgmt_Orig, pgmt_Blend, blendAmt)

   #local pgmt_Blend = pigment {
      Pigment_Attenuate(pgmt_Blend, blendAmt, 0)
   }
   #local fp1 = function { pigment { pgmt_Orig } }
   #local fp2 = function { pigment { pgmt_Blend } }

   // overlay pigments
   #local RedChannel = pigment {
      function {
         (fp2(x,y,z).red*(1-fp1(x,y,z).red)/0.5)
        +(fp1(x,y,z).red-(1-fp1(x,y,z).red))
      }
      color_map { [0 rgb 0][1 rgb <1,0,0>] }
   }

   #local GreenChannel = pigment {
      function {
         (fp2(x,y,z).green*(1-fp1(x,y,z).green)/0.5)
        +(fp1(x,y,z).green-(1-fp1(x,y,z).green))
      }
      color_map { [0 rgb 0][1 rgb <0,1,0>] }
   }

   #local BlueChannel = pigment {
      function {
         (fp2(x,y,z).blue*(1-fp1(x,y,z).blue)/0.5)
        +(fp1(x,y,z).blue-(1-fp1(x,y,z).blue))
      }
      color_map { [0 rgb 0][1 rgb <0,0,1>] }
   }

   // return this new blended pigment
   #local pgmt_Blended = pigment {
      average
      pigment_map {
         [1 RedChannel]
         [1 GreenChannel]
         [1 BlueChannel]
      }
   }
   pgmt_Blended
#end

// stars
#declare P_Stars = pigment {
   image_map { png "starfield_and_moon" interpolate 2 map_type 0 once }
   translate -0.5
}

// atmosphere
#declare P_Clouds = pigment {
   gradient y
   pigment_map {
      [0
         bozo
         pigment_map {
            [0 rgb <44, 43, 58>/255]
            [1 rgb 0]
         }
         turbulence 1
         scale 0.2
      ]
      [0.75 rgb 0]
   }
   translate y*0.5
}

// Combined
plane {z, 200
   texture {
      average
      texture_map {
         [1
            pigment { Pigment_Overlay(P_Stars, P_Clouds, 0.15) }
            finish { emission 1 diffuse 0 }
         ]
         [1
            pigment { P_Stars }
            finish { emission 3 diffuse 0 }
         ]
      }
      scale x*image_width/image_height
      scale 160
      translate y*5
   }
}


Post a reply to this message

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