
CCEffect %{
  techniques:
  - passes:
    - vert: unlit-vs
      frag: unlit-fs
      blendState:
        targets:
        - blend: true
      rasterizerState:
        cullMode: none
      properties:
        mainTexture: { value: white }
        textureWidth: { value: 600.0 }
        speed: { value: 10.0 }
        amplitude: { value: 5.0 }
        wave: { value: 5.0 }
        startPos: { value: [0.0, 0.0] }
}%


CCProgram unlit-vs %{

  precision highp float;

  #include <builtin/uniforms/cc-local>
  #include <builtin/uniforms/cc-global>

  in vec3 a_position;

  uniform LAMYOUMG_COM {
    float textureWidth;
    float speed;
    float amplitude;
    float wave;
    vec2 startPos;
  };

  #if USE_TEXTURE
    in mediump vec2 a_uv0;
    out mediump vec2 v_uv0;
  #endif

  void main () {
    float angleSpanH = wave * 3.14159265;
    float pz = amplitude * sin(cc_time.x * speed - (a_position.x - startPos.x + a_position.y - startPos.y) / textureWidth * angleSpanH);
    vec4 position = vec4(a_position.x, a_position.y + pz, a_position.z, 1);
    // vec4 position = vec4(a_position.x, a_position.y , a_position.z + pz, 1); // use in 3d

    #if USE_TEXTURE
      v_uv0 = a_uv0; 
    #endif
    gl_Position = cc_matViewProj * cc_matWorld * position;
  }
}%


CCProgram unlit-fs %{
  #include <builtin/uniforms/cc-global>

  precision highp float;
  
  #if USE_TEXTURE
    in vec2 v_uv0;
    uniform sampler2D mainTexture;
  #endif

  void main () {
    vec4 o = vec4(1, 1, 1, 1);

    #if USE_TEXTURE
      o *= texture(mainTexture, v_uv0);
    #endif
    gl_FragColor = o;
  }
}%
