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

Fix oct-encoded normal upsampling. #1961

Merged
merged 12 commits into from
Jul 27, 2014

Conversation

abwood
Copy link
Contributor

@abwood abwood commented Jul 24, 2014

Cannot linearly interpolate oct encoded normals in all cases, due to how the octrahedron is unwrapped into a unit square.

…s in all cases, due to how the octrahedron is unwrapped into a unit square.
@abwood
Copy link
Contributor Author

abwood commented Jul 24, 2014

@kring Can you take a look at this?

return Cartesian3.normalize(result, result);
}

function octEncode(vector, out) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a generic unit-tested function (even if it is @private) since we are going to want it for the geometry pipeline, which we are going to start work on again soon for KML? Perhaps it is a function Cartesian3? Or perhaps it is better to make a new oct class and put static decode and encode functions in it.

signNotZero and toSNorm could probably go in Math.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy to. I was on the fence about moving these into Core in this pull request since it is currently only used in this location.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least the geometry pipeline will also use them. Probably dynamic buffers too if it is a win (I bet yes) ( #932). I could also see billboards using something similar for vertex compression ( #419). 3D models will also use this (but won't need the code since it will be done server-side).

/**
* Encodes a normalized vector into 2 bytes following the 'oct' encoding.
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
* Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this wording is a little klunky and we we usually make these link tags. How about?

Encodes a normalized vector into 2 bytes following the 'oct' encoding as described in {@link http://jcgt.org/published/0003/02/01/|A Survey of Efficient Representations of Independent Unit Vectors}.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I would consolidate most of the doc for this function and the decode function and move it into the Oct declaration above.

@abwood
Copy link
Contributor Author

abwood commented Jul 25, 2014

This is ready for review.

}
var magSquared = Cartesian3.magnitudeSquared(vector);
if (Math.abs(magSquared - 1.0) > CesiumMath.EPSILON6) {
throw new DeveloperError('vector must be normalized.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be documented.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jul 25, 2014

Looks good, thanks @abwood.

@kring can have a final look. We want to merge this by Monday or Tuesday for 1.0.

@abwood
Copy link
Contributor Author

abwood commented Jul 26, 2014

Alright, exceptions have been documented. Thanks for the review.

* Cigolle et al 2014: {@link http://jcgt.org/published/0003/02/01/}
*
* @namespace
* @alias Oct
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be public? Seems like it would be a private class to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, seems like it probably should be private. Easy enough to make it public in the future if there's a need for it.

@@ -107,6 +107,8 @@ Change Log
* Added northUpEast transform to help support display of glTF models because Y is their up axis.
* Cesium can now render an unlimited number of imagery layers, no matter how few texture units are supported by the hardware.
* Added `czm_octDecode` and `czm_signNotZero` builtin functions.
* Added `Oct` namespace that defines static functions for encoding and decoding normalized unit vectors to and from oct-encoding.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to go away now that Oct is private.

@kring
Copy link
Member

kring commented Jul 26, 2014

Just those two comments, one of which is incredibly minor and you can feel free to ignore it. Everything else looks good.

@abwood
Copy link
Contributor Author

abwood commented Jul 27, 2014

Alright, thanks for the feedback. Updates are included.

kring added a commit that referenced this pull request Jul 27, 2014
@kring kring merged commit 0a90b19 into CesiumGS:master Jul 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants