Giter Site home page Giter Site logo

waterrw's Introduction

WaterRW

日本語版

WaterRW is 2D interactive water system for Unity.

001

Requirements

  • This project is made with Unity 2020.3.12f1.
  • By default, Burst package is required.

Quick Start

  1. Download WaterRW.unitypackage from releases page.
  2. Install Burst package from Package Manager.
  3. Add Ruccho/Water-RW/Prefabs/Water-RW (Compute).prefab to your scene.

Water-RW prefab is composed of WaterRWCompute script, MeshFilter, and MeshRenderer with Water-RW/With Compute material.

Some platforms such as WebGL or old mobile devices don't support Compute Shader. Make sure your target platform does before using WaterRW.

(Legacy implementation with C# Job System is also included in the package but it is no longer supported.)

Material Settings Guide

WaterRW uses the shader Water-RW/With Compute.

image

Property Type
Tint Color Tint color.
Pixel Snap Float Same as one in Sprites-Default shader.
Normal A Texture2D Normal map A. Use tiling properties to scale a map.
Normal A Intensity Float Amount of distortion of normal map A.
Normal A Speed Vector Scroll speed of normal map A. Only X and Y works.
Normal B Texture2D Same as normal A.
Normal B Intensity Float Same as normal A.
Normal B Speed Vector Same as normal A.
Background Blend Float Rate of reflection blend.
Transparency Float Dark reflection areas goes transparent.
Multiplier Color Color multiplier.
Addend Color Color addend.
Wave Size in Viewport Space Float Horizontal size of near-surface distortion.
Wave Distance in Viewport Float Vertical size of near-surface distortion.
Wave Frequency by Position Float Frequency of sin curve used for near-surface distortion by vertical position.
Wave Frequency by Time Float Frequency of sin curve used for near-surface distortion by vertical time.
Surface Color Color Color of surface line.
Surface Width in Pixel Color Width of surface line in pixels.
Fade Distance in Viewport Space Float Vertical size of fade to avoid display reflection areas out of GrabPass.

Enable Interactions

image

WaterRW supports rough interation with rigidbodies. (Colliders with complex shapes may not be handled correctly!)

In inspector of WaterRWCompute script, select layers to interact with in Layers To Interact With property.

WaterRWCompute Settings

image

Property Type
Mesh segments Per Unit float Numbers of mesh divisions per unit.
Update Mode FixedUpdate / Update Timing to calculate wave. Use FixedUpdate to work interactions correctly.
Override Fixed Time Step bool Determine whether to use custom timestep.
Fixed Time Step float Custom time step.
C float The constant used in wave calculation. Increasing this will increase the speed of the waves.
Decay float Coefficient for damping waves.
Enable Interaction float Determine whether to use interaction.
Layers To Interact With LayerMask Layers to interact with.
Spatial Scale float Horizontal scale used in wave calculation.
Max Interaction Items float Max number of rigidbodies to interact with.
Wave Buffer Pixels Per Unit float Resolution of buffers used to wave calculation.
Scroll To Main Camera bool Track the range of the wave calculation to the position of the main camera.
Max Surface width float Max width of the wave in world scale.

Avoid Divergence

Values of Fixed Time Step, C, Spatial Scale and Wave Buffer Pixels Per Unit may cause divergence.

To avoid divergence, keep 0 ≤ (C * dt / dx) ≤ 1.


dt = time step (Fixed Time Step when Override Fixed Time Step is true, otherwise Time.deltaTime or Time.fixedDeltaTime is used)

dx = Spatial Scale / Wave Buffer Pixels Per Unit


Buffer Scrolling

Although the size of the buffer used for wave calculation is finite, interaction with the seemingly infinite surface of the water can be achieved by making the wave calculation range follow the camera position. If Scroll To Main Camera is true, it will automatically follow Camera.main. To set it manually, set the X coordinate to float WaterRWCompute.WavePosition.

waterrw's People

Contributors

ruccho avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.