docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Check waves and ripples

    To get information about water surface displacement due to waves and ripples, use the GetDeformationBuffer API.

    Example

    using UnityEngine;
    using UnityEngine.Rendering.HighDefinition;
    
    public class WaterDeformationExample : MonoBehaviour
    {
        // Reference to the water surface component
        public WaterSurface waterSurface;
    
        // Material to apply the deformation (waves and ripples) effect
        public Material waterMaterial;
    
        // Shader property name for deformation texture in the water material
        private readonly string _deformationTextureProperty = "_DeformationTex";
    
        void Start()
        {
            // Get the deformation buffer for the entire water surface
            Texture deformationBuffer = waterSurface.GetDeformationBuffer();
    
            if (deformationBuffer != null)
            {
                // Apply the deformation buffer as a texture to the water material
                waterMaterial.SetTexture(_deformationTextureProperty, deformationBuffer);
                Debug.Log("Deformation buffer applied successfully.");
            }
            else
            {
                Debug.LogWarning("Deformation buffer could not be retrieved.");
            }
        }
    
    }
    
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)