Hi, I am trying to create a paint-like shader where the shader draws color into a texture while preserving the paint from the previous frame.
#pragma kernel Paint
Texture2D Input;
RWTexture2D Out;
SamplerState samplerInput;
float2 position;
float radius;
[numthreads(32, 32, 1)]
void Paint(uint3 id : SV_DispatchThreadID)
{
float4 colorIn = Out[id.xy];
float xdist = position.x - id.x;
float ydist = position.y - id.y;
float dist = sqrt(xdist * xdist + ydist * ydist);
int on = sign(radius - dist);
Out[id.xy] = float4(max(colorIn.r, on), 0.0, 0.0, 1.0);
}
This code was working, but stopped working when I updated to Unity 2017.3.1f1. Is there a better way to do this that won't break when Unity updates?
↧