Difference between revisions of "Lua Shaders"

(Restrictions:)
 
Line 44: Line 44:
 
* No Do..While
 
* No Do..While
 
* No Repeat..Until
 
* No Repeat..Until
* No tables. The only allowed form of table lookup is for vector component swizzling.
+
* No tables. The only allowed form of table lookup is for vector component swizzling and access to uniform arrays
* No tail calls
 
* No sub function calls (except for native functions)
 
 
* No strings, userdata, etc. Basically only numbers are supported.
 
* No strings, userdata, etc. Basically only numbers are supported.
 
* Mind your types! Although lua is not a typed language, shaders need types.
 
* Mind your types! Although lua is not a typed language, shaders need types.
 +
* Always check on all platforms: Gideros will translate your lua code to GLSL,HLSL or MSL code, but some platforms are more strict than others about what you can write, or how many arguments a common function is supposed to take.

Latest revision as of 11:07, 12 November 2020

The API allows the creation of Shader objects from within Lua. The 'Shader.lua()' constructor takes five arguments:

With Lua Shaders, it's assumed that the code is within the vertex and fragment parameter functions.

Lua Shader Functions:

(Please note that these functions may or may not be available, the Lua shader is still under development)

Restrictions:

Don't rely on anything external, basically no globals except for attributes, uniforms and varying.

  • No Do..While
  • No Repeat..Until
  • No tables. The only allowed form of table lookup is for vector component swizzling and access to uniform arrays
  • No strings, userdata, etc. Basically only numbers are supported.
  • Mind your types! Although lua is not a typed language, shaders need types.
  • Always check on all platforms: Gideros will translate your lua code to GLSL,HLSL or MSL code, but some platforms are more strict than others about what you can write, or how many arguments a common function is supposed to take.