I wrote a test shader, it worked for the entire scene. But when I apply it to the material, an error appears - “Cannot read property ‘split’ of undefined”
here is the code, what am I doing wrong?
void main(void)
{
vec3 color = vec3(0.11, 0.34, 0.21);
gl_FragColor = vec4(color,1.0);
}
Ball.prototype.initialize = function() {
this.material = new pc.Material();
var fragmentShader = "precision " + this.app.graphicsDevice.precision + " float;\n";
fragmentShader = fragmentShader + this.shader.resource.resource;
var shaderDefinition = {
attributes: {
aUv0: pc.SEMANTIC_TEXCOORD0
},
fshader: fragmentShader
};
this.sh = new pc.Shader(this.app.graphicsDevice, shaderDefinition)
this.material.shader = this.sh
this.entity.model.model.meshInstances[0].material = this.material
};