Hello. I have been learning shaders lately and I have created my first shader effect. My shader controls the PlayerVisibility radius (assume 2D Horror game where the Player can only see limited distance).
To create this effect I did the following:
- Create Black background to cover my whole map and set it to high order in layer ensuring it is on top of all other assets. Set mask interaction for the Sprite Rendederer Mask interaction to Visible Outside Mask.
- Have my tilemap on order in layer 0
- Have my Player Sprite and Player Visibility on order in layer 1
- Add Sprite Mask on Player Visibility game object.
Now I am able to see a small radius around the player, the rest of the map is black out due to black background that is high order in layer.
I also want to have a custom material assigned to my PlayerVisibility game object. I want to be able to control fade in/fade out and how far the player can see. For this I have created a custom shader which works exactly how I want.
I noticed that when I have Sprite Mask Component, the Material properties will not be available in the inspector hence I cannot change the properties of my shader “on the go”.
See the first image attached, when the Sprite Mask is available I cannot access the Material properties.
See the second image attached, when I delete Sprite Mask component, I can access the Material properties but since I no longer have Sprite Mask my game does not work how I want.
I want to know if I can have Sprite Mask and still have access to my Shader properties? Currently, if I want to adjust my material properties, I have to adjust them in Shade Graph and save the shader and then it will be applied to my game object but that is not convenient. I have created some properties (FadeFinishRadius, FadeStart and Color) exactly for this reason but I cannot access them