CC3ShaderProgram program = new CC3ShaderProgramMatchers().SingleTextureProgram();
Once we have the shader, we would like to configure its parameters. However, in this instance a user shouldn't have to be burdened with understanding the innards of a shader they didn't write themselves. Thankfully, cocos3d does the heavy lifting of associating all bundled shaders' attributes/uniforms to corresponding instance variables belonging to a host of different objects. As an example, within our bundled shaders we have the (sample of ) material uniforms
uniform float4 u_cc3MaterialAmbientColor; uniform float4 u_cc3MaterialDiffuseColor; uniform float4 u_cc3MaterialSpecularColor; uniform float4 u_cc3MaterialEmissionColor;
which are bound to the ivars
material.AmbientColor; material.DiffuseColor; material.SpecularColor; material.EmissionColor;
of the currently set CC3Material object within the graphics context. Other classes of interest include: CC3Light, CC3MeshNode, CC3PointParticleEmitter (along with others), which are similarly tied to a number of different shader parameters. So now to use these pre-bundled shaders, a user simply has to worry about setting a collection of ivars and cocos3d will make sure the correct shader parameters are updated.
Next week, I'll be putting all this theory into practice with the port Cocos3D-XNA by showing the basics of creating and using a material object!
No comments:
Post a Comment