From 7d82a46a05b975330d6fdc4b27f8b61c25313b98 Mon Sep 17 00:00:00 2001 From: Ben Houston Date: Sun, 19 Jul 2020 17:24:19 -0400 Subject: [PATCH] fix: uvs for pass Geometry were not in texture space --- src/lib/geometry/primitives/passGeometry.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/lib/geometry/primitives/passGeometry.ts b/src/lib/geometry/primitives/passGeometry.ts index adcc06cc..ae16d512 100644 --- a/src/lib/geometry/primitives/passGeometry.ts +++ b/src/lib/geometry/primitives/passGeometry.ts @@ -12,14 +12,21 @@ import { Geometry } from "../Geometry"; /** * A 2D pass geometry * - * @param min homogeneous coordinate minimum - * @param max homogeneous coordinate minimum + * @param min in clip space + * @param max in clip space */ export function passGeometry(min = new Vector2(-1, -1), max = new Vector2(1, 1)): Geometry { const geometry = new Geometry(); geometry.indices = makeUint32Attribute([0, 1, 2, 0, 2, 3]); + + // in clip space: starts at bottom left, goes CW to top left, top right, bottom right. geometry.attributes["position"] = makeFloat32Attribute([min.x, min.y, min.x, max.y, max.x, max.y, max.x, min.y], 2); - geometry.attributes["uv"] = makeFloat32Attribute([0, 0, 0, 1, 1, 1, 1, 0], 2); + + // texture space is not the same as clip space. Thus this goes to the same locations but it has different + // values + geometry.attributes["uv"] = makeFloat32Attribute([1, 0, 0, 0, 0, 1, 1, 1], 2); + + // because -z points forward, the normals for this to point towards would have to be +z. geometry.attributes["normal"] = makeFloat32Attribute([0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1], 3); return geometry;