My Shader
|
float remap(float input, minval, maxval)
{
float clamped = clamp(input, minval , maxval);
float result = (clamped - minval)/(maxval - minval);
return result;
}
surface
fire_final(float Kfb = 1,
frmulti = 1,
rim_width = .9,
freq = 8,
seperation = .5,
height = .05,
offset = 0,
alpha1Min = .3,
alpha1Max = .5,
alpha2Min = .4,
alpha2Max = .6;
color top = 1,
side = color(1.0, 0.580, 0.094),
bottom = 0;
string firespace = "shader";)
{
normal nn = normalize(N);
normal nf = faceforward(nn, I);
vector V = normalize(-I);
point pp = transform(firespace,P);
float facingRatio = V.nf;
float invFacingRatio = 1 - facingRatio;
color bottom2 = bottom * .08;
float tt = (t + (noise(pp*freq + offset)-seperation)*height);
float alphaBlend1 = smoothstep(alpha1Min, alpha1Min+alpha1Max, tt);
float alphaBlend2 = smoothstep(alpha2Min, alpha2Min+alpha2Max, t);
color edge = mix(top, side, facingRatio - .2);
color topEdge = mix(top, edge, alphaBlend2) * Kfb;
color surfcolor = mix(bottom2,topEdge, alphaBlend1);
float facingRatioReFix = frmulti * invFacingRatio + .05;
float facingRatioFix = mix(facingRatioReFix, alphaBlend1, alphaBlend1) ;
float edgeBlur = smoothstep(1.0 - rim_width, 1.0, facingRatio);
float result = remap(facingRatioFix, 0, .5);
Oi = edgeBlur * result;
Ci = Oi * surfcolor;
Oi = 0;
}
|