123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
- CCEffect %{
- techniques:
- - passes:
- - vert: vs
- frag: fs
- blendState:
- targets:
- - blend: true
- rasterizerState:
- cullMode: none
- properties:
- texture: { value: white }
- u_point: { value: [1,1] }
- u_start: {value: 0 }
- alphaThreshold: { value: 0.5 }
- outlineSize: { value: [0.1,0.01] }
- outlineColor: { value: [1,0,0,0.0] }
- }%
- CCProgram vs %{
- precision highp float;
- #include <cc-global>
- #include <cc-local>
- in vec3 a_position;
- in vec4 a_color;
- out vec4 v_color;
- #if USE_TEXTURE
- in vec2 a_uv0;
- out vec2 v_uv0;
- #endif
- uniform Constant{
- vec2 u_point;
- float u_start;
- };
- void main () {
- vec4 pos = vec4(a_position, 1);
-
- pos.x += (u_point.x - pos.x) * ((pos.y - u_start) / (pos.y - u_point.y));
-
- // 下面的代码基本都不敢动,我们只修改上面
- // 模型的顶点变换 不敢动!
- #if CC_USE_MODEL
- pos = cc_matViewProj * cc_matWorld * pos;
- #else
- pos = cc_matViewProj * pos;
- #endif
- // 给片元着色器传值 v_uv0 不敢动!
- #if USE_TEXTURE
- v_uv0 = a_uv0;
- #endif
- // 给片元着色器传值 v_color 不敢动! 这个v_color就是在sprite组件里能调整的颜色的值
- v_color = a_color;
- // 输出的最终坐标。
- gl_Position = pos;
- }
- }%
- CCProgram fs %{
- precision highp float;
-
- #include <alpha-test>
- #include <texture>
- in vec4 v_color;
- #if USE_TEXTURE
- in vec2 v_uv0;
- uniform sampler2D texture;
- #endif
-
- uniform line{
- vec4 outlineColor;
- vec2 outlineSize;
- };
- void main () {
- vec4 o = vec4(1, 1, 1, 1);
- #if USE_TEXTURE
- CCTexture(texture, v_uv0, o);
- #endif
-
- o *= v_color;
- ALPHA_TEST(o);
- gl_FragColor = o;
- }
-
- }%
|