Browse Source

Document HDR stuff;

bjorn 3 months ago
parent
commit
0a5a93d53e
3 changed files with 73 additions and 0 deletions
  1. 26 0
      api/init.lua
  2. 8 0
      api/lovr/callbacks/conf.lua
  3. 39 0
      api/lovr/graphics/isHDR.lua

+ 26 - 0
api/init.lua

@@ -144,6 +144,11 @@ return {
                       type = "boolean",
                       description = "Whether the desktop window rendering should be antialiased."
                     },
+                    {
+                      name = "hdr",
+                      type = "boolean",
+                      description = "Whether the (**super experimental**) HDR mode should be enabled.  See `lovr.graphics.isHDR`."
+                    },
                     {
                       name = "shadercache",
                       type = "boolean",
@@ -12345,6 +12350,27 @@ return {
             }
           }
         },
+        {
+          name = "isHDR",
+          tag = "graphics-global",
+          summary = "Check if the **super experimental** HDR mode is active.",
+          description = "Returns whether the **super experimental** HDR mode is active.\n\nTo enable HDR, add `t.graphics.hdr` to `lovr.conf`.  When enabled, LÖVR will try to create an HDR10 window.  If the GPU supports it, then this function will return true and the window texture will be HDR:\n\n- Its format will be `rgb10a2` instead of `rgba8`.\n- The display will assume its colors are in the Rec.2020 color space, instead of sRGB.\n- The display will assume its colors are encoded with the PQ transfer function, instead of sRGB.\n\nFor now, it's up to you to write PQ-encoded Rec.2020 color data from your shader when rendering to the window.",
+          key = "lovr.graphics.isHDR",
+          module = "lovr.graphics",
+          notes = "The following shader helper functions make it easier to convert between sRGB colors and HDR10:\n\n    vec3 pqToLinear(vec3 color);\n    vec3 linearToPQ(vec3 color);\n    vec3 sRGBToRec2020(vec3 color);\n    vec3 rec2020ToSRGB(vec3 color);",
+          variants = {
+            {
+              arguments = {},
+              returns = {
+                {
+                  name = "hdr",
+                  type = "boolean",
+                  description = "Whether HDR is enabled."
+                }
+              }
+            }
+          }
+        },
         {
           name = "isTimingEnabled",
           tag = "graphics-global",

+ 8 - 0
api/lovr/callbacks/conf.lua

@@ -136,6 +136,14 @@ return {
               type = 'boolean',
               description = 'Whether the desktop window rendering should be antialiased.'
             },
+            {
+              name = 'hdr',
+              type = 'boolean',
+              description = [[
+                Whether the (**super experimental**) HDR mode should be enabled.  See
+                `lovr.graphics.isHDR`.
+              ]]
+            },
             {
               name = 'shadercache',
               type = 'boolean',

+ 39 - 0
api/lovr/graphics/isHDR.lua

@@ -0,0 +1,39 @@
+return {
+  tag = 'graphics-global',
+  summary = 'Check if the **super experimental** HDR mode is active.',
+  description = [[
+    Returns whether the **super experimental** HDR mode is active.
+
+    To enable HDR, add `t.graphics.hdr` to `lovr.conf`.  When enabled, LÖVR will try to create an
+    HDR10 window.  If the GPU supports it, then this function will return true and the window
+    texture will be HDR:
+
+    - Its format will be `rgb10a2` instead of `rgba8`.
+    - The display will assume its colors are in the Rec.2020 color space, instead of sRGB.
+    - The display will assume its colors are encoded with the PQ transfer function, instead of sRGB.
+
+    For now, it's up to you to write PQ-encoded Rec.2020 color data from your shader when rendering
+    to the window.
+  ]],
+  arguments = {},
+  returns = {
+    hdr = {
+      type = 'boolean',
+      description = 'Whether HDR is enabled.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'hdr' }
+    }
+  },
+  notes = [[
+    The following shader helper functions make it easier to convert between sRGB colors and HDR10:
+
+        vec3 pqToLinear(vec3 color);
+        vec3 linearToPQ(vec3 color);
+        vec3 sRGBToRec2020(vec3 color);
+        vec3 rec2020ToSRGB(vec3 color);
+  ]]
+}