Difference between revisions of "Shader"
Line 37: | Line 37: | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== <translate>Methods</translate> === | === <translate>Methods</translate> === | ||
− | [[Special:MyLanguage/Shader.new|Shader.new]] ''<translate>create new shader</translate>''<br/><!-- GIDEROSMTD:Shader.new --> | + | [[Special:MyLanguage/Shader.new|Shader.new]] ''<translate>create new shader</translate>''<br/><!-- GIDEROSMTD:Shader.new(vertex shader,fragment shader,flags,uniform descriptor,attribute descriptor) create new shader --> |
− | [[Special:MyLanguage/Shader:getEngineVersion|Shader:getEngineVersion]] ''<translate>get shader version</translate>''<br/><!-- GIDEROSMTD:Shader:getEngineVersion --> | + | [[Special:MyLanguage/Shader:getEngineVersion|Shader:getEngineVersion]] ''<translate>get shader version</translate>''<br/><!-- GIDEROSMTD:Shader:getEngineVersion() get shader version --> |
− | [[Special:MyLanguage/Shader:getProperties|Shader:getProperties]] ''<translate>get graphics engine properties</translate>''<br/><!-- GIDEROSMTD:Shader:getProperties --> | + | [[Special:MyLanguage/Shader:getProperties|Shader:getProperties]] ''<translate>get graphics engine properties</translate>''<br/><!-- GIDEROSMTD:Shader:getProperties() get graphics engine properties --> |
− | [[Special:MyLanguage/Shader:getShaderLanguage|Shader:getShaderLanguage]] ''<translate>Get shader language</translate>''<br/><!-- GIDEROSMTD:Shader:getShaderLanguage --> | + | [[Special:MyLanguage/Shader:getShaderLanguage|Shader:getShaderLanguage]] ''<translate>Get shader language</translate>''<br/><!-- GIDEROSMTD:Shader:getShaderLanguage() Get shader language --> |
− | [[Special:MyLanguage/Shader:setConstant|Shader:setConstant]] ''<translate>change the value of a uniform</translate>''<br/><!-- GIDEROSMTD:Shader:setConstant --> | + | [[Special:MyLanguage/Shader:setConstant|Shader:setConstant]] ''<translate>change the value of a uniform</translate>''<br/><!-- GIDEROSMTD:Shader:setConstant(uniform name,data type,mult,data) change the value of a uniform --> |
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== <translate>Events</translate> === | === <translate>Events</translate> === | ||
=== <translate>Constants</translate> === | === <translate>Constants</translate> === | ||
− | [[Special:MyLanguage/Shader.CFLOAT|Shader.CFLOAT]]<br/><!-- GIDEROSCST:Shader.CFLOAT --> | + | [[Special:MyLanguage/Shader.CFLOAT|Shader.CFLOAT]]<br/><!-- GIDEROSCST:Shader.CFLOAT 1--> |
− | [[Special:MyLanguage/Shader.CFLOAT4|Shader.CFLOAT4]]<br/><!-- GIDEROSCST:Shader.CFLOAT4 --> | + | [[Special:MyLanguage/Shader.CFLOAT4|Shader.CFLOAT4]]<br/><!-- GIDEROSCST:Shader.CFLOAT4 2--> |
− | [[Special:MyLanguage/Shader.CINT|Shader.CINT]]<br/><!-- GIDEROSCST:Shader.CINT --> | + | [[Special:MyLanguage/Shader.CINT|Shader.CINT]]<br/><!-- GIDEROSCST:Shader.CINT 0--> |
− | [[Special:MyLanguage/Shader.CMATRIX|Shader.CMATRIX]]<br/><!-- GIDEROSCST:Shader.CMATRIX --> | + | [[Special:MyLanguage/Shader.CMATRIX|Shader.CMATRIX]]<br/><!-- GIDEROSCST:Shader.CMATRIX 3--> |
− | [[Special:MyLanguage/Shader.CTEXTURE|Shader.CTEXTURE]]<br/><!-- GIDEROSCST:Shader.CTEXTURE --> | + | [[Special:MyLanguage/Shader.CTEXTURE|Shader.CTEXTURE]]<br/><!-- GIDEROSCST:Shader.CTEXTURE 4--> |
− | [[Special:MyLanguage/Shader.DBYTE|Shader.DBYTE]]<br/><!-- GIDEROSCST:Shader.DBYTE --> | + | [[Special:MyLanguage/Shader.DBYTE|Shader.DBYTE]]<br/><!-- GIDEROSCST:Shader.DBYTE 0--> |
− | [[Special:MyLanguage/Shader.DFLOAT|Shader.DFLOAT]]<br/><!-- GIDEROSCST:Shader.DFLOAT --> | + | [[Special:MyLanguage/Shader.DFLOAT|Shader.DFLOAT]]<br/><!-- GIDEROSCST:Shader.DFLOAT 5--> |
− | [[Special:MyLanguage/Shader.DINT|Shader.DINT]]<br/><!-- GIDEROSCST:Shader.DINT --> | + | [[Special:MyLanguage/Shader.DINT|Shader.DINT]]<br/><!-- GIDEROSCST:Shader.DINT 4--> |
− | [[Special:MyLanguage/Shader.DSHORT|Shader.DSHORT]]<br/><!-- GIDEROSCST:Shader.DSHORT --> | + | [[Special:MyLanguage/Shader.DSHORT|Shader.DSHORT]]<br/><!-- GIDEROSCST:Shader.DSHORT 2--> |
− | [[Special:MyLanguage/Shader.DUBYTE|Shader.DUBYTE]]<br/><!-- GIDEROSCST:Shader.DUBYTE --> | + | [[Special:MyLanguage/Shader.DUBYTE|Shader.DUBYTE]]<br/><!-- GIDEROSCST:Shader.DUBYTE 1--> |
− | [[Special:MyLanguage/Shader.DUSHORT|Shader.DUSHORT]]<br/><!-- GIDEROSCST:Shader.DUSHORT --> | + | [[Special:MyLanguage/Shader.DUSHORT|Shader.DUSHORT]]<br/><!-- GIDEROSCST:Shader.DUSHORT 3--> |
− | [[Special:MyLanguage/Shader.FLAG_FROM_CODE|Shader.FLAG_FROM_CODE]]<br/><!-- GIDEROSCST:Shader.FLAG_FROM_CODE --> | + | [[Special:MyLanguage/Shader.FLAG_FROM_CODE|Shader.FLAG_FROM_CODE]]<br/><!-- GIDEROSCST:Shader.FLAG_FROM_CODE 4--> |
− | [[Special:MyLanguage/Shader.FLAG_NONE|Shader.FLAG_NONE]]<br/><!-- GIDEROSCST:Shader.FLAG_NONE --> | + | [[Special:MyLanguage/Shader.FLAG_NONE|Shader.FLAG_NONE]]<br/><!-- GIDEROSCST:Shader.FLAG_NONE 0--> |
− | [[Special:MyLanguage/Shader.FLAG_NO_DEFAULT_HEADER|Shader.FLAG_NO_DEFAULT_HEADER]]<br/><!-- GIDEROSCST:Shader.FLAG_NO_DEFAULT_HEADER --> | + | [[Special:MyLanguage/Shader.FLAG_NO_DEFAULT_HEADER|Shader.FLAG_NO_DEFAULT_HEADER]]<br/><!-- GIDEROSCST:Shader.FLAG_NO_DEFAULT_HEADER 1--> |
− | [[Special:MyLanguage/Shader.SYS_COLOR|Shader.SYS_COLOR]]<br/><!-- GIDEROSCST:Shader.SYS_COLOR --> | + | [[Special:MyLanguage/Shader.SYS_COLOR|Shader.SYS_COLOR]]<br/><!-- GIDEROSCST:Shader.SYS_COLOR 2--> |
− | [[Special:MyLanguage/Shader.SYS_NONE|Shader.SYS_NONE]]<br/><!-- GIDEROSCST:Shader.SYS_NONE --> | + | [[Special:MyLanguage/Shader.SYS_NONE|Shader.SYS_NONE]]<br/><!-- GIDEROSCST:Shader.SYS_NONE 0--> |
− | [[Special:MyLanguage/Shader.SYS_PARTICLESIZE|Shader.SYS_PARTICLESIZE]]<br/><!-- GIDEROSCST:Shader.SYS_PARTICLESIZE --> | + | [[Special:MyLanguage/Shader.SYS_PARTICLESIZE|Shader.SYS_PARTICLESIZE]]<br/><!-- GIDEROSCST:Shader.SYS_PARTICLESIZE 6--> |
− | [[Special:MyLanguage/Shader.SYS_TEXTUREINFO|Shader.SYS_TEXTUREINFO]]<br/><!-- GIDEROSCST:Shader.SYS_TEXTUREINFO --> | + | [[Special:MyLanguage/Shader.SYS_TEXTUREINFO|Shader.SYS_TEXTUREINFO]]<br/><!-- GIDEROSCST:Shader.SYS_TEXTUREINFO 5--> |
− | [[Special:MyLanguage/Shader.SYS_WIT|Shader.SYS_WIT]]<br/><!-- GIDEROSCST:Shader.SYS_WIT --> | + | [[Special:MyLanguage/Shader.SYS_WIT|Shader.SYS_WIT]]<br/><!-- GIDEROSCST:Shader.SYS_WIT 3--> |
− | [[Special:MyLanguage/Shader.SYS_WORLD|Shader.SYS_WORLD]]<br/><!-- GIDEROSCST:Shader.SYS_WORLD --> | + | [[Special:MyLanguage/Shader.SYS_WORLD|Shader.SYS_WORLD]]<br/><!-- GIDEROSCST:Shader.SYS_WORLD 4--> |
− | [[Special:MyLanguage/Shader.SYS_WVP|Shader.SYS_WVP]]<br/><!-- GIDEROSCST:Shader.SYS_WVP --> | + | [[Special:MyLanguage/Shader.SYS_WVP|Shader.SYS_WVP]]<br/><!-- GIDEROSCST:Shader.SYS_WVP 1--> |
|} | |} |
Revision as of 15:33, 13 September 2018
Supported platforms:
Available since: Gideros 2015.06.30
Inherits from: Object
Description
Gideros internally uses five distinct shaders: - the ‘Basic’ shader handle shapes with a constant color - the ‘Color’ shader handle shapes with per-vertex colors (mostly used by Mesh sprite) - the ‘Texture’ shader handle textured shapes (Bitmaps) - the ‘TextureColor’ shader handle textured and per-vertex colored shapes - and the ‘Particle’ shader deals with Box2D particle systems
The new shader API allows to replace the default shader used by Gideros with a custom one, on a sprite per sprite basis. As with most of Gideros API’s this one is straight-forward: create a Shader object and assign it to one or several sprites.
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 the standard one, which essentially means that it takes the same input parameters.
Examples
Shader example
--Shaders are in vShader.glsl and fShader.glsl files
local shader=Shader.new("vShader","fShader",0, {
{name="vMatrix",type=Shader.CMATRIX,sys=Shader.SYS_WVP,vertex=true},
{name="fColor",type=Shader.CFLOAT4,sys=Shader.SYS_COLOR,vertex=false},
{name="fTexture",type=Shader.CTEXTURE,vertex=false},
{name="fTexelSize",type=Shader.CFLOAT4,vertex=false},
{name="fRad",type=Shader.CINT,vertex=false}, },
{ {name="vVertex",type=Shader.DFLOAT,mult=3,slot=0,offset=0},
{name="vColor",type=Shader.DUBYTE,mult=4,slot=1,offset=0},
{name="vTexCoord",type=Shader.DFLOAT,mult=2,slot=2,offset=0}, });
shader:setConstant("fRad",Shader.CINT,1,0) --Initial blur level
shader:setConstant("fTexelSize",Shader.CFLOAT4,1,{1/texw,1/texh,0,0}) --Initial texel size
sprite:setShader(shader)
MethodsShader.new create new shader |
EventsConstantsShader.CFLOAT |