I want to use shader graph,but some data come from compute buffer. I often use instance render, custom compute buffer.
Thanks in advance.
Not yet, no.
No support for defining structure buffers. No support for getting SV_InstanceID, SV_VertexID, or SV_PrimitveID. No support for really any of the things needed for instancing.
You can still use Shader Graph, but only for setting up the initial shader as you want it in the broad strokes. Then you have to hand modify the generated shader code.
You can define and use structured buffer using a function node.
Unfortunately it’s not correctly bound when SRP batcher is used but this might be a workaround while waiting for official support.
I don’t suppose you’d mind sharing an example of this would you? I’m having trouble wrapping my head around the Custom Function node.
@mephistonight have you read this article on the Unity blog?
It explains the basics of how to use that node in text or file mode.
Yeah. I found that blog post quite useful. I was trying to use the Custom Function node for something similar to what is being discussed here:
https://discussions.unity.com/t/736128
But even when using file mode, trying to use:
#define unity_ObjectToWorld unity_ObjectToWorld
#define unity_WorldToObject unity_WorldToObject
In a custom function just doesn’t seem to work. I’ve yet to figure out a way to get drawmeshinstancedindirect working in the HDRP via shadergraph.
@mephistonight Did you you ever get it working?
@julian-moschuering Would you be able to share an example?
The Custom Function Node page of the documentation does a good job of explaining how to include your own uniform variables. Not sure about vertex id etc, but the old chestnut of baking ids into UV2 etc could work for some use cases.
An example with structure buffer:
#ifndef VOXEL_MESH_INFO
#define VOXEL_MESH_INFO
StructuredBuffer<float> volume;
void MyFunctionA_float(float i,out float v)
{
v=volume[(int)i];
}
#endif
The custom function setting:
wow all that work maybe I backed the wrong game engine 4 years still not added
Can it be written with string type of custom function?
Hi, what would be the input in the i from the Graph side ?
Thanks
that would be the instanceID