Code: Alles auswählen
-- threshold filter
ywavelength = 0.01
yamplitude = 50
rangefactor = 0.5
xwavelength = 10
xcenter = 0.5
y0 = height/2
x0 = width*xcenter
for y=0, y0-1 do
for x=0, width-1 do
tempy = y/y0
x1 = (1-tempy) * yamplitude * math.sin(tempy * tempy * rangefactor /ywavelength)
x2 = (1-tempy)*(1-tempy) * yamplitude * math.sin((x-x0) * rangefactor / xwavelength)
h,s,l = get_hsl (x+x1+x2,y)
l = (1+tempy)*l
Sorry I seldom comment the code. I will explain the idea. Through a rough math modeling, I determine several factors should be take count into as the graph shows.
H1, the object height,
H2, view point height
Something missed from the graph, the wave propogation normal to the plane of drawing.
Also note that view field is important
All of above can be converted into angular factor or ratio factor, I don't plan to put effort to this.
Through some simplified maths, I conclude the view angle or wavelength will increase roughly as square of a distance factor. Therefore I applied the square in a sin to create a periodic ---- this is very rough, because the axis is also changed
The other effect I applied is to applied an offset from the center, applied to x2.
Then a lightness increment, which I should add control parameter
I removed the y dimensional distortion in the model to reduce the control parameters (previously I need to control 11 parameters).
I know the algorithm is not perfect. I'd like to discuss with your guys on that.