To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cad.rayOpen lugnet.cad.ray in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / Ray-Tracing / 1255
1254  |  1256
Subject: 
Re: Muzzle flash in POV-Ray?
Newsgroups: 
lugnet.cad.ray
Date: 
Tue, 7 May 2002 19:45:43 GMT
Viewed: 
897 times
  
In lugnet.cad.ray, Dave Schuler writes:
In lugnet.cad.ray, Tony Hafner writes:
In lugnet.cad.ray, Dave Schuler writes:
Is there info online somewhere about creating realistic explosion-type
bursts of light in POV-Ray?

I have two quickies:  the quick way and the long way.  (Note that both
examples were written towards POVRay version 3.1g...)

...

The quick way:

Here's what I wrote for the green laser bolts in my wallpaper "Flight".  (1)
This creates a 8x8x600 glowing ellipsoid with soft edges (it's actually a
scaled spehere, so you could scale it to whatever you want).  The bulk of
the magic happens in the media definition for "firebolt_form".  The
"firebolt" macro makes it a light_source if QUAL > 1; this may or may not
give you what you want, however, in which case you should just use the code
in "firebolt_form".

For the muzzle flash in that same wallpaper, I used two criss-crossed,
smaller versions of the "firebolt" object.

Coding notes:
- the POVRay docs don't make it clear that, in order to use media, the
object's texture needs to be color <1,1,1,1> (e.g. totally invisible).  I
believe a hollow object is also required
- keep the emission value low; .2 is near the upper end of what you want
- if you understand pigment maps, then the density map should look familiar

#declare firebolt_form = object {
  sphere {
    <0,0,0>, 1
    hollow
    material {
      texture { pigment { color rgbf <1,1,1,1> } }
      interior {
        media {
          emission .2
          density {
            spherical
            color_map {
              [0 color rgbf <0,0,0,1>]
              [.3 color rgbf <0,.5,0,.7>]
              [1 color rgbf <.5,1,.5,0>]
            }
          }
        }
      }
    }
  }
  no_shadow
  scale <4,300,4>
}

#declare firebolt =
#if( QUAL > 1 )
light_source {
  <0,0,0>
  color rgb <1,1.5,1>
  fade_distance 100
  fade_power 2
  looks_like {
    firebolt_form
  }
}
#else
object {
  firebolt_form
}
#end

...

The long way:

If you don't mind waiting forever for the render to finish, you can add some
neat texture to the glowing ball.  I wrote this for my icosahedron
wallpaper.  It creates a sphere 180 units in diameter with: a tiny
brightly-glowing point; bluish-purplish filaments near the center; and thin
reddish filaments stretching from the center to the edge.

As you can see, it is considerably more complex than the previous example.
In addition to being a composite of 3 or 4 different media definitions (some
with multiple densities), it also employs noise and warp transformations
that slow down the rendering by A LOT.

#declare inner_stuff = object {
  sphere {
    <0,0,0>, 1
    hollow
    material {
      texture {
        pigment {
          color rgbf <1,1,1,1>
        }
      }
      interior {
        media {
          // center ball of glowing stuff
          emission .0125
          #if( QUAL > 0 )
            intervals QUAL * 20
            samples 1, QUAL * 10
          #end
          density {
            spherical
            color_map {
              [0 color rgbf <0,0,0,1>]
              [.6 color rgbf <0,0,.1,1>]
              [.8 color rgbf <0,0,.2,.5>]
              [.95 color rgbf <1,1,2,0>]
              [1 color rgbf <20,20,50,0>]
            }
          }
          scale .75
        }
        media {
          // wispy thin tendrils of stuff throughout the whole field
          emission .0125
          #if( QUAL > 0 )
            intervals QUAL * 20
            samples 1, QUAL * 10
          #end
          density {
            spherical
            color_map {
              [0 color rgbf <0,0,0,1>]
              //[.5 color rgbf <0,0,0,1>]
              [1 color rgbf <1,1,1,0>]
            }
          }
          density {
            bozo
            turbulence 1
            color_map {
              [0 color rgbf <0,0,0,1>]
              [.999 color rgbf <0,0,0,1>]
              [1 color rgbf <1,1,1,0>]
            }
            scale .1
            warp {
              black_hole <0,0,0>, 1
              strength 3
            }
          }
          scale .75
        }
        media {
          // wispy thicker tendrils of stuff close to the center
          emission .0125
          #if( QUAL > 0 )
            intervals QUAL * 20
            samples 1, QUAL * 10
          #end
          density {
            spherical
            color_map {
              [0 color rgbf <0,0,0,1>]
              [.5 color rgbf <0,0,0,1>]
              [1 color rgbf <1,1,1,0>]
            }
          }
          density {
            bozo
            turbulence 1
            color_map {
              [0 color rgbf <0,0,0,1>]
              [.9 color rgbf <0,0,0,1>]
              [1 color rgbf <1,1,1,0>]
            }
            scale .1
            warp {
              black_hole <0,0,0>, 1
              strength 3
            }
          }
          scale .75
        }
        media {
          // fire stuff
          emission .0125
          #if( QUAL > 0 )
            intervals QUAL * 20
            samples 1, QUAL * 10
          #end
          density {
            spherical
            color_map {
              [0 color rgbf <0,0,0,1>]
              [.5 color rgbf <1,1,1,0>]
              [1 color rgbf <1,1,1,0>]
            }
          }
          density {
            spherical
            color_map {
              [0 color rgbf <0,0,0,1>]
              [.1 color rgbf <1,1,0,0>]
              [1 color rgbf <2,2,0,0>]
            }
          }
          density {
            crackle
            turbulence .1
            color_map {
              [0 color rgbf <1,.5,0,0>]
              [.05 color rgbf <1,0,0,0>]
              [.05 color rgbf <0,0,0,1>]
              [1 color rgbf <0,0,0,1>]
            }
            scale .25
            warp {
              black_hole <0,0,0>, 1
              strength 3
            }
            scale 1.1
          }
        }
      }
      scale .75
    }
  }
}

#declare inner_light = light_source {
  <0,0,0>
  color rgb <1,1,1.1>
  fade_distance 1000
  fade_power 1
  looks_like {
    inner_stuff
  }
}

object {
  inner_light
  scale 180
}

...

The cheap way:

Okay, there's one more technique I will mention quickly, but don't have any
code samples for.  (I think I deleted my flame & smoke macro
work-in-progress...arg.)

You can create a simple hollow sphere and give its pigment a noise-function
color_map (I like "granite" for this, but YMMV so please experiment) that
fades from transparent (<1,1,1,1>) to, say, red (<1,0,0,0>).  This looks
cheesy up-close, but if you put in a handful of these balls in the
background mixed together, they can be quite convincing.

HTH!

Cheers,
- jsproat

1.
http://www.io.com/~jsproat/lego/microfig/stickfig/wallpaper/index.shtml#FLIGHT

2.  http://www.io.com/~jsproat/lego/polyhedra/icosahedron.shtml - actual
image is at
http://www.brickshelf.com/gallery/sproaticus/lego/polyhedra/icosahedron_filled.jpg



Message has 2 Replies:
  Re: Muzzle flash in POV-Ray?
 
(...) **snip** Whoa! That'll keep me busy for a while... Thanks for the detailed help--I'm sure this will more than meet my meager needs. After I've messed around with it over the next few nights I'll try to post something. Thanks again, Dave! (22 years ago, 7-May-02, to lugnet.cad.ray)
  Re: Muzzle flash in POV-Ray?
 
In lugnet.cad.ray, Jeremy H. Sproat writes: Replying to myself... again... :-, One item I forgot to mention about my second code snippet (fire object from icosahedron) is that it looked like dithered crap until I added the "intervals" and "samples" (...) (22 years ago, 7-May-02, to lugnet.cad.ray)

Message is in Reply To:
  Re: Muzzle flash in POV-Ray?
 
(...) Hey, that's pretty clever. I was thinking in too linear a fashion, looking for a way to do flames directly, rather than playing with what's already available. I'll play with it when I have the chance and let you know. Do you have any examples (...) (22 years ago, 7-May-02, to lugnet.cad.ray)

8 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR