-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Matúš Chovan edited this page Feb 7, 2019
·
6 revisions
Welcome to the godot-fftwater wiki!
- (CPU) C++ Generates displacement map
- (CPU) GDScript updates displacement map (every _process()) and sends it to shader
- (GPU) Shader displaces vertices and does shading
To use water, download latest package from Releases
The Release package contains:
-
bin/
-
x11/
/win64/
/osx/
(depends on platform) <- contains compiled c++ libraries -
gdwaterfft.gdnlib
<- Godot native library binding file, which tells Godot where to look for compiled libraries -
tessendorf.gdns
<- FFT Water Godot native script
-
-
Water.gd
<- example usage -
Water.shader
<- example shader
- Create
MeshInstance
and setPlaneMesh
as mesh property- adjust size and subdivide as you want (default: 100x100 size, 512x512 subdivide)
- Create
ShaderMaterial
in material property and attachWater.shader
to it - Attach
Water.gd
- Run
onready var tessendorf = load("res://bin/tessendorf.gdns").new()
tessendorf.create(128)
# General wave height
tessendorf.amplitude = 15.0
# Controlls weather (higher number, the more stormy the water will look)
tessendorf.wind_speed = 31.0
# Size of water plane (on plane 100x100 length=500)
tessendorf.length = 500.0
# How sharp the waves should be (needs to be negative)
tessendorf.lambda = -0.9
# Ignoring waves
tessendorf.smoothing = 1.0
# Waves direction...
tessendorf.wind_direction = Vector2(1.0, 0.0)
tessendorf.calculate()
In Water.gd
is an example of how to calculate passed time
tessendorf.update(time_that_passed)
tessendorf.send_displacement(shader_material, "name_of_shader_variable")
shader_material
is obtained using mesh.surface_get_material(0)
"name_of_shader_variable"
is the name of shader uniform, that is used for displacement