Effect base class. An effect = vertex shader + fragment shader + uniforms & attributes + setup code.
Build a shader.
String
Effect base class. An effect = vertex shader + fragment shader + uniforms & attributes + setup code.
Kind: global class
\*
\*
String
String
Boolean
| \*
Boolean
Boolean
Create the effect.
\*
Get a dictionary with all shaders uniforms. Key = uniform name, as appears in shader code. Value = { type: UniformTypes to represent uniform type, bind: Optional bind to one of the built-in uniforms. See Effect.UniformBinds for details. }
Kind: instance property of Effect
Returns: \*
- Dictionary with uniforms descriptions.
\*
Get a dictionary with all shader attributes. Key = attribute name, as appears in shader code. Value = { size: size of every value in this attribute. type: attribute type. See Effect.AttributeTypes for details. normalize: if true, will normalize values. stride: optional stride. offset: optional offset. bind: Optional bind to one of the built-in attributes. See Effect.AttributeBinds for details. }
Kind: instance property of Effect
Returns: \*
- Dictionary with attributes descriptions.
String
Get this effect’s vertex shader code, as string.
Kind: instance property of Effect
Returns: String
- Vertex shader code.
String
Get this effect’s fragment shader code, as string.
Kind: instance property of Effect
Returns: String
- Fragment shader code.
Should this effect enable depth test?
Kind: instance property of Effect
Should this effect enable face culling?
Kind: instance property of Effect
Get depth func to use when rendering using this effect. Use ‘DepthFuncs’ to get options.
Kind: instance property of Effect
Should this effect enable stencil test?
Kind: instance property of Effect
Should this effect enable dithering?
Kind: instance property of Effect
Boolean
| \*
Get polygon offset factor, to apply on depth value before checking.
Kind: instance property of Effect
Returns: Boolean
| \*
- Return false to disable polygon offset, or {factor, unit} to apply polygon offset.
Boolean
Return if this effect have colors attribute on vertices.
Kind: instance property of Effect
Returns: Boolean
- True if got vertices color attribute.
Make this effect active.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
overrideFlags | \* |
Optional flags to override in effect. May include the following: enableDepthTest, enableFaceCulling, enableStencilTest, enableDithering. |
Get a uniform method from a bind key.
Kind: instance method of Effect
Returns: Uniform set method, or null if not set.
Param | Type | Description |
---|---|---|
bindKey | UniformBinds |
Uniform bind key. |
Boolean
Set the main texture. Note: this will only work for effects that utilize the ‘MainTexture’ uniform.
Kind: instance method of Effect
Returns: Boolean
- True if texture was changed, false if there was no need to change the texture.
Param | Type | Description |
---|---|---|
texture | TextureAssetBase |
Texture to set. |
Set the main tint color. Note: this will only work for effects that utilize the ‘Color’ uniform.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
color | Color |
Color to set. |
Set the projection matrix uniform. Note: this will only work for effects that utilize the ‘Projection’ uniform.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
matrix | Matrix |
Matrix to set. |
Set the world matrix uniform. Note: this will only work for effects that utilize the ‘World’ uniform.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
matrix | Matrix |
Matrix to set. |
Set the view matrix uniform. Note: this will only work for effects that utilize the ‘View’ uniform.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
matrix | Matrix |
Matrix to set. |
Set outline params. Note: this will only work for effects that utilize the ‘OutlineWeight’ and ‘OutlineColor’ uniforms.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
weight | Number |
Outline weight, range from 0.0 to 1.0. |
color | Color |
Outline color. |
Set a factor to normalize UV values to be 0-1. Note: this will only work for effects that utilize the ‘UvNormalizationFactor’ uniform.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
factor | Vector2 |
Normalize UVs factor. |
Set the vertices position buffer. Only works if there’s an attribute type bound to ‘Position’.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
buffer | WebGLBuffer |
Vertices position buffer. |
forceSetBuffer | Boolean |
If true, will always set buffer even if buffer is currently set. |
Set the vertices texture coords buffer. Only works if there’s an attribute type bound to ‘TextureCoords’.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
buffer | WebGLBuffer |
Vertices texture coords buffer. |
forceSetBuffer | Boolean |
If true, will always set buffer even if buffer is currently set. |
Set the vertices colors buffer. Only works if there’s an attribute type bound to ‘Colors’.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
buffer | WebGLBuffer |
Vertices colors buffer. |
forceSetBuffer | Boolean |
If true, will always set buffer even if buffer is currently set. |
Set the vertices normals buffer. Only works if there’s an attribute type bound to ‘Normals’.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
buffer | WebGLBuffer |
Vertices normals buffer. |
forceSetBuffer | Boolean |
If true, will always set buffer even if buffer is currently set. |
Set the vertices binormals buffer. Only works if there’s an attribute type bound to ‘Binormals’.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
buffer | WebGLBuffer |
Vertices binormals buffer. |
forceSetBuffer | Boolean |
If true, will always set buffer even if buffer is currently set. |
Set the vertices tangents buffer. Only works if there’s an attribute type bound to ‘Tangents’.
Kind: instance method of Effect
Param | Type | Description |
---|---|---|
buffer | WebGLBuffer |
Vertices tangents buffer. |
forceSetBuffer | Boolean |
If true, will always set buffer even if buffer is currently set. |
\*
Get all supported depth funcs we can set.
Kind: static property of Effect
Returns: \*
- Depth func options: {Never, Less, Equal, LessEqual, Greater, GreaterEqual, Always, NotEqual}.
Default uniform binds. This is a set of commonly used uniforms and their names inside the shader code.
Every bind here comes with a built-in method to set and is used internally by Shaku. For example, if you want to include outline properties in your effect, you can use the ‘OutlineWeight’ and ‘OutlineColor’ binds (with matching name in the shader code). When you use the built-in binds, Shaku will know how to set them itself when relevant, for example in text rendering Shaku will use the outline binds if they exist.
If you don’t use the built-in binds you can just call your uniforms however you like, but you’ll need to set them all manually. Shaku will not know how to set them.
Kind: static property of Effect
Define attribute types.
Kind: static property of Effect
Define built-in attribute binds to connect attribute names for specific use cases like position, uvs, colors, etc. If an effect support one or more of these attributes, Shaku will know how to fill them automatically.
Kind: static property of Effect
enum
Uniform types enum.
Kind: global enum
Read only: true
Properties
Name | Type | Default |
---|---|---|
Texture | UniformType |
texture |
Matrix | UniformType |
uniformMatrix4fv |
Color | UniformType |
uniform4fv |
Float | UniformType |
uniform1f |
FloatArray | UniformType |
uniform1fv |
Int | UniformType |
uniform1i |
IntArray | UniformType |
uniform1iv |
Float2 | UniformType |
uniform2f |
Float2Array | UniformType |
uniform2fv |
Int2 | UniformType |
uniform2i |
Int2Array | UniformType |
uniform2iv |
Float3 | UniformType |
uniform3f |
Float3Array | UniformType |
uniform3fv |
Int3 | UniformType |
uniform3i |
Int3Array | UniformType |
uniform3iv |
Float4 | UniformType |
uniform4f |
Float4Array | UniformType |
uniform4fv |
Int4 | UniformType |
uniform4i |
Int4Array | UniformType |
uniform4iv |
Build a shader.
String
Kind: global typedef