07-10-2019 08:35 AM
04-07-2021 05:06 PM
Did you ever figure out the correct way to do this. My render output seems MUCH darker in the oculus version compared to the desktop version of the same render engine.
04-09-2021 08:46 AM - edited 04-09-2021 09:00 AM
Hi anders.rein. The instructions I list above actually did wind up giving me the colors I wanted.
You can actually inspect my code if you want because I contributed it to the open source project LOVR.
The final version based on the "CubeWorld" example is here, this version is a year old.
This was later simplified by the LOVR core dev into this, the current (0.14 and 0.15/master) version.
Looking at the code, it appears we are still using the method in my post above (`GL_SRGB8_ALPHA8` calling `vrapi_CreateTextureSwapChain3`, plus `VRAPI_MODE_FLAG_FRONT_BUFFER_SRGB` calling `vrapi_EnterVrMode`). We also have a `glEnable(GL_FRAMEBUFFER_SRGB);` in our (non-platform-specific) opengl code.
If you are doing these things and the colors still look dark, the problem may be color space rather than srgb. The Quest supports multiple color spaces and Oculus documents an API for choosing color spaces here. The color space differences are not nearly so intense as the difference between interpreting data as SRGB and non-SRGB, but they are still pretty intense. By default they will use REC.2020 which is the "widest" color space— which is good if you're developing your assets for it, but if you developed your assets on a PC monitor they will look unnaturally deep when interpreted as REC.2020. Notice the VRAPI_COLORSPACE_RIFT_CV1 option in the doc, which I think should match the colors with Oculus Rift on desktop.
(Postscript: There is also a feature to set your color space in the AndroidManifest.xml file, however, this is not in the current documentation. Oculus posted a document about this at one point and then took it down. I am still using it in my in-development game however and it still works, for now. The way to do that was to put `<meta-data android:name="com.oculus.application.colorspace" android:value="Rec.709"/>` (or something) inside the `<application>` tag. The accepted values for "value" I know of are "Rec.709", "Rec.2020", "DCI-P3" or "Adobe". I use Rec.709 because my game started development on the Oculus Go and that value gave me the closest colors to what I saw on the Go. Using the `vrapi_SetClientColorDesc` function is probably better because it is officially documented and appears to support more color spaces.)