Custom color buffer in node material


Could you help me?

I have a problem with custom block. I want to provide custom buffer to my node material.

I used your PG:
And in my PG: it also works.

But when I try to attach my custom block to another port of color merger i got an error

Unfortunatelly i dont understand whats happend because i dont find detailed documentation about the way of creation custom block which you used in your example. Never the less I looked at doc about creation of the custom blocks from json file (Node Material Editor Custom Blocks | Babylon.js Documentation). But I dont understand how i can define attribute (my custom buffer) and provide them on output of the node using way this way (Node Material Editor Custom Blocks | Babylon.js Documentation)

Please help me if you can

When i try to connect my custom block to any another port line “undefined” is added to vertex shader before attribute vec2 myTest;

Interesting thing that if i reconnect out port of my block manually (using ‘connectTo’ function, not nme) it works fine

In fact, when in the NME, the default setting is to generate the comments along with the functions that have been injected in the code through the _emitFunction method. The comment is the 3rd parameter of _emitFunction, but in my example I did not set a comment, so it is undefined my default. You can fix the problem by setting a dummy comment:

1 Like

You are rock :metal:
Thank you very much!!!

One more question. Could I add such as custom block to NodeMaterial editor? I know how to do that with blocks parsed from .json but in this case I don’t know if it is possible

No, that won’t be possible because you can’t create a new attribute with the CustomBlock feature of the NME.

1 Like

Thank you!

Hello again @Evgeni_Popov !

I dont think that it is right to open another topic because my new question is very close to this topic. It is about providing of texture to node material by instance. I already read topic about changing texture per instance using uv offset but it will not work for me. Maybe there is the way to provide small texture (<512x512 px) using buffer? Like we did it with floats or vectors

Unfortunately it’s not possible. We can’t bind textures on a per-instance basis. You will have to use a big texture and pass a (u,v,width,height) vec4 to each instance, so that they can each target a different part of the texture.

1 Like