// Effect Syntax Guide: https://github.com/cocos-creator/docs-3d/blob/master/zh/material-system/effect-syntax.md
CCEffect %{
techniques:
-
name: opaque
passes:
-
vert: withwave-vs:vert
frag: withwave-fs:frag
properties: &props
_MainTex: { value: white ,editor: { displayName: Base layer }}
_DetailTex: { value: white, editor: { displayName: layer } }
_DetailColor: { value: [1.0, 1.0, 1.0, 1.0], editor: { displayName: layer Color , type: color } }
_ModelUpVector: { value: [0.0, 1.0, 0.0, 1.0]}
_ScrollX: { value: 0.0 , editor: { displayName: layer Scroll speed X }}
_ScrollY: { value: 0.02 , editor: { displayName: layer Scroll speed Y }}
_DetailScale: { value: 0.5, editor: { displayName: Detail Scale } }
_MMultiplier: { value: 1.0, editor: { displayName: Layer Multiplier } }
_RimColor: { value: [0.0, 0.0, 0.0, 0.0], editor: { displayName: Rim Color , type: color } }
-
-
name: transparent
passes:
-
vert: withwave-vs:vert # builtin header
frag: withwave-fs:frag
blendState:
targets:
-
blend: true
blendSrc: src_alpha
blendDst: one_minus_src_alpha
blendSrcAlpha: src_alpha
blendDstAlpha: one_minus_src_alpha
properties: *props
-
-
}%
CCProgram withwave-vs %{
precision highp float;
#include
#include
#include
#include
out vec2 v_position;
out vec2 v_uv;
out vec4 v_normal;
out float _ScrollX;
out float _ScrollY;
out float _DetailScale;
#if USE_INSTANCING // when instancing is enabled
#pragma format(RGBA8) // normalized unsigned byte
in vec4 a_instanced_color;
out vec4 v_instanced_color;
#endif
uniform TexCoords {
vec4 tilingOffset;
};
vec4 vert () {
StandardVertInput In;
CCVertInput(In);
mat4 matWorld, matWorldIT;
CCGetWorldMatrixFull(matWorld, matWorldIT);
vec4 pos = matWorld * In.position;
// v_position = pos.xyzw;
v_position = pos.xz;
v_normal = normalize((matWorldIT * vec4(In.normal, 0.0)).xyzw);
// vec4 pos = cc_matProj * (cc_matView * matWorld) * In.position;
// vec4 pos1 = matWorld * In.position;
// v_position = pos1.xyzw;
v_uv.xy = a_texCoord;
#if USE_INSTANCING
v_instanced_color = a_instanced_color;
#endif
CCPassShadowParams(pos);
return cc_matProj * (cc_matView * matWorld) * In.position;;
}
}%
CCProgram withwave-fs %{
precision highp float;
#include
#include
in vec2 v_uv;
in vec2 v_position;
in vec4 v_normal;
uniform sampler2D _MainTex;
uniform sampler2D _DetailTex;
uniform Constant {
float _ScrollX;
float _ScrollY;
float _MMultiplier;
float _DetailScale;
vec4 _ModelUpVector;
vec4 _DetailColor;
vec4 _RimColor;
};
#if USE_INSTANCING // when instancing is enabled
in vec4 v_instanced_color;
#endif
vec4 frag () {
vec4 tex = texture(_MainTex, v_uv.xy);
// vec2 uv1 = v_position.xz * _DetailScale + vec2(1.0* cc_time.x, 0.0* cc_time.y) ;
// vec2 uv1 = v_position.xy * _DetailScale + vec2(_ScrollX* cc_time.x, _ScrollY* cc_time.y) ;
vec2 uv1 = v_position.xy * 0.025 + vec2(_ScrollX* cc_time.x, _ScrollY* cc_time.y) ;
vec4 tex2 = texture(_DetailTex, uv1.xy);
// float percent = clamp(dot(_ModelUpVector.xyzw, normalize(v_position)-0.1), 0.0, 1.0);//
float percent = clamp(dot(_ModelUpVector.xyzw, v_normal), 0.0, 1.0);
vec4 col = tex + tex2 * _DetailColor * percent * _MMultiplier + _RimColor;
//vec4 col = tex + tex2 * _DetailColor * 0.5 * _MMultiplier + _RimColor;
#if USE_INSTANCING
col = col + v_instanced_color;
#endif
col.a = 1.0;
// if (col.a < 0.01) discard;
return CCFragOutput(col);
}
}%
放到3.3.0就报错 帮看下。怎么修改