Blending Materials Based On Trigger.

Hey everyone,
I’m trying to create a prototype for a game project and I’m unsure how to proceed with my current goal. I’ll start by stating I don’t have any real knolage of shaders and scripting for them. With this just being a prototype I was hoping I could put something together a bit quicker, just to test the concept. Other then that I’m quite well equiped to handle C# scripting.

So what I am trying to achive can be seen below:

I would like to have objects within my game have 1 of 2 meterials applyed to them based on the position of triggers within the world. This would also need to work in real time, so the triggers could be moved and the materials would update accordingly.

From what I understand, I would need a shaders that supports 2 different materials. Then I would somehow tell the shader during the drawing process where the trigger is so that it can draw the different materials for the correct areas. (Again not really sure about shaders - so that could be complete noncess).

If anyone knows a way to create this effect or could point me in the right direction that would be amazing.
Thanks all.

Hello,

One simple idea:

  • Make an offscreen pass before the opaque passes which will contain a mask. Like your screen, output red color for pixels outside your trigger, blue color for pixels inside your trigger and a mixed reb-blue color for pixels between the two.
  • Send the mask to your material shader which will choose the render technique depending on the mask color.

To make an offscreen pass, you can use CommandBuffer, Shader pass with Grabpass, etc. (In my opinion, CommandBuffer is better)

You may simple just use a projector and a projector material with falloff map. Then project the material B on to the object with material A.