Browse Source

Update Shader:send table;

bjorn 5 years ago
parent
commit
7d689560de
2 changed files with 38 additions and 8 deletions
  1. 1 1
      api/init.lua
  2. 37 7
      api/lovr/graphics/Shader/send.lua

+ 1 - 1
api/init.lua

@@ -11931,7 +11931,7 @@ return {
                 "ShaderBlock:sendBlock",
                 "ShaderBlock:sendBlock",
                 "Shader: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`, `int`</td>\n      <td>`number`</td>\n    </tr>\n    <tr>\n      <td>TODO</td>\n      <td>SORRY</td>\n    </tr>\n  </tbody> </table>\n\nUniform variables declared as `float`s must be sent a single number, whereas uniforms declared as `vec4`s must be sent a table containing 4 numbers, etc.  Note that uniforms declared as mat4s can be sent a `mat4` object.\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>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.",
               variants = {
               variants = {
                 {
                 {
                   arguments = {
                   arguments = {

+ 37 - 7
api/lovr/graphics/Shader/send.lua

@@ -28,19 +28,49 @@ return {
       </thead>
       </thead>
       <tbody>
       <tbody>
         <tr>
         <tr>
-          <td>`float`, `int`</td>
-          <td>`number`</td>
+          <td>float</td>
+          <td>number</td>
         </tr>
         </tr>
         <tr>
         <tr>
-          <td>TODO</td>
-          <td>SORRY</td>
+          <td>int</td>
+          <td>number</td>
+        </tr>
+        <tr>
+          <td>vec2</td>
+          <td>{ x, y }</td>
+        </tr>
+        <tr>
+          <td>vec3</td>
+          <td>{ x, y, z } or vec3</td>
+        </tr>
+        <tr>
+          <td>vec4</td>
+          <td>{ x, y, z, w }</td>
+        </tr>
+        <tr>
+          <td>ivec2, ivec3, ivec4</td>
+          <td>{ ...numbers }</td>
+        </tr>
+        <tr>
+          <td>mat2, mat3</td>
+          <td>{ ...numbers }</td>
+        </tr>
+        <tr>
+          <td>mat4</td>
+          <td>{ x, y, z, w, ... } or mat4</td>
+        </tr>
+        <tr>
+          <td>sampler2D, sampler3D, samplerCube, sampler2DArray</td>
+          <td>Texture</td>
+        </tr>
+        <tr>
+          <td>image2D, image3D, imageCube, image2DArray</td>
+          <td>Texture</td>
         </tr>
         </tr>
       </tbody>
       </tbody>
     </table>
     </table>
 
 
-    Uniform variables declared as `float`s must be sent a single number, whereas uniforms declared
-    as `vec4`s must be sent a table containing 4 numbers, etc.  Note that uniforms declared as mat4s
-    can be sent a `mat4` object.
+    Uniform arrays can be wrapped in tables or passed as multiple arguments.
 
 
     An error is thrown if the uniform does not exist or is not used in the shader.  The
     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.
     `Shader:hasUniform` function can be used to check if a uniform variable exists.