hotschpotsh/product-scroll-poc/vertexShader.glsl

21 lines
465 B
GLSL

varying vec2 vUv;
varying float vDisplacement;
uniform sampler2D tDepth;
uniform float uDepthScale;
void main() {
vUv = uv;
// Read depth from texture
float depth = texture2D(tDepth, uv).r;
vDisplacement = depth;
// Displace z position based on depth
vec3 newPosition = position;
newPosition.z += depth * uDepthScale;
gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0);
}