Simulate Fluids on Splines.
- Independent Surface visuals from Physics forces
- Works on any shape or spline
- optional Physics included
- Compatible with Effectors
- Use texture and materials of your choice
- Wave control
- Mask options
Setup from empty project in 30 secs
- Create a polygon using Water2D to fill a volume.
- Use multiple surfaces
- Use masks to merge all surfaces and volume
- Add effectors to the polygon mesh
Any property from the material can be overwritten in a local setting without affecting the material.
(textures, colors, shaders, colliders settings, physics, etc)
Actually... you dont need a material if you only use local settings.
Easy set up for 2D layers and 3D positioning
Surfaces can be applied to the whole edge of the shape or just between 2 selected points.
Multiple independent surfaces (sharing the same settings) can be applied to the same spline.
Also you can add multiple Components, so the same spline can contain several styles.
Callbacks to user you own methods when an object enter or leaves the surface.
It's a collection of render and physics settings for fluids surface simulation that can be replicated in any spline,
TL;DR It's an easy way to create 2D water :D
Time Saving:
When you update the material, every Spline in scene using the material also gets updated.
Updated Environment:
The water will look and behave exactly on every selected location, avoiding unexpected behaviors or missing components.
Faster iterations:
Now you can add swimming pools, rivers and other effects instantly, just draw a line and play with it withouth even coding.
Render settings as depth of the mesh, texture, shaders, colors, masks (to created seamless groups of water) , order in layer,
It is possible to create a textured mesh for the whole area, and another (optional) mesh for surface texture, and also can be combined with spline textures for surfaces.
Surface simulation (Waves):
real physics values for simulating the surface (mass, spread, spring constant, etc), and adjustments like force multiplier, thresholds and clamping, and restricing waves on the edges of the spline.
Already contains basic profiles (water, jelly, etc)
Colliders:
Provides different settings for optimizing the amount of colliders created and maximize the performance.
Physics:
(Optional) self-physics defined, thresholds and density for interacting with elements colliding with the mesh.
This physics are very basics and can be siwtched off and work combined with Effectors or your own code.
Textured surfaces can distort a texture, but using masks can only hide/show part of a background.
For polygons (closed shapes) using mask is the only generic solution I found.
Creating surfaces all around (you can try) will create would depend totally in the internal vertex architecture, and eventually would create unwanted results.
For closed shapes, my suggestion is to use both textured surface, and masks (and negative masks) to create a better result.
I also suggest to create your own shaders, mine are extremely basic.
1) Can I use my own physics settings? yes
2) Can I use effectors and composite colliders? yes
3) Can I use my own shaders/materials? yes
4) Can I use Line Renderer? yes, A component called "Spline Line Renderer" can save you lots of time for doing this and its auto-updated.
5) Can I have simulated surfaces only between 2 points of the shape? Yes. you can actually create as many surfaces between any 2 points as you want, and each will have its own behavior.
6) Can I create any shape with it? Not exactly. The surface shape is restricted to be an extension (extrusion) of the edge of the shape. To create the effect of all of it being a single block it would require specific mesh construction for every shape, and this is something that can not be done as a pre-setting.
However, using closed shape can create an extra mesh for the whole shape to be used for any extra purpose and/or making from the whole shape a single block
7) In which cases I would need to use masks? When you want to put 2 shapes next to each other and create a seamless effect of being a single object
8) plz ask :)
Use it when you want to have a full polygon of water2D instead of a single line.
The shape can contain multiple surfaces.
Perfect for "underwater" environments.
You need 3 meshes:
1- a mesh with the MASK BACKGROUND material
2- a mesh with the MASK material
3- Surface(s) mesh(es) ( with uses both MASK and MASK ERASER material)
and the most important: select the correct shader for each polygon.
BACKGROUND polygon:
This polygon is a simple texture mesh (squared), this polygon should cover the total area of the water polygon to use.
Use "mask bg" material
MASK polygon :
Its only purpose is to interact with the background polygon. Making visible ONLY overlaping areas.
Use "mask" material
Surfaces:
Instead of displaying a texture, surfaces can be created as a MASK to apply all the dynamic effects to the background mesh.
Use "mask" material and "negative mesh" option (explained below).
This is a complementary mesh above the surface mesh with the only purpose of hide the background by when the wave's are in movement.
Explanation:
When the Mask is used alone, it can only display more area from the background, but the background should also be hidden by the wave's movement.
The only way to create this effect is by adding a "Negative Mesh" ( a MASK ERASER) material.
Textured surfaces can distort a texture, but using masks can only hide/show part of a background.
For polygons (closed shapes) using mask is the only generic solution I found.
Creating surfaces all around (you can try) will create would depend totally in the internal vertex architecture, and eventually would create unwanted results.
For closed shapes, my suggestion is to use both textured surface, and masks (and negative masks) to create a better result.
I also suggest to create your own shaders, mine are extremely basic.
There are 3 shaders included:
- watermask Bg
- watermask
- watermaskeraser
The shaders uses the stencil buffer to hide or show areas when they overlap.
1- mask BG contains the texture to display and is only visible when it overlaps with the mask
2- (additive) mask is invisible, contains no texture, and its only purpose is to interact with the mask BG.
Creating a mask without BG or viceversa is totally useless
3- (substractive) mask eraser's behavior is similar to mask, but instead of displaying the bg, it hides the background on overlapping areas, with higher priority than the additive mask.
If you use this mask setup, you should also use the "create negative mask" checkbox on the render settings.
Surface using additive material allows the background to extend when waves goes above the water level, and using the negative mask allows the background to hide when the waves goes under the water level.
Sure, I encourage you do to it, Im pretty sure you want to achieve a more advance result using complex shaders, but I wanted to keep it as basic shader code as possible so people can understand the code and create their own versions.
The shaders have a VERY fragile and easy to screw up setup. Verify the next points:
1- The shaders need to have specific ORDER IN LAYER to work:
* mask polygon: any.
* background polygon order: any
* eraser polygon order: equal or bigger than mask.
I suggest you to use the "Auto order" checkbox, this will use the correct order in layer setup.
2- Also need specific values on code using the STENCIL BUFFER on the shader:
Render queues for each material:
mask: 1999 ( 1 before geometry)
mask bg: 3000
mask eraser: same as mask (1999)
All of them will work propertly only when the "Stencil Reference Value" is the same in all of the shaders ( I set value 10... for no reason in particular)
3- It happens to me (idkw) that sometimes the material appears missing or invalid. When this happens... Just select the material, and pick again the correspondant shader.. this solves it.