123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- // 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
- blend: true
- }
- ]
- 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_TINT
- attribute lowp vec4 a_color0;
- #endif
- attribute mediump vec2 a_uv0;
- varying mediump vec2 v_uv0;
- varying lowp vec4 v_light;
- #if USE_TINT
- varying lowp vec4 v_dark;
- #endif
- void main () {
- mat4 mvp;
-
- #if _USE_MODEL
- mvp = cc_matViewProj * cc_matWorld;
- #else
- mvp = cc_matViewProj;
- #endif
- v_uv0 = a_uv0;
- v_light = a_color;
- #if USE_TINT
- v_dark = a_color0;
- #endif
- gl_Position = mvp * vec4(a_position, 1);
- }
- }
- %% fs {
- precision highp float;
- uniform sampler2D texture;
- varying mediump vec2 v_uv0;
- #include <alpha-test>
- varying lowp vec4 v_light;
- #if USE_TINT
- varying lowp vec4 v_dark;
- #endif
- void main () {
- vec4 texColor = texture2D(texture, v_uv0);
- #if _USE_ETC1_TEXTURE
- texColor.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;
- #endif
- vec4 finalColor;
- #if USE_TINT
- finalColor.a = v_light.a * texColor.a;
- finalColor.rgb = ((texColor.a - 1.0) * v_dark.a + 1.0 - texColor.rgb) * v_dark.rgb + texColor.rgb * v_light.rgb;
- #else
- finalColor = texColor * v_light;
- #endif
- ALPHA_TEST(finalColor);
- gl_FragColor = finalColor;
- }
- }
|