Closed sebavan closed 2 years ago
@sebavan @PatrickRyanMS for this, would changing the Attribute line on the NME from Options to a Text Input suffice?
Almost :-) It would also require a new mode being Custom Attribute and only in this mode having a text input.
How would the custom attribute get used in NME? And how do we preview it? For shaders that deal with things like vertex color, we need to load in a preview model with vertex color. But how are we handling custom attributes?
I think we don't need to preview custom attributes, as we won't know what they are beforehand.
And if the user wants to test they can drop their own mesh in the preview window anyway
And if the user wants to test they can drop their own mesh in the preview window anyway
This is where I am confused. If it's a custom parameter and we don't know what it's for, how do we apply it to a user-provided mesh? Especially if it's a parameter for something like a thin instance where the meshes rendered in the preview window are not thin instances. I agree that we can't render something we don't know how to handle, but is that distinction ok since NME stand-alone does not have a scene attached and there is no way to validate what any custom parameter is doing until you attach it to a scene? At minimum, we should probably put some language in the parameters panel of a custom parameter that we do not render the results of custom parameters in the preview window.
In case this helps anyone, I found a workaround for my situation by using a normal input block with this snippet:
const selectedBlock = nodeMaterial.getBlockByName("selected");
if (selectedBlock instanceof BABYLON.InputBlock) {
selectedBlock.setAsAttribute("selected");
nodeMaterial.build();
}
Especially if it's a parameter for something like a thin instance where the meshes rendered in the preview window are not thin instances.
You have a good point on this, maybe we should at least add an option on the drop down to render a few instances/thin instances so the user could preview shaders that vary per instance 🤔
Closing for now as there is a way to do it by code and doing it in NME does not provide additional benefit
It would be great to have the possibility to use custom attributes through the NME editor.
It is currently possible by code in the NodeMaterial input block but not through the editor.
https://forum.babylonjs.com/t/how-to-make-nme-material-for-thin-instances-with-color-attribute/30469/6?u=sebavan