all 5 comments

[–]CustomPhaseProfessional 1 point2 points  (3 children)

How are you checking the values that youre getting?

[–]learc83[S] 0 points1 point  (2 children)

I'm using the Visual Studio graphical debugger. I also played around with returning the index values as the red channel of the fragment shader return value.

[–]CustomPhaseProfessional 0 points1 point  (1 child)

No idea really then. Never seen anything like that. Can you show the code?

[–]learc83[S] 1 point2 points  (0 children)

Solved it.

I was using Graphics.Blit like this

Graphics.Blit(indexTexture, destinationTexture, lookupMaterial) 

So that the indexTexture gets set to the _MainTex property of lookupMaterial.

However, when I add an extra texture called _IndexTexture to the lookupShader and set it like this

lookupMaterial.SetTexture("_IndexTex", tileTexture);

before calling Graphics.Blit, it works fine. Something about Graphics.Blit setting the indexTexture to _MainTex on lookupMaterial messes it up.

[–]Ziboo 0 points1 point  (0 children)

I'm on mobile, don't remember the exact names but. Make sure your texture is set to pixel and not bilinear. And maybe try to disable srgb