Hello. I’ve created a Shader Graph that draws traces on a texture when clicking on specific mouse coordinates. The shader works, but there’s one issue I can’t solve—or rather, understand why it exists.
The problem is that when I start drawing traces and render the first trace, the shader writes two traces: one at the default mouse position of the shader and another at the correct mouse position. In my understanding, only the new trace should be recorded.
How the shader works:
- The CRT trace texture (with Double Buffered enabled) is initialized with a black color when entering the drawing state.
- The shader then receives the correct position, and only after this, the CRT texture is updated.
- In a different shader, the CRT texture is blended with another texture and displayed on the material.
In other words, the displayed traces are taken only from the CRT texture.
The issue can be resolved if the default shader coordinates are set outside the texture coordinates. However, I’d still like to understand why the trace at the default coordinates is being recorded.
Here’s how I update the CRT:
if (hit.collider.gameObject.CompareTag("WSoil"))
{
_cntx.WaterMat.SetVector("_inputPosition", hit.textureCoord + RandomCirclePoint());
_cntx.WaterMat.SetFloat("_maskAngle", Random.Range(0, 360));
_cntx.WaterCRT.Update();
}
How shader looks:
Do you have any ideas?
Thank you in advance!