Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit a7cbec3

Browse files
authored
Work around Oculus ColorScale bug (#3259)
1 parent 32305d7 commit a7cbec3

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

app/src/main/cpp/vrb

app/src/oculusvr/cpp/OculusVRLayers.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ class OculusLayerBase : public OculusLayer {
7777
virtual void
7878
Update(const ovrTracking2 &aTracking, ovrTextureSwapChain *aClearSwapChain) override {
7979
vrb::Color tintColor = layer->GetTintColor();
80-
if (!IsComposited() && layer->GetClearColor().Alpha()) {
80+
if (!IsComposited() && (layer->GetClearColor().Alpha() > 0.0f)) {
8181
tintColor = layer->GetClearColor();
82+
tintColor.SetRGBA(convertColor(tintColor.Red()), convertColor(tintColor.Green()), convertColor(tintColor.Blue()), tintColor.Alpha());
8283
}
84+
8385
ovrLayer.Header.ColorScale.x = tintColor.Red();
8486
ovrLayer.Header.ColorScale.y = tintColor.Green();
8587
ovrLayer.Header.ColorScale.z = tintColor.Blue();
@@ -158,7 +160,17 @@ class OculusLayerBase : public OculusLayer {
158160
return (IsComposited() || layer->GetClearColor().Alpha() == 0) ? swapChain : aClearSwapChain;
159161
}
160162

163+
protected:
161164
virtual ~OculusLayerBase() {}
165+
166+
// Convert sRGB to linear RGB. Used to work around bug in Oculus compositor.
167+
float convertColor(const float color) {
168+
if (color > 0.04045f) {
169+
return powf(color + 0.055f, 2.4f) / 1.055f;
170+
} else {
171+
return color / 12.92f;
172+
}
173+
}
162174
};
163175

164176

0 commit comments

Comments
 (0)