-
-
Notifications
You must be signed in to change notification settings - Fork 150
Fix stereo and 180 degree video rendering, add 360 stereo side-by-side #2038
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
Open
NataleVIL
wants to merge
3
commits into
Igalia:main
Choose a base branch
from
vil-it:upstream-video-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ struct VRLayer::State { | |
| std::function<void()> pendingEvent; | ||
| std::string name; | ||
| bool composited; | ||
| // Clear for layers drawing per-eye content, or both eyes get the left one. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please get rid of the comments, code is self explanatory and they get easily rotten. |
||
| bool useSameLayerForBothEyes; | ||
| State(): | ||
| initialized(false), | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,6 +124,10 @@ struct VRVideo::State { | |
| leftEye = createSphereProjection(false, device::EyeRect(0.0f, 0.5f, 1.0f, 0.5f)); | ||
| rightEye = createSphereProjection(false, device::EyeRect(0.0f, 0.0f, 1.0f, 0.5f)); | ||
| break; | ||
| case VRVideoProjection::VIDEO_PROJECTION_360_STEREO_LEFT_RIGHT: | ||
| leftEye = createSphereProjection(false, device::EyeRect(0.0f, 0.0f, 0.5f, 1.0f)); | ||
| rightEye = createSphereProjection(false, device::EyeRect(0.5f, 0.0f, 0.5f, 1.0f)); | ||
| break; | ||
| case VRVideoProjection::VIDEO_PROJECTION_180: | ||
| leftEye = createSphereProjection(true, device::EyeRect(0.0f, 0.0f, 1.0f, 1.0f)); | ||
| break; | ||
|
|
@@ -152,6 +156,9 @@ struct VRVideo::State { | |
| case VRVideoProjection::VIDEO_PROJECTION_360_STEREO: | ||
| create360StereoProjectionLayer(); | ||
| break; | ||
| case VRVideoProjection::VIDEO_PROJECTION_360_STEREO_LEFT_RIGHT: | ||
| create360LRProjectionLayer(); | ||
| break; | ||
| case VRVideoProjection::VIDEO_PROJECTION_180: | ||
| create180ProjectionLayer(); | ||
| break; | ||
|
|
@@ -267,6 +274,32 @@ struct VRVideo::State { | |
| rightTransform.ScaleInPlace(vrb::Vector(1.0f, 0.5f, 1.0f)); | ||
| equirect->SetUVTransform(device::Eye::Right, rightTransform); | ||
|
|
||
| // Per-eye UV transforms need one layer per eye, else mono. | ||
| equirect->SetUseSameLayerForBothEyes(false); | ||
|
|
||
| leftEye = vrb::Toggle::Create(create); | ||
| leftEye->AddNode(VRLayerNode::Create(create, equirect)); | ||
| rightEye = vrb::Toggle::Create(create); | ||
| rightEye->AddNode(VRLayerNode::Create(create, equirect)); | ||
| } | ||
|
|
||
| void create360LRProjectionLayer() { | ||
| vrb::CreationContextPtr create = context.lock(); | ||
| DeviceDelegatePtr device = deviceWeak.lock(); | ||
| VRLayerEquirectPtr equirect = device->CreateLayerEquirect(window->GetLayer()); | ||
| layer = equirect; | ||
|
|
||
| vrb::Matrix leftTransform = vrb::Matrix::Identity(); | ||
| leftTransform.ScaleInPlace(vrb::Vector(0.5f, 1.0f, 1.0f)); | ||
| equirect->SetUVTransform(device::Eye::Left, leftTransform); | ||
|
|
||
| vrb::Matrix rightTransform = vrb::Matrix::Position(vrb::Vector(0.5f, 0.0f, 0.0f)); | ||
| rightTransform.ScaleInPlace(vrb::Vector(0.5f, 1.0f, 1.0f)); | ||
| equirect->SetUVTransform(device::Eye::Right, rightTransform); | ||
|
|
||
| // Per-eye UV transforms need one layer per eye, else mono. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for this comment |
||
| equirect->SetUseSameLayerForBothEyes(false); | ||
|
|
||
| leftEye = vrb::Toggle::Create(create); | ||
| leftEye->AddNode(VRLayerNode::Create(create, equirect)); | ||
| rightEye = vrb::Toggle::Create(create); | ||
|
|
@@ -292,6 +325,8 @@ struct VRVideo::State { | |
|
|
||
| vrb::Matrix uvTransform = vrb::Matrix::Identity(); | ||
| uvTransform.ScaleInPlace(vrb::Vector(2.0f, 1.0f, 1.0f)); | ||
| // centers the hemisphere in front of the viewer. | ||
| uvTransform.TranslateInPlace(vrb::Vector(-0.5f, 0.0f, 0.0f)); | ||
|
|
||
| equirect->SetUVTransform(device::Eye::Left, uvTransform); | ||
| equirect->SetUVTransform(device::Eye::Right, uvTransform); | ||
|
|
@@ -342,10 +377,15 @@ struct VRVideo::State { | |
|
|
||
| vrb::Matrix uvTransform = vrb::Matrix::Identity(); | ||
| uvTransform.ScaleInPlace(vrb::Vector(2.0f, 0.5f, 1.0f)); | ||
| // centers the hemisphere in front of the viewer. | ||
| uvTransform.TranslateInPlace(vrb::Vector(-0.5f, 0.0f, 0.0f)); | ||
| equirect->SetUVTransform(device::Eye::Left, uvTransform); | ||
| uvTransform.TranslateInPlace(vrb::Vector(0.0f, 0.5f, 0.0f)); | ||
| equirect->SetUVTransform(device::Eye::Right, uvTransform); | ||
|
|
||
| // Per-eye UV transforms need one layer per eye, else mono. | ||
| equirect->SetUseSameLayerForBothEyes(false); | ||
|
|
||
| leftEye = create180LayerToggle(equirect); | ||
| rightEye = create180LayerToggle(equirect); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
app/src/main/res/drawable/ic_icon_videoplayback_360_stereo_leftright.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <vector | ||
| xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:width="24dp" | ||
| android:height="24dp" | ||
| android:viewportWidth="200" | ||
| android:viewportHeight="200"> | ||
| <path | ||
| android:fillColor="@color/void_color" | ||
| android:pathData="M27.5 75.87a8 8 0 0 0 10.85-3.24 68.68 68.68 0 0 1 107.49-17.39l-5 4.26a6.82 6.82 0 0 0 2.19 11.61L169 80.2a6.82 6.82 0 0 0 9-7.7l-5.06-26.95a6.83 6.83 0 0 0-11.16-3.92L158 44.77A84.69 84.69 0 0 0 24.27 65a8 8 0 0 0 3.23 10.87zM172.5 124.13a8 8 0 0 0-10.85 3.24 68.68 68.68 0 0 1-107.49 17.39l5-4.26a6.82 6.82 0 0 0-2.19-11.61l-25.92-9.09a6.82 6.82 0 0 0-9 7.7l5.06 26.95a6.83 6.83 0 0 0 11.16 3.92l3.73-3.14a84.09 84.09 0 0 0 52.86 23.94q3.21.26 6.41.25A84.77 84.77 0 0 0 175.73 135a8 8 0 0 0-3.23-10.87z"/> | ||
| <path | ||
| android:fillColor="@color/void_color" | ||
| android:pathData="M108 26.5v147a8 8 0 0 0-16 0v-147a8 8 0 0 0 16 0z"/> | ||
| </vector> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think we can get rid of 360s, it adds nothing