I implemented a ShaderGraphMaterial and tried to load it from my usda scene by ShaderGraphMaterial.init(name: in: bundle). I want to dynamically set TextureResource on that material, so I wanted to expose texture as Uniform Input of a ShaderGraphMaterial. But obviously RCP's Shader Graph doesn't support Texture input as parameter as the image shows:
And from the code level, ShaderGraphMaterial also didn't expose a way to set TexturesResources neither. Its parameterNames shows an empty array if I didn't set any custom input params. The texture I get is from my backend so it really cannot be saved into a file and load it again (that would be too weird).
Is there something I am missing?
Hi @milanowth
RCP's ShaderGraph does support textures as input parameters to shaders!
First, select Image File as the type of the input parameter in Reality Composer Pro. Then, in code, use the setParameter(name:value:) method of your ShaderGraphMaterial with a value of .textureResource(_:) to pass your texture to the shader.
For example, if your ShaderGraphMaterial has an Image File input with the name "MyTexture", you can set this parameter in code like so:
try shader.setParameter(name: "MyTexture", value: .textureResource(myTextureResource))
Here, shader is the ShaderGraphMaterial you loaded from RCP, and myTextureResource is the texture resource you want to apply to your shader.
Hope this helps, and let me know if you have any additional questions!