Int UBO for Material Plugin

I followed this topic to add Array UBO:

But it does not work, neither true nor false for engine.disableUniformBuffers:

The error I get with engine.disableUniformBuffers = false:

...
Interface block Material is not linkable between attached shaders.

When I set engine.disableUniformBuffers = true, then all materials are black.

I get a different error with engine.disableUniformBuffers = false:

Error: Precisions of uniform block ‘Material’ member ‘Material.revealersCount’ differ between VERTEX and FRAGMENT shaders.

So I try to changed revealersCount to float and it worked.

Tip: you should register plugin before setting the material, the ground material is not using the plugin now.

Worked PG(I guess): https://playground.babylonjs.com/#3576XC#4

Edit: the error I meet is the same as CustomMaterial Error: Precisions of uniform "..." differ between VERTEX and FRAGMENT shaders, but there is nowhere in material plugin to declare highp int before uniform block Material is decalred, so it seems change int to float is the only way?

2 Likes

I did set type to “mediump int”, then it works!

You can use the CUSTOM_VERTEX_BEGIN and CUSTOM_FRAGMENT_BEGIN injection points to inject some declarations near the start of the shaders.