Browse Source

More shader updates;

bjorn 5 years ago
parent
commit
fb309a50e6

File diff suppressed because it is too large
+ 16 - 2
api/init.lua


+ 7 - 7
api/lovr/graphics/Shader/init.lua

@@ -30,13 +30,14 @@ return {
 
     Vertex shader header:
 
-        in vec3 lovrPosition;
-        in vec3 lovrNormal;
+        in vec3 lovrPosition; // The vertex position
+        in vec3 lovrNormal; // The vertex normal vector
         in vec2 lovrTexCoord;
         in vec4 lovrVertexColor;
         in vec3 lovrTangent;
         in uvec4 lovrBones;
         in vec4 lovrBoneWeights;
+        in uint lovrDrawID;
         out vec2 texCoord;
         out vec4 vertexColor;
         out vec4 lovrColor;
@@ -44,12 +45,12 @@ return {
         uniform mat4 lovrView;
         uniform mat4 lovrProjection;
         uniform mat4 lovrTransform; // Model-View matrix
-        uniform mat3 lovrNormalMatrix;
+        uniform mat3 lovrNormalMatrix; // Inverse-transpose of lovrModel
         uniform mat3 lovrMaterialTransform;
         uniform float lovrPointSize;
         uniform mat4 lovrPose[48];
         uniform int lovrViewportCount;
-        uniform int lovrViewportIndex;
+        uniform int lovrViewID;
         const mat4 lovrPoseMatrix; // Bone-weighted pose
         const int lovrInstanceID; // Current instance ID
 
@@ -61,7 +62,6 @@ return {
         out vec4 lovrCanvas[gl_MaxDrawBuffers];
         uniform float lovrMetalness;
         uniform float lovrRoughness;
-        uniform vec4 lovrColor;
         uniform vec4 lovrDiffuseColor;
         uniform vec4 lovrEmissiveColor;
         uniform sampler2D lovrDiffuseTexture;
@@ -72,7 +72,7 @@ return {
         uniform sampler2D lovrNormalTexture;
         uniform samplerCube lovrEnvironmentTexture;
         uniform int lovrViewportCount;
-        uniform int lovrViewportIndex;
+        uniform int lovrViewID;
 
     ### Compute Shaders
 
@@ -126,7 +126,7 @@ return {
       end
 
       function lovr.draw()
-        model:draw(x, y, z, 1)
+        model:draw(x, y, z)
       end
     ]=]
   },

+ 19 - 3
api/lovr/graphics/newComputeShader.lua

@@ -9,6 +9,20 @@ return {
       name = 'source',
       type = 'string',
       description = 'The code or filename of the compute shader.'
+    },
+    {
+      name = '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.'
+        }
+      }
     }
   },
   returns = {
@@ -19,14 +33,16 @@ return {
     }
   },
   notes = [[
-    Compute shaders are not supported on all hardware, use `lovr.graphics.getSupported` to check
-    if they're available on the current system.
+    Compute shaders are not supported on all hardware, use `lovr.graphics.getFeatures` to check if
+    they're available on the current system.
 
     The source code for a compute shader needs to implement the `void compute();` GLSL function.
     This function doesn't return anything, but the compute shader is able to write data out to
     `Texture`s or `ShaderBlock`s.
 
     The GLSL version used for compute shaders is GLSL 430.
+
+    Currently, up to 32 shader flags are supported.
   ]],
   example = [=[
     function lovr.load()
@@ -34,7 +50,7 @@ return {
         layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
 
         void compute() {
-          // compute things!
+          // compute things!?
         }
       ]])
 

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

@@ -72,8 +72,7 @@ return {
       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.
+      of the flag should be a number between 0.0 and 1.0, representing the alpha treshold.
     - `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
@@ -99,15 +98,16 @@ return {
         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.
+        use this flag to turn off ACES and use your own tonemapping.
 
     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.
+
+    Currently, up to 32 shader flags are supported.
   ]],
   related = {
     'lovr.graphics.setShader',
     'lovr.graphics.getShader',
-    'lovr.graphics.newComputeShader',
-    'Shader'
+    'lovr.graphics.newComputeShader'
   }
 }

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