Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add normal compression to Primitive #1628

Closed
pjcozzi opened this issue Apr 21, 2014 · 0 comments
Closed

Add normal compression to Primitive #1628

pjcozzi opened this issue Apr 21, 2014 · 0 comments

Comments

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 21, 2014

There's a new JCGT paper: A Survey of Efficient Representations
for Independent Unit Vectors
. This is an excellent survey of space/time/quality tradeoffs for compressed normals.

To save memory, let's add this to the primitive's geometry pipeline. Read the paper to see what the best tradeoffs are for us, but this could be as simple as patching our vertex shaders with hemioct_to_float32x3 from Listing 6 and adding float32x3_to_hemioct in Listing 6 to our geometry pipeline as early as possible to minimize memory copies (do not move this into individual geometries though).

Let's do two stages:

  • Add [options.compressNormals=true] or whatever flag to the Primitive constructor to compress normal, binormal, and tangent (when they are present). Patch the vertex shader.
  • Since normal attributes will be vec2 now, when present pack normal and st into a vec4. Pack binormal and tangent into a vec4. Patch the vertex shader.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants