Skip to content

Commit

Permalink
fix: uvs for pass Geometry were not in texture space
Browse files Browse the repository at this point in the history
  • Loading branch information
bhouston committed Jul 19, 2020
1 parent 7b2ff75 commit 7d82a46
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/lib/geometry/primitives/passGeometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7d82a46

Please sign in to comment.