下面是处理采样放的的问题了,直接贴代码:
varying vec2 v_texCoord;
uniform float scale_factor;
uniform vec2 min_texCoord;
uniform vec2 max_texCoord;
uniform vec2 offset_texCoord;
vec2 convertToOriginCoordinate(vec2 uv) {
return (uv*scale_factor + offset_texCoord);
}
void main() {
vec2 new_uv = convertToOriginCoordinate(v_texCoord);
vec4 col = vec4(0.0);
if(new_uv.x >= min_texCoord.x && new_uv.y >= min_texCoord.y && new_uv.x <= max_texCoord.x && new_uv.y <= max_texCoord.y) {
col = texture2D(CC_Texture0, new_uv);
}
gl_FragColor = col;
}
scale_factor是缩放系数
min_texCoord:最小纹理坐标,一般是(0.0, 0.0),后面再说为什么不写死0.0,外部代码传入。
max_texCoord:最大纹理坐标,一般是(1.0, 1.0),外部代码传入。
of