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...")
 
(Redirected page to Global Command: shaderCompile)
 
Line 1: Line 1:
==shaderCompile==
+
#REDIRECT [[Global Command: 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>
 
 
 
Lua Syntax:
 
<pre class="command-syntax">shaderCompile(vsh, fsh)</pre>
 
===Arguments===
 
====vsh====
 
:'''"string"''' - vertex shader
 
====fsh====
 
:'''"string"''' - fragment shader
 
===Flags===
 
===Return Values===
 
None.
 
===Examples===
 
Example 1: minimal shader
 
<syntaxhighlight>
 
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)
 
 
 
</syntaxhighlight>
 

Latest revision as of 13:33, 19 May 2023