Skip to content

Commit

Permalink
Work around Oculus ColorScale bug (#3259)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluemarvin committed Apr 27, 2020
1 parent 32305d7 commit a7cbec3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/src/main/cpp/vrb
Submodule vrb updated 1 files
+2 −2 include/vrb/Color.h
14 changes: 13 additions & 1 deletion app/src/oculusvr/cpp/OculusVRLayers.h
Expand Up @@ -77,9 +77,11 @@ class OculusLayerBase : public OculusLayer {
virtual void
Update(const ovrTracking2 &aTracking, ovrTextureSwapChain *aClearSwapChain) override {
vrb::Color tintColor = layer->GetTintColor();
if (!IsComposited() && layer->GetClearColor().Alpha()) {
if (!IsComposited() && (layer->GetClearColor().Alpha() > 0.0f)) {
tintColor = layer->GetClearColor();
tintColor.SetRGBA(convertColor(tintColor.Red()), convertColor(tintColor.Green()), convertColor(tintColor.Blue()), tintColor.Alpha());
}

ovrLayer.Header.ColorScale.x = tintColor.Red();
ovrLayer.Header.ColorScale.y = tintColor.Green();
ovrLayer.Header.ColorScale.z = tintColor.Blue();
Expand Down Expand Up @@ -158,7 +160,17 @@ class OculusLayerBase : public OculusLayer {
return (IsComposited() || layer->GetClearColor().Alpha() == 0) ? swapChain : aClearSwapChain;
}

protected:
virtual ~OculusLayerBase() {}

// Convert sRGB to linear RGB. Used to work around bug in Oculus compositor.
float convertColor(const float color) {
if (color > 0.04045f) {
return powf(color + 0.055f, 2.4f) / 1.055f;
} else {
return color / 12.92f;
}
}
};


Expand Down

0 comments on commit a7cbec3

Please sign in to comment.