- UID
- 172
- 帖子
- 491
- 精华
- 9
- 积分
- 770
- 来自
- 皖宣州
|
向uf光照着色开刀:
Lighting {
;
; Coloring algorithm for the Slope family of fractal types.
; This coloring algorithm performs 3D lighting for these
; fractals.
;
; Written by Damien M. Jones
;
final:
float vz = -sqrt(1-|#z|) ; extract implied portion of normal
float d2r = #pi/180 ; degrees to radians conversion factor
; create vector for light direction
float lx = cos((270-@angle)*d2r) * cos(@elevation*d2r)
float ly = sin((270-@angle)*d2r) * cos(@elevation*d2r)
float lz = -sin(@elevation*d2r)
; compute cosine of angle between these vectors
; (this is the amount of lighting on the surface)
float l = lx*real(#z) + ly*imag(#z) + lz*vz
IF (l < @ambient) ; light is below the ambient level
l = @ambient ; set it to the ambient level
ENDIF
IF (@ambient < 0) ; the ambient level is negative
l = l + 1 ; offset to prevent clipping at 0
ENDIF
#index = l*0.99 ; reduce it just a bit to prevent
; the colors from wrapping
default:
title = "Lighting"
helpfile = "Uf*.chm"
helptopic = "Html/coloring/standard/lighting.html"
heading
text = "Tip: Combine with one of the Slope formulas"
endheading
param @angle
caption = "Light Rotation"
default = 90.0
hint = "Gives the rotation of the light source, in degrees. With 0 \
degrees, the light comes from above. Positive values give \
clockwise rotation."
endparam
param @elevation
caption = "Light Elevation"
default = 30.0
hint = "Gives the elevation of the light source, in degrees."
endparam
param @ambient
caption = "Ambient Light"
default = 0.0
min = -1.0
max = 1.0
hint = "Specifies the level of ambient light. Use -1.0 to \
color all surfaces."
endparam
} |
|