Browse Source

more graphics docs;

bjorn 5 years ago
parent
commit
3e429ace7d

File diff suppressed because it is too large
+ 111 - 19
api/init.lua


+ 7 - 0
api/lovr/graphics/FilterMode.lua

@@ -24,5 +24,12 @@ return {
         this filter mode.  Gives the best results but is also slower.
       ]]
     }
+  },
+  related = {
+    'Texture:getFilter',
+    'Texture:setFilter',
+    'lovr.graphics.getDefaultFilter',
+    'lovr.graphics.setDefaultFilter',
+    'WrapMode'
   }
 }

+ 1 - 0
api/lovr/graphics/getDefaultFilter.lua

@@ -21,6 +21,7 @@ return {
       ]]
     }
   },
+  notes = 'The default filter is `trilinear`.',
   related = {
     'Texture:getFilter',
     'Texture:setFilter'

+ 1 - 1
api/lovr/graphics/getLineWidth.lua

@@ -13,5 +13,5 @@ return {
   related = {
     'lovr.graphics.line'
   },
-  notes = 'The default line width is `1.0`.'
+  notes = 'The default line width is `1`.'
 }

+ 14 - 3
api/lovr/graphics/newMesh.lua

@@ -28,6 +28,10 @@ return {
       type = 'table',
       description = 'A table of vertices.  Each vertex is a table containing the vertex data.'
     },
+    blob = {
+      type = 'Blob',
+      description = 'A binary Blob containing vertex data.'
+    },
     format = {
       type = 'table',
       description = 'A table describing the attribute format for the vertices.'
@@ -48,10 +52,13 @@ return {
       arguments = { 'vertices', 'mode', 'usage' },
       returns = { 'mesh' }
     },
+    {
+      arguments = { 'blob', 'mode', 'usage' },
+      returns = { 'mesh' }
+    },
     {
       description = [[
-        These variants accept a custom vertex format.  For more info, see the <a
-        data-key="Mesh">`Mesh`</a> page.
+        These variants accept a custom vertex format.  For more info, see the `Mesh` page.
       ]],
       arguments = { 'format', 'size', 'mode', 'usage' },
       returns = { 'mesh' }
@@ -59,7 +66,11 @@ return {
     {
       arguments = { 'format', 'vertices', 'mode', 'usage' },
       returns = { 'mesh' }
+    },
+    {
+      arguments = { 'format', 'blob', 'mode', 'usage' },
+      returns = { 'mesh' }
     }
   },
-  notes = 'Once created, the size of the Mesh can\'t be changed.'
+  notes = 'Once created, the size and format of the Mesh cannot be changed.'
 }

+ 75 - 5
api/lovr/graphics/newShader.lua

@@ -3,19 +3,42 @@ return {
   summary = 'Create a new Shader.',
   description = 'Creates a new Shader.',
   arguments = {
-    {
-      name = 'vertex',
+    vertex = {
       type = 'string',
       description = [[
         The code or filename of the vertex shader.  If nil, the default vertex shader is used.
       ]]
     },
-    {
-      name = 'fragment',
+    fragment = {
       type = 'string',
       description = [[
         The code or filename of the fragment shader.  If nil, the default fragment shader is used.
       ]]
+    },
+    default = {
+      type = 'DefaultShader',
+      description = 'A builtin shader to use for the shader code.'
+    },
+    options = {
+      type = 'table',
+      default = '{}',
+      description = 'Optional settings for the Shader.',
+      table = {
+        {
+          name = 'flags',
+          type = 'table',
+          default = '{}',
+          description = 'A table of key-value options passed to the Shader.'
+        },
+        {
+          name = 'stereo',
+          type = 'boolean',
+          default = 'true',
+          description = [[
+            Whether the Shader should be configured for stereo rendering (Currently Android-only).
+          ]]
+        }
+      }
     }
   },
   returns = {
@@ -25,8 +48,55 @@ return {
       description = 'The new Shader.'
     }
   },
+  notes = [[
+    The `flags` table should contain string keys, with boolean or numeric values.  These flags can
+    be used to customize the behavior of Shaders from Lua, by using the flags in the shader source
+    code.  Numeric flags will be available as constants named `FLAG_<flagName>`.  Boolean flags can
+    be used with `#ifdef` and will only be defined if the value in the Lua table was `true`.
+
+    The following flags are used by shaders provided by LÖVR:
+
+    - `animated` is a boolean flag that will cause the shader to position vertices based on the pose
+      of an animated skeleton.  This should usually only be used for animated `Model`s, since it
+      needs a skeleton to work properly and is slower than normal rendering.
+    - `alphaCutoff` is a numeric flag that can be used to implement simple "cutout" style
+      transparency, where pixels with alpha below a certain threshold will be discarded.  The value
+      of the flag should be a number between 0.0 and 1.0.  Any pixels with alpha less than the
+      cutoff will be discarded.
+    - `uniformScale` is a boolean flag used for optimization.  If the Shader is only going to be
+      used with objects that have a *uniform* scale (i.e. the x, y, and z components of the scale
+      are all the same number), then this flag can be set to use a faster method to compute the
+      `lovrNormalMatrix` uniform variable.
+    - `multicanvas` is a boolean flag that should be set when rendering to multiple Textures
+      attached to a `Canvas`.  When set, the fragment shader should implement the `colors` function
+      instead of the `color` function, and can write color values to the `lovrCanvas` array instead
+      of returning a single color.  Each color in the array gets written to the corresponding
+      texture attached to the canvas.
+    - The following flags are used only by the `standard` PBR shader:
+      - `normalMap` should be set to `true` to render objects with a normal map, providing a more
+      detailed, bumpy appearance.  Currently, this requires the model to have vertex tangents.
+      - `emissive` should be set to `true` to apply emissive maps to rendered objects.  This is
+        usually used to apply glowing lights or screens to objects, since the emissive texture is
+        not affected at all by lighting.
+      - `indirectLighting` is an *awesome* boolean flag that will apply realistic reflections and
+        lighting to the surface of an object, based on a specially-created skybox.  See the
+        `Standard Shader` guide for more information.
+      - `occlusion` is a boolean flag that uses the ambient occlusion texture in the model.  It only
+        affects indirect lighting, so it will only have an effect if the `indirectLighting` flag is
+        also enabled.
+      - `skipTonemap` is a flag that will skip the tonemapping process.  Tonemapping is an important
+        process that maps the high definition physical color values down to a 0 - 1 range for
+        display.  There are lots of different tonemapping algorithms that give different artistic
+        effects.  The default tonemapping in the standard shader is the ACES algorithm, but you can
+        use this flag to turn off ACES and use your own tonemapping function.
+
+    The `stereo` option is only necessary for Android.  Currently on Android, only stereo shaders
+    can be used with stereo Canvases, and mono Shaders can only be used with mono Canvases.
+  ]],
   related = {
     'lovr.graphics.setShader',
-    'lovr.graphics.getShader'
+    'lovr.graphics.getShader',
+    'lovr.graphics.newComputeShader',
+    'Shader'
   }
 }

+ 1 - 0
api/lovr/graphics/setDefaultFilter.lua

@@ -21,6 +21,7 @@ return {
     }
   },
   returns = {},
+  notes = 'The default filter is `trilinear`.',
   related = {
     'Texture:getFilter',
     'Texture:setFilter'

+ 6 - 3
api/lovr/graphics/setLineWidth.lua

@@ -6,15 +6,18 @@ return {
     {
       name = 'width',
       type = 'number',
+      default = '1',
       description = 'The new line width, in pixels.'
     }
   },
   returns = {},
   notes = [[
-    The default line width is `1.0`.
+    The default line width is `1`.
 
-    Driver support for line widths is poor.  The actual width of lines may be different from what is
-    set here.  In particular, some graphics drivers only support a line width of `1.0`.
+    GPU driver support for line widths is poor.  The actual width of lines may be different from
+    what is set here.  In particular, some graphics drivers only support a line width of `1`.
+
+    Currently this function only supports integer values from 1 to 255.
   ]],
   related = {
     'lovr.graphics.line'

+ 1 - 0
api/lovr/graphics/setPointSize.lua

@@ -6,6 +6,7 @@ return {
     {
       name = 'size',
       type = 'number',
+      default = '1.0',
       description = 'The new point size.'
     }
   },

+ 1 - 1
api/lovr/graphics/skybox.lua

@@ -2,7 +2,7 @@ return {
   tag = 'graphicsPrimitives',
   summary = 'Render a skybox.',
   description = [[
-    Render a skybox from a texture.  Two common kinds of skybox textures are supported: A 2d
+    Render a skybox from a texture.  Two common kinds of skybox textures are supported: A 2D
     equirectangular texture with a spherical coordinates can be used, or a "cubemap" texture created
     from 6 images.
   ]],

Some files were not shown because too many files changed in this diff