Hello!
I am trying to pass a texture array to a NME CustomBlock function, and I can’t get it to work. I keep getting the error “cannot connect these two connectors”.
I will elaborate: I have a CustomBlock containing a shader function that takes a sampler2DArray, for example:
const code = `void SurfaceShader(vec2 uv, sampler2DArray tex, out vec3 rgb)
{
rgb = texture2D(tex, vec3(uv.x, uv.y, 0)).rgb;
}`;
const codeBlock = new BABYLON.CustomBlock("codeBlock");
codeBlock.options = {
"name": "codeBlock",
"target": "Neutral",
"inParameters": [
{ 'name': 'uv', 'type': 'Vector2' },
{ 'name': 'tex', 'type': 'sampler2DArray' }
],
"outParameters": [{"name": "rgb", "type": "Vector3" }],
"functionName": "SurfaceShader",
"code": [code]
};
So I believe I need to create and pass a RawTexture2DArray object into the input to this code block. However I can’t figure out how to properly do this.
I tried using an ImageSourceBlock, assigning the RawTexture2DArray to the texture, and connecting it to the CustomBlock, but I get the error “cannot connect these two connectors”. Here’s a playground link showing this attempt: Babylon.js Playground
I thought that perhaps I should be using an InputBlock instead, so I tried creating an InputBlock, assigning the RawTexture2DArray to the value, but unfortunately I get the same error. Here’s a playground link showing this attempt: Babylon.js Playground
Just for completeness, here’s a playground link showing a normal (non-array) texture, which works properly. Another way to phrase my question is: How can I convert this working sample to use a texture array instead of a single texture?: Babylon.js Playground
Thank you for any assistance, it’s very appreciated!
