Lua GLSL Api: Difference between revisions

From Spring
Jump to navigationJump to search
mNo edit summary
mNo edit summary
Line 18: Line 18:
   }) -> number shaderID
   }) -> number shaderID


* The "Vertex" or vertex-shadder is your GLSL-Code as string, its written in a C-Dialect. This shadder is busy deforming the geometry of a unit but it can not create new polygons. Use it for waves, wobbling surfaces etc.
* The "Vertex" or vertex-shader is your GLSL-Code as string, its written in a C-Dialect. This shader is busy deforming the geometry of a unit but it can not create new polygons. Use it for waves, wobbling surfaces etc.
   
   
* The "Geometry" or Geometry-shadder can create new vertices and verticestripes from points.  
* The "Geometry" or Geometry-shader can create new vertices and vertice-stripes from points.  


* The "Fragment" or Fragment-shadder (sometimes called pixel-Shadder) is post processing the allready rendered picture (for example drawing stars on the sky)- remember textures are not always 2 dimensional pictures. They can contain information about the depth, or the third value marks areas and the strenght at which these are processed.
* The "Fragment" or Fragment-shader (sometimes called pixel-Shader) is post processing the allready rendered picture (for example drawing stars on the sky)- remember textures are not always 2 dimensional pictures. They can contain information about the depth, or the third value marks areas and the strength at which these are processed.


* The Uniforms are the values, you send along with the shadder-program. To use them in the Shadder-Program declare them like this:  
* The Uniforms are the values, you send along with the shader-program. To use them in the shader-program declare them like this:  
<font color="#55ee99">''uniform float frame;''</font>
<font color="#55ee99">''uniform float frame;''</font>



Revision as of 13:51, 15 February 2014

Development < Lua Scripting < Lua GLSL Api

These functions are ONLY available if the graphic board supports GLSL.

Please test in your scripts if one of them exists before you use them!


gl.CreateShader

 ({ [ vertex   = "glsl code" ,]
   [ geometry = "glsl code" ,]
   [ fragment = "glsl code" ,]
   [ uniform       = { uniformName = number value, ...} ,]
   [ uniformInt    = { uniformName = number value, ...} ,]
   [ uniformArray  = { uniformName = number value, ...} ,] table with > 4 and <= 32 elements
   [ uniformMatrix = { uniformName = number value, ...} ,]
   [ geoInputType = number inType,]
   [ geoOutputType = number outType,]
   [ geoOutputVerts = number maxVerts,]
   [ definitions = "string of shader #defines", ]
 }) -> number shaderID
  • The "Vertex" or vertex-shader is your GLSL-Code as string, its written in a C-Dialect. This shader is busy deforming the geometry of a unit but it can not create new polygons. Use it for waves, wobbling surfaces etc.
  • The "Geometry" or Geometry-shader can create new vertices and vertice-stripes from points.
  • The "Fragment" or Fragment-shader (sometimes called pixel-Shader) is post processing the allready rendered picture (for example drawing stars on the sky)- remember textures are not always 2 dimensional pictures. They can contain information about the depth, or the third value marks areas and the strength at which these are processed.
  • The Uniforms are the values, you send along with the shader-program. To use them in the shader-program declare them like this:

uniform float frame;


gl.DeleteShader

 ( number shaderID ) -> nil

gl.ActiveShader can be used in none drawing events (to update uniforms etc.)!

 ( number shaderID, function [, arg1 [, arg2, ..]] ) -> nil

gl.UseShader

 ( number shaderID ) -> boolean linked

gl.GetShaderLog

 ( ) -> string "errorLog"

gl.SetShaderParameter needed by geometry shader programs (check the opengl shader4 extension for glProgramParameteri)

 ( number shaderID, number param, number value ) -> nil

gl.GetActiveUniforms

 ( number shaderID ) -> { 
     [1] = { name = "name", type = "type", length = number length, size = number size },
     ...
   }

gl.GetUniformLocation

 ( number shaderID, name uniformName ) -> number locationID

gl.Uniform

 ( number locationID, number f1 [,number f2 [,number f3 [,number f4]]] ) -> nil

gl.UniformInt

 ( number locationID, number int1 [,number int2 [,number int3 [,number int4]]] ) -> nil

gl.UniformArray New in version 95.0

 ( number locationID, number type, table uniforms ) -> nil

type can be one of {0 = int, 1 = float}

gl.UniformMatrix

 ( number locationID, 
   "shadow" |
   "camera" |
   "caminv" |
   "camprj" |
   number m1, number m2, number m3, number m4 |
   number m1, ... , number m9 |
   number m1, ... , number m16
 ) -> nil