Hi guys, for my new endless runner game I wanted to make a glow around the player that
This is what I’ve got currently, the background offsets with the camera. I’d like the glow to fill in the lines of the pattern and to get fainter further from the player.
I know I can just make a lit texture of said lines and set the alpha, but the problem is knowing where the player is. I considered using a stencil buffer but that only allows for on or off. I also looked into multiple passes and subshaders but I ran into the same issue of not knowing where the player is.
Are there any other means of communicating between shaders? To only render a certain texture in an area where a different sprite exists?
All the solutions with setting blending seemed to be outdated.
My current fragment shader, should it help (I know I could have done the offset/scale in script but I felt it more appropriate here in case I needed the values for the glow effect):
float _XPos; //Comes from script, unsure how to get it from shader
fixed2 _Scale; //Not used, didn't know how to format a float2 in the Properties section
float _ScaleX;
float _ScaleY;
fixed4 frag (v2f i) : SV_Target
{
//texture is scaled to compensate for how the sprite was scaled by the script (to account for different screen sizes)
float postScale = 0.7; //For scaling after compensation
fixed4 mainOut = tex2D(_MainTex, float2((i.uvMain.x * _ScaleX * postScale) + (_XPos * postScale), i.uvMain.y * _ScaleY * postScale)); //the xPos is also added (scaled to fit)
return mainOut;
}
Any help, other ideas on how I could achieve this effect, or even just an indication of where relevant information might be found is much appreciated. Thank you.