Questions about shaders and Materials

Hello, I have 2 questions

  1. if we create a custom shader directly in the “/shaders” folder with a text editor can we only use it using a script? I mean is there a way to connect it with a new material?

  2. when we create an instance of a material with parameters, is there a way to use the same instance on 2 objects and edit the parameters for each objects from the inspector? Let’s say one has color red and the second color blue or do I need to duplicate the instance and assign a different instance to each objects ? (after testing it seems more that I need 2 instances)


about the first question I would say yes you can, with a script and a material instance (I don’t know if there is another or better way), using a GPUTexture and setting it as render target and then pass this texture to the material instance.
As a quick example, taking the Custom Geometry Drawing tutorial and modifying it a bit to add the GPUTexture.

This other tutorial, HOWTO: Render FPS weapon, has an example using a GPUTexture.

As for the second point, if I understood it correctly it would be something like Custom Primitive Data from unreal engine, but I don’t know if it can be done.

reading again the first question, now I don’t know if you want to skip the script part or if what I commented is useful for you. If what I said doesn’t work for you, I hope you find the answer.

Thank you for your reply, I came from an Engine where you basically derive a shader to make a material, I can see here the flax philosophy is much more low level, so certainly more powerful but needs more of a learning curve, it will certainly help if we could have both options into the material editor for using visual shader or simply text editor and then drap & drop the material into an actor, so I will dig the documentation more and try to understand the low level programming of the render pipeline in flax :slight_smile: