From cd303e95bda7a1578cafcbb11f6f83b2ca547385 Mon Sep 17 00:00:00 2001 From: Jack Davenport Date: Thu, 30 Jun 2022 12:34:43 +1000 Subject: [PATCH] Simplified GLSL code examples Used mix instead of calculating the interpolation directly, should clear up the example a lot. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6e3fd7f..7baaf07 100644 --- a/README.md +++ b/README.md @@ -54,15 +54,15 @@ Pass textureMerger.mergedTexture to your shader as a Texture uniform. Pass the r For **gl.POINTS** ```GLSL -float coordX = ((gl_PointCoord.x) * (endU - startU)) + startU; -float coordY = ((1.0 - gl_PointCoord.y) * (endV - startV)) + startV; +float coordX = mix(startU, endU, gl_PointCoord.x); +float coordY = mix(startV, endV, 1.0 - gl_PointCoord.y); vec4 textureColor = texture2D(texture, vec2(coordX, coordY)); ``` For the rest: ```GLSL // affine transformation on original UV of a vertex -float coordX = (uv.x * (endU - startU) + startU); -float coordY = (uv.y * (startV - endV) + endV); +float coordX = mix(startU, endU, uv.x); +float coordY = mix(startV, endV, uv.y); vec4 textureColor = texture2D(texture, vec2(coordX, coordY)); ```