Skip to content

Commit 1d297c6

Browse files
authored
0.2.0 Readme
1 parent 1a49e50 commit 1d297c6

File tree

1 file changed

+87
-9
lines changed

1 file changed

+87
-9
lines changed

README.md

Lines changed: 87 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,55 @@ Once you are happy with the shape of your river, you can use the *River -> Gener
3939
In case you want to access the river mesh directly to use it for other purposes such as generating a collision shape. You can use the *River -> Generate MeshInstance Sibling* option.
4040
![b5qdG0oYbV](https://user-images.githubusercontent.com/4955051/102623733-e1f88000-413a-11eb-8c79-99a1977fbca9.gif)
4141

42+
**Using a WaterSystem Node**
43+
44+
To generate a global height and flowmap of a river. You can add a *WaterSystem* node and generate a texture based on any *River* child nodes with the *WaterSystem -> Generate System Maps* option.
45+
![bnhOeLjP8H](https://user-images.githubusercontent.com/4955051/104091192-c6812080-5273-11eb-87a9-0684b306033e.gif)
46+
47+
**Using a Buoyant Node**
48+
49+
Adding a *Buoyant* node as a child to a *RigidBody* will allow the object to float on the river if a *WaterSystem* with valid maps is available.
50+
![image](https://user-images.githubusercontent.com/4955051/104091388-085e9680-5275-11eb-8564-84d196140da6.png)
51+
52+
**Using flow and height maps in shaders**
53+
54+
You can automatically assign the global textures from the *WaterSystem* node to *MeshInstances* to use them in shaders. See the *WaterSystem* parameters for details. Once the textures and coordinates are assigned you can use them in a shader like this:
55+
56+
```
57+
shader_type spatial;
58+
59+
uniform sampler2D water_systemmap;
60+
uniform mat4 water_systemmap_coords;
61+
varying vec3 world_vertex;
62+
63+
float water_altitude(vec3 pos) {
64+
vec3 pos_in_aabb = pos - water_systemmap_coords[0].xyz;
65+
vec2 pos_2d = vec2(pos_in_aabb.x, pos_in_aabb.z);
66+
float longest_side = water_systemmap_coords[1].x > water_systemmap_coords[1].z ? water_systemmap_coords[1].x : water_systemmap_coords[1].z;
67+
pos_2d = pos_2d / longest_side;
68+
float value = texture(water_systemmap, pos_2d).b;
69+
float height = value * water_systemmap_coords[1].y + water_systemmap_coords[0].y;
70+
return pos.y - height;
71+
}
72+
73+
void vertex() {
74+
world_vertex = (WORLD_MATRIX * vec4(VERTEX, 1.0)).xyz;
75+
}
76+
77+
void fragment() {
78+
float altitude = clamp(water_altitude(world_vertex), 0.0, 1.0);
79+
ALBEDO = vec3(altitude);
80+
}
81+
```
82+
83+
For effects such as this:
84+
85+
![UtzIm3ohmc](https://user-images.githubusercontent.com/4955051/104092678-75762a00-527d-11eb-9eff-18851b84a429.gif)
86+
87+
4288
River Parameters
4389
----------------
44-
The river's parameters are split into 4 sections.
90+
The river's parameters are split into 5 sections.
4591

4692
**Shape**
4793

@@ -51,17 +97,27 @@ The river's parameters are split into 4 sections.
5197

5298
**Material**
5399

54-
- *Flow Speed* - How fast the river flows.
55100
- *Texture* - The pattern used for the water. RG channels hold the normal map and B holds the foam pattern.
56-
- *Tiling* - The UV tiling used on the above texture.
101+
- *UV Scale* - The UV scaling used on the above texture.
57102
- *Normal Scale* - The strength of the normal mapping.
58-
- *Albedo* - The colour of the water will display beyond the clarity threshold.
103+
- *Albedo* - The two colours of the water mixed based on the depth set in *Gradient Depth*.
104+
- *Gradient Depth* - Use this to control how the albedo gradient is applied.
59105
- *Clarity* - How far light can travel in the water before only returning the albedo colour.
106+
- *Edge Fade* - The distance the river fades out when it intesects other objects to give the shore line a softer look.
60107
- *Roughness* - The roughness of the water surface, also affects the blurring that occurs in the refraction.
61108
- *Refraction* - How much the background get's bent by the water shape.
62-
- *Foam Albedo* - The colour of the foam.
63-
- *Foam Ammount* - Controls the foam cutoff in the shader, you may have to use the foam baking setting to change the amount of foam further. See below.
64-
- *Foam Smoothness* - Controls how the foam layers are combined to give a sharper or softer look.
109+
- *Flow* - Subcategory for flow options.
110+
- *Speed* - How fast the river flows.
111+
- *Base Strength* - Base multiplier of the flow vectors.
112+
- *Steepness Strength* - Flow vectors multiplied by the steepness of the river.
113+
- *Distance Strength* - Flow vectors multiplied by the distance field for faster flows further away from shore.
114+
- *Pressure Strength* - Flow vectors multiplied by a pressure map, to imitate the flow increasing when there is less available space in the river.
115+
- *Max Strength* - Clamps the maximum multiplier of the flow vectors.
116+
- *Foam* - Subcategory for the foam options.
117+
- *Albedo* - The colour of the foam.
118+
- *Ammount* - Controls the foam cutoff in the shader, you may have to use the foam baking setting to change the amount of foam further. See below.
119+
- *Steepness* - Gives the option to add in foam where the river is steep.
120+
- *Smoothness* - Controls how the foam layers are combined to give a sharper or softer look.
65121

66122
**Lod**
67123

@@ -70,23 +126,45 @@ The river's parameters are split into 4 sections.
70126
**Baking**
71127

72128
- *Resolution* - Controls the resolution of the baked flow and foam map. This texture does not need to be very large to look decent, so only increse it if needed as the baking time can increase a lot.
129+
- *Raycast Distance* - The collision map is calculated using raycasts from the river surface to detect colliders, adjust the length as needed.
130+
- *Raycast Layers* - The physics layers to use for the raycast.
73131
- *Dilate* - The amount of dilation happening to convert the collision map to an Distance Field. This value should generally not be adjusted.
74132
- *Flowmap Blur* - How much the flowmap is blurred to clear up seams or artifacts.
75133
- *Foam Cutoff* - How much of the Distance Field is cut off to generate the foam mask. Increasing this calue will make the foam mask tighter around the collisions.
76134
- *Foam Offset* - How far the foam strethes along the flow direction.
77135
- *Foam Blur* - How much the foam mask is blurred.
78136

137+
**Advanced**
138+
- *Custom Shader* - This option allows you to easily make a copy of the default shader and edit it.
139+
140+
WaterSystem Parameters
141+
----------------------
142+
- *System Map* - The baked system maps texture
143+
- *System Bake Resolution* - The resolution of the system maps
144+
- *System Group Name* - This group name is assigned at runtime, it is used by the *Buoyant* node to find the WaterSystem. If you only have one *WaterSystem*, you can just leave this be.
145+
- *Auto Assign Texture & Coordinates On Generate* - Subcategory for auto assign setting, used to send the system map and coordinates to materials to be used in shaders
146+
- *Wet Group Name* - This name will be used to find any *MeshInstances* that should have the maps assigned
147+
- *Surface Index* - The surface index the material you want to send the maps to is set on the *MeshInstance*, -1 means disabled.
148+
- *Material Override* - If the material is instead set as a Material Override, check this box for the maps to be assigned there.
149+
150+
Buoyant Parameters
151+
------------------
152+
- *Water System Group Name* - This is used to find the *WaterSystem* to get height and flow data from, this should match the value in your *WaterSystem*.
153+
- *Buoyancy Force* - The amount of upwards force applied to the *RigidBody* when the *Buoyant* is under the water level.
154+
- *Up Correcting Force* - The amount of torque force being added to the *RigidBody* to try and keep the object upright in the water.
155+
- *Flow Force* The amount the flow vectors from the *WaterSystem* get's applied to the *RigidBody*.
156+
- *Water Resistance* This sets the *RigidBody's* damping parameter when under the water level.
157+
79158
Current Limitations
80159
-------------------
81160
* There is only a river node so far, so no solution for lakes or oceans.
82-
* There is no system for detecting whether you are under the water and no effects to imitate the under water view.
83161
* There are no real time reflections on the water. Since godot does not allow Screen Space Reflections with transparent objects, the built-in SSR effect cannot be used. I will probably implement my own eventually.
84162
* There is no mesh displacement. Since Godot does not have tesselation, mesh displacement is not feasible.
85163
* Rivers do not interact with each other. At the moment there is no way to elegantly merge multiple rivers into one or splitting one into multiple. I plan to implement a solution for this eventually.
86164

87165
Acknowledgements
88166
---------------
89-
* Thanks to my patrons *Marcus Richter, Dmitriy Keane, spacechace0 and Johannes Wuesnch* for all their support.
167+
* Thanks to my patrons *Marcus Richter, Dmitriy Keane, spacechace0, Johannes Wuesnch, Winston and Little Mouse Games* for all their support.
90168

91169
Several people in the Godot community have helped me out with this.
92170
* *Zylann* has been really helpful, both with any issues I've had working on terrains, but also in that whenever I don't know how to do something in a plugin I generally find the answer somewhere in his code.

0 commit comments

Comments
 (0)