由 ChildPark » 4日 9月 2005年, 23:27
surface muiltlayer(
float Ka = 1,
Kd = 0.5;
color col = color(1,1,1);
color col1 = color(1,0,0);
color col2 = color(0,1,0);
color col3 = color(0,0,1);
color bg = color(0,0,0);
)
{
float fuzz = 0.005;
normal Nf = faceforward(normalize(N), I);
/* Layer 1 color */
float ss1 = smoothstep(0-fuzz, 0+fuzz, s) - smoothstep(0.2, 0.2+fuzz, s);
float tt1 = smoothstep(0-fuzz, 0+fuzz, t) - smoothstep(0.2, 0.2+fuzz, t);
float comp1 = ss1* tt1;
color layer1 = mix(bg, col, comp1);
/* Layer 2 color */
float ss2 = smoothstep(0.2-fuzz, 0.2+fuzz, s) - smoothstep(0.4, 0.4+fuzz, s);
float tt2 = smoothstep(0.2-fuzz, 0.2+fuzz, t) - smoothstep(0.4, 0.4+fuzz, t);
float comp2 = ss2 + tt2;
color layer2 = mix(layer1, col1, comp2);
/* Layer 3 color */
float ss3 = smoothstep(0.4-fuzz, 0.4+fuzz, s) - smoothstep(0.6, 0.6+fuzz, s);
float tt3 = smoothstep(0.4-fuzz, 0.4+fuzz, t) - smoothstep(0.6, 0.6+fuzz, t);
float comp3 = ss3 + tt3;
color layer3 = mix(layer2, col2, comp3);
/* Layer 4 color */
float ss4 = smoothstep(0.6-fuzz, 0.6+fuzz, s) - smoothstep(0.8, 0.8+fuzz, s);
float tt4 = smoothstep(0.6-fuzz, 0.6+fuzz, t) - smoothstep(0.8, 0.8+fuzz, t);
float comp4 = ss4 + tt4;
color final = mix(layer3, col3, comp4);
Oi = Os;
Ci = Oi * final * (Ka * ambient() + Kd * diffuse(Nf));
}
- 附加檔案
-
- muiltlayer.jpg (24.75 KiB) 被瀏覽 22319 次