Why my circle wave has a hole in the center ?

This is simplified version without light, the wave center is (0,0)

Shader "Water/CircleWaveHasHole"
{
    Properties
    {
        _Color("Color", Color) = (1,1,1,1)
        _MainTex("Texture", 2D) = "white" {}
        [Gamma]_Metallic("Metallic", Range(0,1)) = 0
        _Smoothness("Smoothness", Range(0,1)) = 0

        _Wave1("Wave1  (ALQP)", Vector) = (0.2,5,0.2,1)//A:amplitude, L:wavelength, Q:steepness P:Initial phase
        _Center1("Wave1 Center", Vector) = (1,1,1,1)//
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #include "UnityCG.cginc"

            #define TAU (2*UNITY_PI)
            #define TIME (_Time.y)
            struct GerstnerWave {
                float amplitude;
                float wavelength;
                float speed;
                float3 dir;
                float4 center;
                float steepness;
                float w;
            };

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;
            float4 _Color;
            float _Metallic;
            float _Smoothness;

            float4 _Wave1;
            float4 _Center1;

            void GerstnerPositionSum(float3 originalPoint, GerstnerWave wave, inout float3 positionOffset) {
                float phi = dot(normalize(originalPoint.xz - float2(0, 0)), originalPoint.xz);
                positionOffset.y += wave.amplitude*sin(phi);
            }

            v2f vert (appdata v)
            {
                v2f o;

                o.uv = TRANSFORM_TEX(v.uv, _MainTex);

                GerstnerWave wave;

                wave.amplitude = _Wave1[0];
                wave.wavelength = _Wave1[1];
                wave.steepness = _Wave1[2];
                wave.speed = _Wave1[3];
                wave.center = _Center1;
                wave.w = TAU / wave.wavelength;
                //float2 dir = abs(normalize(v.vertex.xz - _Center1.xz));
                //waves[0].dir = (dir.x, 0, dir.y);
                float3 positionOffset = float3(0, 0, 0);
                GerstnerPositionSum(v.vertex, wave, positionOffset);

                v.vertex.y += positionOffset.y;
                o.vertex = UnityObjectToClipPos(v.vertex);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                return fixed4(0,0,0,0);
            }
            ENDCG
        }
    }
}

I don’t know why has a hole in center, how can the vertex be deleted?
5177837--513932--upload_2019-11-15_15-16-3.png

5177837--513929--upload_2019-11-15_15-15-50.png

I suspect the problem is here: normalize(originalPoint.xz - float2(0, 0)). I bet your missing vertex is exactly at position 0, which means your are trying to normalize 0 which returns something that is either infinite or simply not a number. Either way, not something you want to use as a vertex position :slight_smile:

Recently I have been quite busy, sorry, I forget to reply. I modify the code like this:

float phi = 0;
if(originalPoint.x!=0 || originalPoint.z!=0 ){
    phi = dot(normalize(originalPoint.xz - float2(0, 0)), originalPoint.xz);
}

And I think if the wave is circle wave, use length(originalPoint.xz - float2(0, 0) is better.