|
 |
If you want a candle flame, here is one I developed a number of years ago based
on many photos of flames, and had posted here somewhere before.
I always found that people tend to not get the colours right, especially the
purple and blues near the bottom. This is purely emissive media and has
turbulence added in. (the turb_translate macro within the macro is to back
check the flame base point so it is still centred where it should be. don't set
the turbulence level too high or it can fail at finding the point and
get stuck in an infinite loop, the sample image is set to 0.3).
sample usage:
union{
cylinder{0 y*100 10 pigment{rgb 1}}
cylinder{0 y*106 0.5 pigment{rgb 0}}
object{Flam(0.3) scale 15 translate y*(108)}
light_source{0
rgb <1,.5,0>
translate <0,117,0>
media_attenuation on
fade_power 2
fade_distance 100
}
}
//START
#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.35;
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.90 rgb <0,0,0>]
[0.94 rgb <0,0,1>]
[0.98 rgb <0,0,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.75-OS),0.001)
}
#end
//END
Post a reply to this message
Attachments:
Download 'candleflame.jpg' (396 KB)
Preview of image 'candleflame.jpg'

|
 |