Skip to content

Commit f41e02a

Browse files
authored
Merge pull request #18 from Uralstech/unstable
UXR.QuestCamrea v4.2.1
2 parents c6b0f50 + c75d902 commit f41e02a

10 files changed

Lines changed: 30 additions & 273 deletions

File tree

Documentation/DocSource/QuickStart.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Quick Start
22

33
The example code provided in this quick start guide is for educational and demonstration purposes only. It may not represent best practices for production use.
4-
This quick start was last updated for **UXR.QuestCamera v4.1.0**.
4+
This quick start was last updated for **UXR.QuestCamera v4.2.1**.
55

66
## Breaking Changes Notice
77

@@ -246,7 +246,7 @@ Note that an awaiter of `TakePicture` also has to wait for the camera device and
246246

247247
### Vulkan-specific Capture Sessions (Experimental)
248248

249-
If your app uses the Vulkan Graphics API and targets API Level 33 (Android 13) or higher, you can use
249+
If your app uses the Vulkan Graphics API and Linear color space, and targets API Level 33 (Android 13) or higher, you can use
250250
`VulkanContinuousCaptureSession` and `VulkanOnDemandCaptureSession`, in the `Uralstech.UXR.QuestCamera.Vulkan` namespace,
251251
instead of `ContinuousCaptureSession` and `OnDemandCaptureSession`. It can improve memory usage and
252252
performance as it uses a native rendering plugin to perform YUV-to-RGBA conversion
@@ -456,10 +456,11 @@ This sample also uses the old input system. There is no code that references it,
456456

457457
### YUV Conversion Accuracy
458458

459-
OpenGL's `EXT_YUV_target`[<sup>[1]</sup>](#yuvconversionaccuracy_ref1) and Vulkan's `VK_KHR_sampler_ycbcr_conversion`[<sup>[2]</sup>](#yuvconversionaccuracy_ref2) may produce non-linear R'G'B' values when sampling YUV images. This package applies only rudimentary transfer-function corrections to convert these values to linear RGB, which may result in inaccurate colors.
460-
461-
Both the compute-shader-based YUV converter and the OpenGL converter are potentially inaccurate because they currently assume
462-
full-range BT.601 YUV data and do not account for the actual color range or standard of the source image.
459+
OpenGL's `EXT_YUV_target`[<sup>[1]</sup>](#yuvconversionaccuracy_ref1) and Vulkan's `VK_KHR_sampler_ycbcr_conversion`[<sup>[2]</sup>](#yuvconversionaccuracy_ref2) may produce non-linear R'G'B'
460+
values when sampling YUV images. Starting with UXR.QuestCamera v4.2.1, the package's Vulkan capture sessions use the SMPTE 170M[<sup>[3]</sup>](#yuvconversionaccuracy_ref3) inverse transfer
461+
function to convert sampled colors to linear RGB. The included compute-shader-based converter and OpenGL session currently assume full-range BT.601 YUV data and treat sampled colors as
462+
if they are in gamma space.
463463

464464
<a id="yuvconversionaccuracy_ref1"></a> <sup>[1]</sup> <https://registry.khronos.org/OpenGL/extensions/EXT/EXT_YUV_target.txt> (Issues, 9. Should sampling return samples converted in to linear space or raw samples?)<br/>
465-
<a id="yuvconversionaccuracy_ref2"></a> <sup>[2]</sup> <https://github.com/KhronosGroup/Vulkan-Docs/issues/2356>
465+
<a id="yuvconversionaccuracy_ref2"></a> <sup>[2]</sup> <https://github.com/KhronosGroup/Vulkan-Docs/issues/2356><br/>
466+
<a id="yuvconversionaccuracy_ref3"></a> <sup>[3]</sup> <https://developer.android.com/reference/android/hardware/DataSpace#TRANSFER_SMPTE_170M>

Documentation/DocSource/V3Migration.md

Lines changed: 0 additions & 221 deletions
This file was deleted.

Documentation/DocSource/toc.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@ items:
77
- name: Quick Start
88
href: QuickStart.md
99
- name: Advanced Samples
10-
href: AdvancedSamples.md
11-
- name: V3 Migration (Archived)
12-
href: V3Migration.md
10+
href: AdvancedSamples.md

THIRD-PARTY-LICENSES.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

UCamera/VulkanPlugin/Shaders/Render.frag

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,26 @@ layout(set = 0, binding = 0) uniform sampler2D src;
55
layout(location = 0) in vec2 uv;
66
layout(location = 0) out vec4 outColor;
77

8+
// Inverse transfer function for SMPTE 170M, formulae from:
9+
// https://www.kernel.org/doc/Documentation/media/uapi/v4l/colorspaces-details.rst
10+
// Adjusted for 0-1 input range.
11+
12+
const float inverseExponent = 1.0 / 0.45;
13+
14+
float smpte170mInverseTransfer(float val) {
15+
16+
return val >= 0.081
17+
? pow((val + 0.099) / 1.099, inverseExponent)
18+
: val / 4.5;
19+
}
20+
821
void main() {
922
vec4 color = texture(src, uv);
1023

11-
// TODO: implement conversions from
12-
// https://developer.android.com/reference/android/hardware/DataSpace#TRANSFER_GAMMA2_2
13-
outColor = vec4(pow(color.rgb, vec3(2.2)), color.a);
24+
outColor = vec4(
25+
smpte170mInverseTransfer(color.r),
26+
smpte170mInverseTransfer(color.g),
27+
smpte170mInverseTransfer(color.b),
28+
1.0
29+
);
1430
}
Binary file not shown.
Binary file not shown.

UXR.QuestCamera/Packages/com.uralstech.uxr.questcamera/Runtime/Scripts/Sessions/GLES/GLESCaptureSession.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public sealed class Proxy : ProxyBase { }
4242
public bool HasNewFrame => _lastUpdateFrame == Time.frameCount;
4343

4444
/// <summary>The output texture with converted frames.</summary>
45+
// TODO: Change to RenderTexture and update conversion to use same transfer as the Vulkan shader.
4546
public readonly Texture2D Texture;
4647

4748
/// <summary>The capture timestamp of the last processed frame.</summary>

UXR.QuestCamera/Packages/com.uralstech.uxr.questcamera/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "UXR.QuestCamera",
44
"description": "A Unity package to use the new Meta Quest Passthrough Camera API.\n\nUXR.QuestCamera v4.0.0 is a rewrite of the package with lots of breaking changes. Please see the documentation, reference manual and updated sample for changes.",
55
"keywords": [],
6-
"version": "4.2.0",
6+
"version": "4.2.1",
77
"unity": "2022.3",
88
"hideInEditor": false,
99
"documentationUrl": "https://uralstech.github.io/UXR.QuestCamera/",

0 commit comments

Comments
 (0)