tilt-shift-camera/app/src/main/res/raw/tiltshift_vertex.glsl

22 lines
649 B
Text
Raw Normal View History

// Vertex shader for tilt-shift effect.
//
// uTexMatrix: applied to texcoords. For the passthrough pass it carries the
// SurfaceTexture transform (sensor → display rotation, plus Y-flip). For the
// blur passes it is identity.
// uMirrorX: 1.0 to horizontally mirror texcoords (front-camera selfie view),
// 0.0 otherwise. Applied AFTER uTexMatrix.
attribute vec4 aPosition;
attribute vec2 aTexCoord;
uniform mat4 uTexMatrix;
uniform float uMirrorX;
varying vec2 vTexCoord;
void main() {
gl_Position = aPosition;
vec2 tc = (uTexMatrix * vec4(aTexCoord, 0.0, 1.0)).xy;
if (uMirrorX > 0.5) tc.x = 1.0 - tc.x;
vTexCoord = tc;
}