OpenGL ES Toon Shader in Cocos Creator?

OpenGL ES Toon Shader in Cocos Creator?
0

Hello!

I’m new to CC and was wondering if someone could point me in the right direction for how to create a toon shader in CC 2.1.2. I’ve seen several ways to implement materials/effects but I’m not sure which way is the correct way or how to go about it.

Here are a few things I’ve found:

    // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.  

    // Note: Current format version is experiment, the format may be changed.
    // The future format may not be compatible, you may need to update the script manually.

    %{
      techniques: [
        {
          passes: [
            {
              vert: vs
              frag: fs
              cullMode: none
              depthTest: true
              depthWrite: true
              blend: false
            }
          ]
          layer: 0
        }
      ]
      properties: {
        texture: {
          type: sampler2D
          value: null
        }
        alphaThreshold: {
          type: number
          value: 0.5
        }
      }
    %}

    %% vs {

    precision highp float;

    uniform mat4 cc_matViewProj;

    #if _USE_MODEL
      uniform mat4 cc_matWorld;
    #endif

    attribute vec3 a_position;
    attribute lowp vec4 a_color;

    #if USE_TEXTURE
      attribute mediump vec2 a_uv0;
      varying mediump vec2 v_uv0;
    #endif

    varying lowp vec4 v_color;

    void main () {
      mat4 mvp;
      
      #if _USE_MODEL
        mvp = cc_matViewProj * cc_matWorld;
      #else
        mvp = cc_matViewProj;
      #endif

      #if USE_TEXTURE
        v_uv0 = a_uv0;
      #endif

      v_color = a_color;

      gl_Position = mvp * vec4(a_position, 1);
    }

    }

    %% fs {

    precision highp float;

    #if USE_TEXTURE
      uniform sampler2D texture;
      varying mediump vec2 v_uv0;
    #endif

    #include <alpha-test>

    varying lowp vec4 v_color;

    void main () {
      vec4 color = v_color;

      #if USE_TEXTURE
        color *= texture2D(texture, v_uv0);
        #if _USE_ETC1_TEXTURE
          color.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;
        #endif
      #endif

      ALPHA_TEST(color);

      gl_FragColor = color;
    }

    }

Let’s ask @jare to provide a resource.

Can you attach a full project?or you can take look by this demo bellow.