0

In Unity, I have a sprite with the usual _MainTex and an additional _inner texture defined as secondary texture in the sprite editor. In shaderGraph, when I want to access this secondary texture for a material meant for the sprite renderer, I can just enter the "ref" as _inner in the Texture2D property, works like a charm.

But when I try to do the same with the same sprite with a shader meant for a UI canvas image (in-game UI), the shader does not appear to find the secondary texture (so the same shader works on my SpriteRenderer, but doesn't on my UI image renderer).

Am I doing something wrong? Any idea what?

Giezi
  • 140
  • 1
  • 10
  • can you post the shader code? – nkazz Feb 01 '21 at 20:01
  • I can, but it's generated by shadergraph. The two first properties are: ```Properties{ [NoScaleOffset] _MainTex ("MainTexture", 2D) = "white" { } [NoScaleOffset] _inner ("Inner", 2D) = "white" { } } ``` – Giezi Feb 01 '21 at 20:17

1 Answers1

0

I have encountered a similar problem, the difference is I was making an unlit shader from shader graph. As far as I know, the problem is caused by the master node. Change the master node to sprite lit or sprite unlit, then it can specify the secondary shader, otherwise it won't. So if your UI shader can work fine with a sprite lit or sprite unlit node, you can give it a try.

Sprite Lit and Sprite Unlit works fine

Sprite Lit and Sprite Unlit works fine

EDIT:

As I commented below, flip the secondary texture back.

enter image description here

I can't explain the principle behind the problem, but it worked for me anyhow.

Nicolas Dai
  • 296
  • 1
  • 8
  • I gave it more test, and found that the secondary texture is loaded actually, but normal has been flipped, flip it back will work perfectly. – Nicolas Dai Mar 29 '21 at 03:59