Constructor
new Shader(graphicsDevice, definition, precache)
Creates a new shader object.
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
graphicsDevice |
pc.GraphicsDevice | The graphics device used to manage this shader. | |||||||||||||||
definition |
Object | The shader definition from which to build the shader.
Properties
|
|||||||||||||||
precache |
Object | Triggers imediate link. |
- Source:
Example
// Create a shader that renders primitives with a solid red color
var shaderDefinition = {
attributes: {
aPosition: pc.SEMANTIC_POSITION
},
vshader: [
"attribute vec3 aPosition;",
"",
"void main(void)",
"{",
" gl_Position = vec4(aPosition, 1.0);",
"}"
].join("\n"),
fshader: [
"precision " + graphicsDevice.precision + " float;",
"",
"void main(void)",
"{",
" gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);",
"}"
].join("\n")
};
shader = new pc.Shader(graphicsDevice, shaderDefinition);
Methods
destroy()
Frees resources associated with this shader.
- Source: