Hi, I’m procedurally generating a texture and applying it to a material on a plane with sharedMaterial.mainTexture this main texture is usually accessed in a shader by using _MainTex
Using a PBR shader graph works fine but using an Unlit shader graph gives errors, even though the graphs are identical with the only change being the Master node.
The error is: Compilation error in graph at line 66 (on d3d11): redefinition of ‘_MainTex’
btw using shader graph has saved me so much time so far, I owe you lot a full tanker truck of beer
I believe the issue is that the Unlit LWRP subshader defines _MainTex for use in its meta pass. Changing this requires changing all of LWRP…
May I ask if there is a specific reason you are using _MainTex?
We dont recommend you use those shortcuts anymore and instead use Material.SetTexture("_MyTexture", texture) instead. This way you can be sure to avoid naming conflicts with properties required by the render pipeline.
Second this. We cannot use SpriteRenderer due to this limitation.
While we are on the topic, it would be nice if once SpriteRenderer is supported if Unity would provide the Pixel Snapping option that default Sprite shader has as a node.
There are going to be new specific master nodes to write Shader Graph shaders for 2D sprite rendering, which won’t be using the meta pass that defines _MainTex. So once you’re able to use the new master nodes, you should also be able to use _MainTex for your intended use case.