// cocoscreator 版本2.3.0
// 大家好 ,下面变量 a_uv0 和 a_color 我不知道是如何和什么赋值呢,请问各位大佬!!!
// 都带 in 的修饰符,确没有赋值函数, 也没有外部赋值!!!
// Copyright © 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 }
time: { value: 0 }
speed: { value: 0.002 }
}%
- blend: true
- vert: vs
CCProgram vs %{
precision highp float;
#include
in vec3 a_position;
// --------------------------------
// 大家好 in 的修饰符是仅供外接传入的值 函数不能修改
// 但是我在用shader的时候没有给他赋值,但是下面的main函数确直接用了这个值
// 请问下传入值的流程是什么呢, 外部又如何给他赋值呢!
in mediump vec2 a_uv0;
in vec4 a_color;
out vec4 v_color;
out mediump vec2 v_uv0;
void main () {
gl_Position = cc_matViewProj * vec4(a_position, 1);
v_uv0 = a_uv0;
v_color = a_color;
}
}%
CCProgram fs %{
precision highp float;
uniform Time {
float time;
};
uniform SPEED {
float speed;
};
uniform sampler2D texture;
in mediump vec2 v_uv0;
in vec4 v_color;
void main () {
vec2 uv = v_uv0.xy;
uv.x += time * speed;
uv.x = fract(uv.x);
vec4 color = texture2D(texture, uv);
#if CC_USE_ALPHA_ATLAS_TEXTURE
color.a *= texture2D(texture, uv + vec2(0, 0.5)).r;
#endif
gl_FragColor = color;
}
}%