Issue Setting Color of Thin Instance

How can I set the color of the thin instance while using this custom material to set the tile?

https://www.babylonjs-playground.com/#KWVY94#4

Also, how can I get this working when the texture is used for both diffuse and opacity?

https://www.babylonjs-playground.com/#KWVY94#6

Thanks

For the color part, I got it to green. https://www.babylonjs-playground.com/#KWVY94#7

There is a square character in line 52

I shouldve been more specific. I need to be able to color thin instances using the color attribute of the thin instance.

I think I need a different way of setting the uv offset, but my shaders skills are a bit lacking.

You can simply multiply baseColor by vColor:

https://www.babylonjs-playground.com/#KWVY94#8

1 Like

Thanks Evgeni. Is there a way to get that custom material to work when the texture is also set to the opacity texture?

https://www.babylonjs-playground.com/#KWVY94#9

Do I need add similar code to Fragment_Custom_Alpha?

This one is a little more involved because there’s no simple way to inject some code just after the alpha texture has been sampled.

You can use a feature that allows to tamper with the shader source code just before it is sent to the GPU to replace the alpha sampling code by your own (lines 51-64):

https://www.babylonjs-playground.com/#KWVY94#10

You can also write your own shader with ShaderMaterial but it’s even more involved.

You could also write a node material in the NME, using for eg uv2 to hold tileOffset.

1 Like

Man, you are a wizard. Thanks!