70 |
real k1 = (trace(G) + disc)/2.0; |
real k1 = (trace(G) + disc)/2.0; |
71 |
real k2 = (trace(G) - disc)/2.0; |
real k2 = (trace(G) - disc)/2.0; |
72 |
// find material RGBA |
// find material RGBA |
73 |
vec3 matRGB = RGB([max(-1.0, min(1.0, 6.0*k1)), |
vec3 matRGB = RGB([clamp(-1.0, 1.0, 6.0*k1), |
74 |
max(-1.0, min(1.0, 6.0*k2))]); |
clamp(-1.0, 1.0, 6.0*k2)]); |
75 |
real alpha = min(1.0, lerp(0.0, 1.0, |
real alpha = min(1.0, lerp(0.0, 1.0, |
76 |
valOpacMin, val, valOpacMax)); |
valOpacMin, val, valOpacMax)); |
77 |
real ld = max(0.0, norm • lightDir); |
real ld = max(0.0, norm • lightDir); |
81 |
+ phongKd*ld*modulate(matRGB, lightRGB) |
+ phongKd*ld*modulate(matRGB, lightRGB) |
82 |
+ phongKs*hd^phongSp*lightRGB); |
+ phongKs*hd^phongSp*lightRGB); |
83 |
// composite with existing ray color and transparency |
// composite with existing ray color and transparency |
84 |
rayRGB = rayRGB + rayTransp*alpha*pntRGB; |
rayRGB += rayTransp*alpha*pntRGB; |
85 |
rayTransp = rayTransp*(1.0 - alpha); |
rayTransp *= 1.0 - alpha; |
86 |
} |
} |
87 |
} |
} |
88 |
if (rayTransp < 0.01) { // early ray termination |
if (rayTransp < 0.01) { // early ray termination |