Graphics.Blit always outputting 1 on red and alpha channels

I’m new to shaders and ShaderGraphs and am having an extremely odd issue when attempting to Graphics.Blit() to a RenderTexture. I created an extremely basic ShaderGraph, which quite literally does nothing except return a solid color. (Black with no alpha in this case) I then set the Material this graph creates in the editor to the paintMaterial field. Here is the ShaderGraph:

I have a script that does the following:

private void Start()
        {
            this.wetnessTexture = new RenderTexture(this.textureSize.x, this.textureSize.y, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear);
            this.wetnessTexture.Create();
        
            this.soilMaterial.SetTexture(WetnessTexture, this.wetnessTexture);
        
            //Make sure the RenderTexture starts at all black.
            RenderTexture.active = this.wetnessTexture;
            GL.Clear(true, true, new Color(0, 0, 0, 0));
            Graphics.Blit(null, this.wetnessTexture, this.paintMaterial);
            RenderTexture.active = null;
        }

I’m viewing the RenderTexture by just clicking the SoilMaterial and seeing what the WetnessTexture property is displaying. It looks like this:

It’s completely red, despite the paintMaterial only being able to return (0,0,0,0) for the color. If I output the color at (0,0) by converting it to a Texture2D and then calling GetPixel(0,0), it says 0.471, 0.004, 0, 0.

1 Like

Solved, you have to use Graphics.Blit(null, this.wetnessTexture, this.paintMaterial, 0); because ShaderGraphs do multiple passes that shouldn’t be rendered every pass, only the first one.

1 Like