Simple lua script for water reflection

Hier können mit Artweaver erstellte Bilder präsentiert werden - Here you can show pictures created with Artweaver.
Singerxy
Beiträge: 9
Registriert: Mi Jan 31, 2007 8:31 pm

Simple lua script for water reflection

Beitragvon Singerxy » Mi Aug 06, 2008 1:30 am

I reproduced my previous lua script for water reflection and wish to trigger more discussion on the wonderful artweaver with lua.

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
    set_hsl (x,height-y,h,s,l)
  end
end


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
Distance
Wavelength

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.
Dateianhänge
Firefox_Wallpaper_by_joezerosum_LuaDemo_by_Singerxy.png
2008-08-05_181036.png
2008-08-05_181036.png (9.06 KiB) 6555 mal betrachtet

staigerman
Beiträge: 14
Registriert: Mi Mai 17, 2006 6:36 pm
Kontaktdaten:

Beitragvon staigerman » So Aug 24, 2008 11:35 pm

very nice.

we have seen anotehr lua script that can also be used for water reflection. It is a little more suited for 'disturbed' water. I bet using the two together will make for great effects.

See http://www.thebest3d.com/dogwaffle/lua/berries-slider-shifted-enhanced.jpg - this was done with Marco Pontello's 'Sliders'. The reflection itself was done pre-emptively in Dogwaffle. Easy enough to do the same in ArtWeaver.

See more about Sliders here: http://www.thebest3d.com/dogwaffle/lua/samples.html#Sliders_-_by_Marco_Pontello

I guess the next step is to combine the two scripts.

Bild

staigerman
Beiträge: 14
Registriert: Mi Mai 17, 2006 6:36 pm
Kontaktdaten:

get_ / set_ hsl or hsv ?

Beitragvon staigerman » Mo Aug 25, 2008 3:15 am

hue saturation lightness, hsl... or is it hsv, hue saturation value?

When I run the script above, using DogLua's lua system in Dogwaffle, it stops at line 17 with get_hsl

when I change it to get_hsv instead, it works.

Is there really a function called get_hsl or is that a typo?

dito with line 19: set_hsl should be set_hsv ?

-Philip


Zurück zu „Gallery“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast