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.