Difference between revisions of "Shader"
(5 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
*and the ‘'''Particle'''’ shader deals with Box2D particle systems | *and the ‘'''Particle'''’ shader deals with Box2D particle systems | ||
− | The shader API allows replacing the default shader used by Gideros with a custom one, on a sprite per sprite basis. You create a Shader object and assign it to one or several sprites. '''[[Writing Shaders]]''' | + | The shader API allows replacing the default shader used by Gideros with a custom one, on a sprite per sprite basis. You create a Shader object and assign it to one or several sprites. See [[Writing Custom Shaders]]. |
+ | |||
+ | '''The recommended way is to write your shader code in Lua, it will then be automatically translated to the relevant shader language for the platform you are using, eg GLSL, HLSL or MSL. Please see [[Shader.lua]] and [[Writing Lua Shaders]].''' | ||
That said, since Gideros will use your shader as if it was the standard one, you will have to make sure that your custom shader is compatible with Gideros standard Shader, which essentially means that it takes the same input parameters. | That said, since Gideros will use your shader as if it was the standard one, you will have to make sure that your custom shader is compatible with Gideros standard Shader, which essentially means that it takes the same input parameters. | ||
− | |||
− | |||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
+ | |||
=== Methods === | === Methods === | ||
− | |||
[[Shader.getEngineVersion]] ''gets the shader engine version''<br/><!--GIDEROSMTD:Shader.getEngineVersion() gets the shader engine version--> | [[Shader.getEngineVersion]] ''gets the shader engine version''<br/><!--GIDEROSMTD:Shader.getEngineVersion() gets the shader engine version--> | ||
[[Shader.getProperties]] ''gets the graphics engine properties''<br/><!--GIDEROSMTD:Shader.getProperties() gets the graphics engine properties--> | [[Shader.getProperties]] ''gets the graphics engine properties''<br/><!--GIDEROSMTD:Shader.getProperties() gets the graphics engine properties--> | ||
[[Shader.getShaderLanguage]] ''gets the shader language''<br/><!--GIDEROSMTD:Shader.getShaderLanguage() gets the shader language--> | [[Shader.getShaderLanguage]] ''gets the shader language''<br/><!--GIDEROSMTD:Shader.getShaderLanguage() gets the shader language--> | ||
+ | [[Shader.lua]] ''creates a new Lua shader''<br/><!--GIDEROSMTD:Shader.lua(vshader,fshader,flags,uniform descriptor,attribute descriptor) creates a new Lua shader--> | ||
+ | [[Shader.new]] ''creates a new shader''<br/><!--GIDEROSMTD:Shader.new(vshader,fshader,flags,uniform descriptor,attribute descriptor) creates a new shader--> | ||
− | [[Shader:isValid]] '' | + | [[Shader:isValid]] ''checks if this shader was compiled successfully''<br/><!--GIDEROSMTD:Shader:isValid() checks if this shader was compiled successfully--> |
[[Shader:setConstant]] ''changes the value of a uniform''<br/><!--GIDEROSMTD:Shader:setConstant(uniform name,data type,mult,data) changes the value of a uniform--> | [[Shader:setConstant]] ''changes the value of a uniform''<br/><!--GIDEROSMTD:Shader:setConstant(uniform name,data type,mult,data) changes the value of a uniform--> | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
− | |||
=== Events === | === Events === | ||
=== Constants === | === Constants === | ||
− | '''[[Shader Constants]]''' | + | '''[[Shader Constants]]'''</br> |
+ | '''[[Shader Flags]]'''</br> | ||
+ | '''[[Shader Uniform Descriptors]]'''</br> | ||
+ | '''[[Shader Attribute Descriptors]]'''</br> | ||
<!--GIDEROSCST:Shader.CFLOAT 1 a float value--> | <!--GIDEROSCST:Shader.CFLOAT 1 a float value--> | ||
<!--GIDEROSCST:Shader.CFLOAT2 2 a vector of two floats--> | <!--GIDEROSCST:Shader.CFLOAT2 2 a vector of two floats--> |
Latest revision as of 05:00, 6 November 2023
Supported platforms:
Available since: Gideros 2015.06.30
Inherits from: Object
Description
Gideros internally uses five distinct shaders:
- the ‘Basic’ shader handles shapes with a constant color
- the ‘Color’ shader handles shapes with per-vertex colors (mostly used by Mesh sprite)
- the ‘Texture’ shader handles textured shapes (Bitmaps)
- the ‘TextureColor’ shader handles textured and per-vertex colored shapes
- and the ‘Particle’ shader deals with Box2D particle systems
The shader API allows replacing the default shader used by Gideros with a custom one, on a sprite per sprite basis. You create a Shader object and assign it to one or several sprites. See Writing Custom Shaders.
The recommended way is to write your shader code in Lua, it will then be automatically translated to the relevant shader language for the platform you are using, eg GLSL, HLSL or MSL. Please see Shader.lua and Writing Lua Shaders.
That said, since Gideros will use your shader as if it was the standard one, you will have to make sure that your custom shader is compatible with Gideros standard Shader, which essentially means that it takes the same input parameters.
MethodsShader.getEngineVersion gets the shader engine version Shader:isValid checks if this shader was compiled successfully |
EventsConstantsShader Constants |