Browse Source

Update Shader:send table;

bjorn 5 years ago
parent
commit
2402386b2a
2 changed files with 34 additions and 21 deletions
  1. 1 1
      api/init.lua
  2. 33 20
      api/lovr/graphics/Shader/send.lua

+ 1 - 1
api/init.lua

@@ -11931,7 +11931,7 @@ return {
                 "ShaderBlock:sendBlock",
                 "Shader:sendBlock"
               },
-              notes = "The shader does not need to be active to update its uniforms.\n\nThe following type combinations are supported:\n\n<table>\n  <thead>\n    <tr>\n      <td>Uniform type</td>\n      <td>LÖVR type</td>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>float</td>\n      <td>number</td>\n    </tr>\n    <tr>\n      <td>int</td>\n      <td>number</td>\n    </tr>\n    <tr>\n      <td>vec2</td>\n      <td>{ x, y }</td>\n    </tr>\n    <tr>\n      <td>vec3</td>\n      <td>{ x, y, z } or vec3</td>\n    </tr>\n    <tr>\n      <td>vec4</td>\n      <td>{ x, y, z, w }</td>\n    </tr>\n    <tr>\n      <td>ivec2, ivec3, ivec4</td>\n      <td>{ ...numbers }</td>\n    </tr>\n    <tr>\n      <td>mat2, mat3</td>\n      <td>{ ...numbers }</td>\n    </tr>\n    <tr>\n      <td>mat4</td>\n      <td>{ x, y, z, w, ... } or mat4</td>\n    </tr>\n    <tr>\n      <td>sampler2D, sampler3D, samplerCube, sampler2DArray</td>\n      <td>Texture</td>\n    </tr>\n    <tr>\n      <td>image2D, image3D, imageCube, image2DArray</td>\n      <td>Texture</td>\n    </tr>\n  </tbody> </table>\n\nUniform arrays can be wrapped in tables or passed as multiple arguments.\n\nAn error is thrown if the uniform does not exist or is not used in the shader.  The `Shader:hasUniform` function can be used to check if a uniform variable exists.\n\n`Blob`s can be used to pass arbitrary binary data to Shader variables.",
+              notes = "The shader does not need to be active to update its uniforms.\n\nThe following type combinations are supported:\n\n<table>\n  <thead>\n    <tr>\n      <td>Uniform type</td>\n      <td>LÖVR type</td>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td><code>float</code></td>\n      <td><code>number</code></td>\n    </tr>\n    <tr>\n      <td><code>int</code></td>\n      <td><code>number</code></td>\n    </tr>\n    <tr>\n      <td><code>vec2</code></td>\n      <td><code>{ x, y }</code></td>\n    </tr>\n    <tr>\n      <td><code>vec3</code></td>\n      <td><code>{ x, y, z }</code> or <code>vec3</code></td>\n    </tr>\n    <tr>\n      <td><code>vec4</code></td>\n      <td><code>{ x, y, z, w }</code></td>\n    </tr>\n    <tr>\n      <td><code>ivec2</code></td>\n      <td><code>{ x, y }</code></td>\n    </tr>\n    <tr>\n      <td><code>mat2</code></td>\n      <td>{ x, y, ... }</td>\n    </tr>\n    <tr>\n      <td><code>mat3</code></td>\n      <td><code>{ x, y, z, ... }</code></td>\n    </tr>\n    <tr>\n      <td><code>mat4</code></td>\n      <td><code>{ x, y, z, w, ... }</code> or <code>mat4</code></td>\n    </tr>\n    <tr>\n      <td><code>sampler</code></td>\n      <td><code>Texture</code></td>\n    </tr>\n    <tr>\n      <td><code>image</code></td>\n      <td><code>Texture</code></td>\n    </tr>\n  </tbody> </table>\n\nUniform arrays can be wrapped in tables or passed as multiple arguments.\n\nTextures must match the type of sampler or image they are being sent to.\n\nThe following sampler (and image) types are currently supported:\n\n- `sampler2D`\n- `sampler3D`\n- `samplerCube`\n- `sampler2DArray`\n\nAn error is thrown if the uniform does not exist or is not used in the shader.  The `Shader:hasUniform` function can be used to check if a uniform variable exists.\n\n`Blob`s can be used to pass arbitrary binary data to Shader variables.",
               variants = {
                 {
                   arguments = {

+ 33 - 20
api/lovr/graphics/Shader/send.lua

@@ -28,50 +28,63 @@ return {
       </thead>
       <tbody>
         <tr>
-          <td>float</td>
-          <td>number</td>
+          <td><code>float</code></td>
+          <td><code>number</code></td>
         </tr>
         <tr>
-          <td>int</td>
-          <td>number</td>
+          <td><code>int</code></td>
+          <td><code>number</code></td>
         </tr>
         <tr>
-          <td>vec2</td>
-          <td>{ x, y }</td>
+          <td><code>vec2</code></td>
+          <td><code>{ x, y }</code></td>
         </tr>
         <tr>
-          <td>vec3</td>
-          <td>{ x, y, z } or vec3</td>
+          <td><code>vec3</code></td>
+          <td><code>{ x, y, z }</code> or <code>vec3</code></td>
         </tr>
         <tr>
-          <td>vec4</td>
-          <td>{ x, y, z, w }</td>
+          <td><code>vec4</code></td>
+          <td><code>{ x, y, z, w }</code></td>
         </tr>
         <tr>
-          <td>ivec2, ivec3, ivec4</td>
-          <td>{ ...numbers }</td>
+          <td><code>ivec2</code></td>
+          <td><code>{ x, y }</code></td>
         </tr>
         <tr>
-          <td>mat2, mat3</td>
-          <td>{ ...numbers }</td>
+          <td><code>mat2</code></td>
+          <td>{ x, y, ... }</td>
         </tr>
         <tr>
-          <td>mat4</td>
-          <td>{ x, y, z, w, ... } or mat4</td>
+          <td><code>mat3</code></td>
+          <td><code>{ x, y, z, ... }</code></td>
         </tr>
         <tr>
-          <td>sampler2D, sampler3D, samplerCube, sampler2DArray</td>
-          <td>Texture</td>
+          <td><code>mat4</code></td>
+          <td><code>{ x, y, z, w, ... }</code> or <code>mat4</code></td>
         </tr>
         <tr>
-          <td>image2D, image3D, imageCube, image2DArray</td>
-          <td>Texture</td>
+          <td><code>sampler</code></td>
+          <td><code>Texture</code></td>
+        </tr>
+        <tr>
+          <td><code>image</code></td>
+          <td><code>Texture</code></td>
         </tr>
       </tbody>
     </table>
 
     Uniform arrays can be wrapped in tables or passed as multiple arguments.
 
+    Textures must match the type of sampler or image they are being sent to.
+
+    The following sampler (and image) types are currently supported:
+
+    - `sampler2D`
+    - `sampler3D`
+    - `samplerCube`
+    - `sampler2DArray`
+
     An error is thrown if the uniform does not exist or is not used in the shader.  The
     `Shader:hasUniform` function can be used to check if a uniform variable exists.