#NVJOB Water Shader - simple and fast



Simple and fast water shader. Two types of water.
Supported rendering path deferred and forward.
It works on all platforms.
This shader is suitable for scenes where water is not a key element of the scene, but a decorative element.

For Unity version of at least 2019.1.8 (64-bit)
Current version 1.4.5
Download from Unity Asset Store Download from GitHub Archive of previous versions Report a Problem / Issue Tracker / FAQ


Information

The movement of the waves is carried out using global shader variables: _WaterLocalUvX, _WaterLocalUvZ, _WaterLocalUvNX, _WaterLocalUvNZ.

_WaterLocalUvX, _WaterLocalUvZ - Offset main texture.
_WaterLocalUvNX, _WaterLocalUvNZ - Offset normal map texture.

using UnityEngine; public class Water : MonoBehaviour { public float UvRotateSpeed = 0.4f; public float UvRotateDistance = 2.0f; public float UvBumpRotateSpeed = 0.4f; public float UvBumpRotateDistance = 2.0f; Vector2 lwVector, lwNVector; private void Awake() { lwVector = Vector2.zero; lwNVector = Vector2.zero; } void Update() { lwVector = Quaternion.AngleAxis(Time.time * UvRotateSpeed, Vector3.forward) * Vector2.one * UvRotateDistance; lwNVector = Quaternion.AngleAxis(Time.time * UvBumpRotateSpeed, Vector3.forward) * Vector2.one * UvBumpRotateDistance; Shader.SetGlobalFloat("_WaterLocalUvX", lwVector.x); Shader.SetGlobalFloat("_WaterLocalUvZ", lwVector.y); Shader.SetGlobalFloat("_WaterLocalUvNX", lwNVector.x); Shader.SetGlobalFloat("_WaterLocalUvNZ", lwNVector.y); } }
#NVJOB Nicholas Veselov (nvjob.github.io) | Water Shader (simple and fast) Unity Asset

For working shaders on mobile platforms with Forward Rendering.

In asset this fix is already added to the general script.

using UnityEngine; using UnityEngine; [ExecuteInEditMode] public class depthTextureFix : MonoBehaviour { void OnEnable() { GetComponent().depthTextureMode = DepthTextureMode.Depth; } }

The rotation of the wind synchronously with water.

Optionally, you can not use.

using UnityEngine; using UnityEngine; public class WindZoneRot : MonoBehaviour { Transform tr; private void Awake() { tr = transform; } void LateUpdate() { tr.rotation = Quaternion.LookRotation(new Vector3(Shader.GetGlobalFloat("_WaterLocalUvNX"), 0, Shader.GetGlobalFloat("_WaterLocalUvNZ")), Vector3.zero) * Quaternion.Euler(0, -40, 0); } }
#NVJOB Nicholas Veselov (nvjob.github.io) | Water Shader (simple and fast) Unity Asset

#NVJOB Nicholas Veselov (nvjob.github.io) | Water Shader (simple and fast) Unity Asset

#NVJOB Nicholas Veselov (nvjob.github.io) | Water Shader (simple and fast) Unity Asset

#NVJOB Nicholas Veselov (nvjob.github.io) | Water Shader (simple and fast) Unity Asset

License

This project is licensed under MIT License
(C) Copyright 2016-2019 #NVJOB
Nicholas Veselov - independent software and assets developer
Website powered by GitHub.com