Instances with ShaderMaterial

Hey, I have a problem drawing instances with ShaderMaterial. They don’t seem to be drawn.
I searched it and others had the same problem years ago.

Is this fixed in latest version of Babylon? What is the standard way to use ShaderMaterial on instances?

1 Like

Hi @vuoriov4

I used this PG this morning for some test :
Maybe that’s what you were looking for :slight_smile:


Thanks I got it working with this example. Finally my game has some explosions :smiley:

Another problem: How to access the instance index inside the shader?
I’ll post here if I figure it out…

use gl_InstanceID. it returns an int that you can cast to a float.

Thank you it worked. For anyone having the same problem here’s the solution written out.

Vertex shader

flat varying int iid;
void main(void) {
    iid = gl_InstanceID;


flat varying int iid;  
void main(void) {
    float(iid); // instance index as float