ektogamat / fake-glow-material-threejs

A simple to use fake glow material for vanilla threejs
https://fake-glow-material-threejs.vercel.app/
MIT License
65 stars 4 forks source link

Usage with InstancedMesh #2

Open fluxxus opened 3 weeks ago

fluxxus commented 3 weeks ago

Hey,

please correct me if I am wrong, but it seems that your material is not working with InstancedMesh. Basically the positioning doesn't have any effect.

I've found this reddit thread , while not directly tied to your material the suggestion is to use this gl_Position = projectionMatrix * viewMatrix * modelMatrix * instanceMatrix * vec4(position, 1.0).

Which I did and swapped the gl_Position line in your shader code with the above and it worked.

Is this the right approach if using InstancedMesh?

ektogamat commented 3 weeks ago

Hey. Thank you very much for your feedback. This is awesome. If you can, just send me a PR and I can merge it okay? I tested with animated meshes but not with instanced meshes so your approach is probably right!

Thanks again and sorry for the delay 😊

fluxxus commented 3 weeks ago

No problem, glad that I could help. I'll submit PR tomorrow if it is ok with you, I am away from the computer right now.

P.S. How would you check if InstancedMesh is used? I haven't tried, but I guess that the above line won't work for regular meshes. This is just my guess, I am far from expert.