Difference between revisions of "ShaderCompile"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Created page with "==shaderCompile== <div class="command-min-version-info">Available since: <span class="command-min-version">v4.0</span></div> <div class="command-doc">Compile shader</div> L...")
(No difference)

Revision as of 22:28, 30 September 2014

shaderCompile

Available since: v4.0
Compile shader

Lua Syntax:

shaderCompile(vsh, fsh)

Arguments

vsh

"string" - vertex shader

fsh

"string" - fragment shader

Flags

Return Values

None.

Examples

Example 1: minimal shader

shader = {_temporary_=0, num = shaderCompile([[#ifdef GL_ES 
precision lowp float; 
precision lowp int; 
#endif 
varying vec2 texcoord; 
uniform mat4 mvp_mat; 
attribute vec2 position; 
attribute vec2 uv; 
uniform int pass; 
void main () 
{ 
  gl_Position = mvp_mat * vec4(position.x,position.y,0.0,1.0); 
  texcoord = uv; 
}]],[[#ifdef GL_ES 
precision highp float; 
precision lowp  int; 
#endif 

uniform sampler2D composite;
uniform int pass;
varying vec2 texcoord;
  
void main() {
  gl_FragColor = texture2D(composite, texcoord.st);
}
]])}
shaderSetOptions("active",shader.num)