Hello guys,
Following is my vertex shader…
precision highp float;
// Attributes
attribute vec3 position;
attribute vec2 uv;
attribute vec4 world0;
attribute vec4 world1;
attribute vec4 world2;
attribute vec4 world3;
// Uniforms
uniform mat4 view;
uniform mat4 viewProjection;
varying vec2 UV;
void main(void)
{
mat4 world = mat4(world0, world1, world2, world3);
mat4 worldViewProjection = viewProjection * world;
gl_Position = worldViewProjection * vec4(position, 1.0);
UV = uv;
}
and fragment shader…
precision highp float;
// Varying
varying vec2 UV;
uniform sampler2D albedo;
void main(void) {
gl_FragColor = texture(albedo,UV);
}
and this is how I create shader material…
this._trackMaterialInstanced = new ShaderMaterial('trackMaterial',this._scene, "./assets/shaders/opaque_instancing", {
attributes: ["position","uv", "world0", "world1", "world2", "world3"],
uniforms: ["viewProjection","albedo"]
});
const albedo = new Texture('assets/textures/Atlas_Opaque_Arctic.png', this._scene);
this._trackMaterialInstanced.setTexture('albedo', albedo);
this._trackMaterialInstanced.backFaceCulling = true;
this._trackMaterialInstanced.forceDepthWrite = true;
I am getting following error in my game after a while…
thinEngine.js:2931 Uncaught TypeError: Cannot read property 'program' of null babylon js
Any idea what I am doing wrong? Thanks.