Hey everyone, I've been looking everywhere for how to do an effect I need for my game. What I want is as the player is moving through a black and white world, I want to bleed colors that turns the world into color as the bleeding expands leaving a trail of colored world. The closest I have come to finding this effect is this: . But this in only a global effect. It doesn't help me as far as leaving a trail behind. Does anybody have any advice on how I can accomplish this?
Use render texture to store mask, and use that mask for blend colored and grayscale zonese. A mask can be drawn, like this for example. Code (CSharp): Shader "Unlit/UvTest" { Properties { _MainTex ("Texture", 2D) = "white" {} _BrushColor("Brush color", Color) = (1,.5,.5,1) _BrushSize("Brush size", Float) = 1 } SubShader { Tags { "RenderType"="Opaque" } Cull Off Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; float4 worldPos : TEXCOORD1; }; sampler2D _MainTex; float4 _MainTex_ST; float4 _BrushPos; fixed4 _BrushColor; float _BrushSize; v2f vert (appdata v) { v2f o; o.vertex = float4(v.uv.x-0.5, -v.uv.y+0.5, 0, 0.5); o.worldPos = mul(unity_ObjectToWorld, v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); return o; } fixed4 frag (v2f i) : SV_Target { // sample the texture fixed4 col = tex2D(_MainTex, i.uv); float dist = distance(i.worldPos, float4(_BrushPos.xyz, 1)); fixed t = smoothstep(0,_BrushSize,dist); col = lerp(_BrushColor, col, t); return col; // return t.xxxx; } ENDCG } } } Code (CSharp): using UnityEngine; [ExecuteInEditMode] public class BrushPositionSetter : MonoBehaviour { void Update() { Shader.SetGlobalVector("_BrushPos", transform.position); } } The same render texture is used for both input and output. It's works but I do not know how to get rid of the black edging on the borders of the UV islands.
Thanks! That's a lot closer to what I'm looking for. Where does the material go and I assume the setter going on the orb you paint with?
Here package with current setup, just for demonstrate conception, I think is better idea use camera controlled from script, or even something like drawMeshNow.
Thanks again. Your project works only I'm not getting the same result as in your video. It's working more like a spotlight or a projector. Not actually leaving any trail behind.
I don't know what is happened, may by something was corrupted due version mismatch. Here I iterate thru all things to show settings.
Hi there, same here. How are you leaving the trail behind? I'm trying to recreate the shader in shadergraph