我正在使用深度效果视图处理自定义照片。我正在将触摸坐标传递给GLSurfaceView渲染器以“更改视角”。但是在纹理之间存在水平条纹,并且这样做时会产生倾斜。
我的片段着色器代码:
#ifdef GL_ES
precision highp float;
#endif
varying vec2 texcoordVarying;
uniform sampler2D texture;
uniform sampler2D depth;
uniform float time;
uniform vec2 touch;
uniform vec2 limit;
uniform vec4 resolution;
vec2 mirrored(vec2 v) {
vec2 m = mod(v,2.);
return mix(m,2.0 - m, step(1.0 ,m));
}
void main(void) {
vec2 uv = 1.0 * gl_FragCoord.xy / resolution.xy ;
vec2 vUv = (uv - vec2(0.5))*resolution.zw + vec2(0.5);
vUv.y = 1. - vUv.y;
vec4 tex1 = texture2D(depth,mirrored(vUv));
vec2 fake3d = vec2(vUv.x + (tex1.r - 0.5)* touch.x/limit.x, vUv.y + (tex1.r - 0.5)* touch.y/limit.y );
gl_FragColor = texture2D(texture,mirrored(fake3d));
}
我正在传递这样的坐标:
queueEvent {
renderer.touchTargetX = event.rawX / renderer.width
renderer.touchTargetY = event.rawY / renderer.height
}
requestRender()
GL_REPEAT
,请尝试使用GL_CLAMP_TO_EDGE
。