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
✨ [amp-story-360] Add scene orientation support (fixes #29514) #30138
Conversation
Hey @gmajoulet, @processprocess! These files were changed:
|
Added necessary shader modifications to Zuho library by @nicoptere to this PR to avoid another branch mess. Depending on the speed of the review I might or might not add the changes to the amp-story-360 player as well :) |
Ok, hold on as it seems it would make more sense to take Euler angles (heading, pitch, roll) instead of tilt values. We need to come up with different attribute names (and I need to make changes to zuho as well). Will update this thread when the PR is ready for review again. |
Ok, PTAL. The updated API is Open question: this is called orientation in Street View world so @nicoptere suggested Here is an Adding the new attributes with matching values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validator changes look good. I didn't review the javascript.
cc @newmuis @ampproject/wg-stories (I'm OOO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scene-
sounds good to me for the API prefix! It's generic enough.
third_party/zuho/zuho.js
Outdated
else { | ||
return vec4(0.0); | ||
} | ||
vec4 sample( float dx, float dy ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah... I'll be honest: I only understand the whitespace changes in this file 😅
Do we have any kind of inline comments to make this clearer? Or tests to assert the correct behavior?
As is, I have no idea whether this has broken something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey,
the zuho.js is a lightweight wrapper around a WebGL context, it is meant to display a collection of projections (formarly stored under zuho.Mapping) in the shader the bool unproject(vec2, out vec3);
method was meant to be replaced with different implementations corresponding to the different projections ( if( unproject(p, q) ){
in the next diff).
the goal of this unprojection was to convert the position of a 2D pixel into a 3D coordinate on a sphere to know where to sample the panorama texture.
with some projections, this would result in invalid coordinates, which in turn would give invalid texture sampling coordinate.
this condition was here to handle the invalid cases and fallback to a transparent pixel ( }else{ return vec4(0.); }
in the next diff)
branching in a shader is usually considered bad practice but more importantly, the projection we use is always valid as you can see from the previous commit L.88
so what we did was "simply" to remove the test (if(unproject(p,q){)else{}
) and inline the resulting 3D vector of the unproject method ( vec3 q = vec3(vPos + uPxSize * vec2(dx, dy), -1.0);
)
not sure if it's clearer but that's what happened here ^^'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch @nicoptere ! The only projection method we are using did not require this test and branching is costly, so it was not just dead code, but expensive dead code 😬. Which reminds me I need to start looking at @jonlab's EAC projection implementation and figure out how to remove all the branching.
As for the whitespace changes in the shader, it's meant to save a few bytes in the JS package: because it's a string literal, it does not get obfuscated/minimzed by the JS compiler like the rest of the code. We could easily shred more bytes, but the shader would become even more obscure 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, are these added lines pulling in code that we'd previously trimmed from the zuho library? Or is this net new code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no new logic in the shader with the latest implementation, only a small refactor/simplification. There were some heavier shader changes in the first proposed implementation (see this commit) but now the new logic has moved entirely to the JS side with the orientation
property and the new euler_
method.
Note however that more substantial changes will be required in the shader when we add EAC projection mapping for the video support. And I have no idea how we can add tests to a webgl shader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔
Are there ways we can add a manual test at least? Providing steps to test and expected results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely something to think about when we make these changes. Maybe screenshots would work with Percy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I can file an issue to follow up; LGTM for now.
Thanks for the review! Can you rerun the tests? Also is the PR blocked on @gmajoulet ? |
/to @rsimha for OWNERS approval :) |
anyone willing to owners-approve for third-party? @kristoferbaxter maybe? 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approval: validator changes only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @rsimha for /third_party
OWNERS approval
…) (ampproject#30138) * Base element with a working example * Add amp-img to test file * Fix base test, add play/pause/rewind methods * revert example to proper state * revert example to master state (for now) * actually revert example to master state (with new line) * Add comment in zuho's README.amp * Implement play/pause support for amp-story-360 in amp-story-page * Fix test * Update/add validator tests * restore missing newlines (wat) * more newline nonsense * Add tilt attributes to validator * Update example * Add orientation correction support to zuho library * Replacing tilt API with Euler angles for scene orientation correction * Remove unused Quaternion class * Whitespace & validator text fixes * Lint fix * Lint fix 2 * Lint fix 3 the fixening
First step for fixing #29514. This doesn't add the logic but since the validator has its own release cycle, we can get this out of the way first.