creator version: 2.2.1
CCEffect %{
techniques:
- passes:
- vert: vs
frag: fs
blendState:
targets:
- blend: true
rasterizerState:
cullMode: none
properties:
texture: { value: white }
alphaThreshold: { value: 0.5 }
}%
CCProgram vs %{
precision highp float;
#include <cc-global>
#include <cc-local>
in vec3 a_position;
in vec4 a_color;
out vec4 v_color;
in vec2 a_uv0;
out vec2 v_uv0;
void main () {
vec4 pos = vec4(a_position, 1);
#if CC_USE_MODEL
pos = cc_matViewProj * cc_matWorld * pos;
#else
pos = cc_matViewProj * pos;
#endif
v_uv0 = a_uv0;
v_color = a_color;
gl_Position = pos;
}
}%
CCProgram fs %{
precision highp float;
#include <alpha-test>
#include <cc-global>
in vec4 v_color;
in vec2 v_uv0;
float wave_max_height = 0.05;
float total_offset = 0.8;
uniform sampler2D texture;
void main () {
vec4 o = vec4(1.0);
// float wave_offset = sin(v_uv0.x * 4.0 + cc_time.x * 4.0) * wave_max_height;
// if(total_offset + wave_offset > v_uv0.y){
// discard;
// // o = vec4(v_uv0.y);
// }
if(v_uv0.y < 0.5){
discard;
}
o *= texture(texture, v_uv0);
o *= v_color;
gl_FragColor = o;
}
}%
上面是一份片元着色器的代码,材质贴在某些图片上,没有渲染出任何像素,最后测试发现,从渲染管线拿到的uv坐标y值始终是一个非常小的浮点值,有些图片则是符合预期显示了一半,但是去掉discard的逻辑,又可以正确的从texture映射到像素
传递到顶点着色器的a_uv0的取值范围不是[0, 1]吗,大佬们解答一下
整理了一个demo,大佬们看看有什么问题TestUV.zip (731.8 KB)

