Crafty.defaultShader()

public Crafty.WebGLShader Crafty.defaultShader(String component[, Crafty.WebGLShader shader])
component

Name of the component to assign a default shader to

shader

New default shader to assign to a component

Assigns or fetches a default shader for a component.

This allows the default shader for a component to be overridden, and therefor allows developers to override the default shader behaviour with more complex shaders.

Example

Let's say we want to set the grayscale enabled shader from the example of the WebGLShader as default for sprites:

Crafty.defaultShader("Sprite", recoloredSprite);