POV-Ray : Newsgroups : povray.binaries.images : Fire and... wait, what the hell...? [100 KB] : Re: Fire and... wait, what the hell...? [100 KB] Server Time
7 Aug 2024 15:21:13 EDT (-0400)
  Re: Fire and... wait, what the hell...? [100 KB]  
From: Trevor G Quayle
Date: 9 Feb 2006 13:35:00
Message: <web.43eb8a3cf5fb88c4c8947640@news.povray.org>
Eero Ahonen <aer### [at] removethiszbxtnetinvalid> wrote:
> Trevor G Quayle wrote:
> >
> > If you're interested, I have a macro I made a couple years ago for a candle
> > flame as in the attached image.
> >
>
> Nice one - open source? :)
>
> --
> Eero "Aero" Ahonen
>    http://www.zbxt.net
>       aer### [at] removethiszbxtnetinvalid

Sure.  It evens contains a macro that attempts to reverse engineer the
turbulence to keep the flame properly postioned when turbulated (doesn't
work too well with turbulence of 1 or more, tends to get stuck and not be
able to find the turbulated point).

Feel free to adjust anything in it.  Don't ask me o explain the mathematics
though, I wrote it a few years ago and have no idea how it works anymore.


#macro Flam (Turb)
  #local R1=seed(2);
  #local OS=rand(R1)*50;
  #local Flam1 = function(x,y,z)
{pow(pow(pow(3*x,2)+pow(0.8*y-0.2,2)+pow(3*z,2),3)+pow(max(1-sqrt(pow(5*x,2)+pow(y+.5,2)+pow(5*z,2)),0),2))}
  #local Flam2 = function(x,y,z)
{floor(pow(sqrt(pow((3.5*x),2)+pow((0.4*y+0.6),2)+pow((3.5*z),2)),2))}
  #local FlamF = function(x,y,z) {min(max(Flam1(x,y,z),Flam2(x,y,z)),1)}
  #macro turb_translate (tTurb,tOcta,tLamb,tOmeg,P0,Acc)
    #local PC=P0;
    #local Dir=<0,0,0>;
    #local V0=vlength(vturbulence(tLamb, tOmeg, tOcta, P0)*tTurb);
    #local Step=V0/2;
    #macro AB(PC,Step,d,Dir,V0)
      #local P1=PC+Step*d;
      #local V1=vlength(P1+vturbulence(tLamb, tOmeg, tOcta, P1)*tTurb-P0);
      #if (V1<V0 | d.x=1)
        #local Dir=d;
        #local V0=V1;
      #end
    #end
    #while (V0>Acc)
      #local DrP=Dir;
      AB(PC,Step, x,Dir,V0)
      AB(PC,Step,-x,Dir,V0)
      AB(PC,Step, y,Dir,V0)
      AB(PC,Step,-y,Dir,V0)
      AB(PC,Step, z,Dir,V0)
      AB(PC,Step,-z,Dir,V0)
      #if (vlength(DrP+Dir)=0)
        #local Step=Step/2;
      #else
        #local Step=V0/2;
      #end
      #local PC=PC+Step*Dir;
    #end
    PC
  #end
  #local tOcta=7;
  #local tLamb=1.32;
  #local tOmeg=0.135;
  sphere{0 1.1 scale <1/2,1,1/2> translate y*(0.15+OS)
    hollow
    pigment{rgbt <1,1,1,1>}
    interior{
      media{
        emission rgb 0.3
        method 3
        intervals 2
        density{
          function{FlamF(x,y-OS,z)}
          color_map{
            [0.00 rgb <1,1,.5>]
            [0.20 rgb <1,.5,0>]
            [0.60 rgb <1,.1,0>]
            [0.78 rgb <0,0,0>]
            [0.84 rgb <0,0,0>]
            [0.89 rgb <1,0,1>]
            [0.93 rgb <0,0,1>]
            [0.98 rgb <0,1,1>]
            [1.00 rgb <0,0,0>]
          }
          warp{
            turbulence Turb
            octaves tOcta
            lambda tLamb
            omega tOmeg
          }
        }
      }
    }
    no_shadow
    translate turb_translate(Turb,tOcta,tLamb,tOmeg,y*(0.65-OS),0.001)
  }
#end

object{Flam(0.2) scale 10}


-tgq


Post a reply to this message

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