RSL
|
IntroductionThis tutorial develops a self-luminescent surface shader that looks somewhat like a flame. The shader begins as a simple color ramp shader - listing 1. |
Listing 1
|
Hard Edged Flames
Using
|
Listing 2
|
Soft Edged Flames
Although the if(t > noise(p * freq)) /\ / \ / \ t-0.1, t+0.1 The two new values become the first parameters to the smoothstep function. The second part of the if-else statement becomes the final parameter to smoothstep ie. if(t > noise(p * freq)) | |________________________ | Oi = 1 - smoothstep(t-0.1,t+0.1,noise(p * freq)); Subtracting the value of smoothstep from 1.0 reverses the "dirction" of the flames. The animation shown below demonstrates the effects of softening the edges of the flame.
The final version of this shader uses a parameter called "soft" instead of an explicit value of 0.1. |
Extensions
The techniques shown in this tutorial have only been applied
to opacity. The color of the flame was created using the Ci = Oi * Cs * surfcolor * Kfb; might be modified as, if(high_frequency_noise > 0.7) surfcolor = color(1,1,1); Ci = Oi * Cs * surfcolor * Kfb; How high_frequency_noise is calculated is left as a problem for the reader - refer to the tutorial " RSL: Writing Displacement Shaders". |
© 2002- Malcolm Kesson. All rights reserved.