Shader property issue with Single Pass Instanced

Hi!

I have a question related to the Single Pass Instanced mode and setting material texture properties.

I have a property in a shader defined like this:

_OverlayTex (“Overlay (RGB)”, 2D) = “black” {}

The uniform itself is defined properly as
UNITY_DECLARE_SCREENSPACE_TEXTURE(_OverlayTex);

However when going into play mode, I got a console error:
“Error assigning 2D texture to texarray texture property ‘_OverlayTex’: Dimensions must match”

It works fine though and if I remove the property declaration (and keep just the uniform), the console error goes away as well. However we prefer to declare the property otherwise Unity loses the reference and the effect when the script gets initialized do not look properly in Editor.

If a change the property to:

_OverlayTex (“Overlay (RGB)”, 2DArray) = “black” {}

then it works fine, no errors, but it fails in other VR rendering path non-VR mode.

So to the question: is there any way to declare a property either 2D or 2DArray so it does not depend on the active VR mode? Thanks.

Hi @Kronnect !

You are running into this issue because single-pass instancing uses texture arrays whereas single-pass and multi-pass use a single texture.

Try the following

_OverlayTex ("Overlay (RGB)", any) = "" {}

I hope that helps.

2 Likes

Yep, helps a lot, it works. Thank you!

btw, regarding Single Pass Instanced rendering, I have noticed that simple Blit operations between TwoEye flagged render textures do not honour this setting:

RenderTexture rt1, rt2; // both are TwoEye flagged
Graphics.Blit (r1, rt2); // <-- do not work

But using a simple vertex/frag shader that uses the appropriate macros for instancing and sampling texture works.

Trying to do this on line 40 of a shader. Single pass stereo instanced. multi_compile instanced pragma.

UNITY_DECLARE_SCREENSPACE_TEXTURE(_ReflectionTex);

Shader error:

Shader error in …: Unexpected token ‘;’. Expected one of: typedef const void inline uniform nointerpolation extern shared static volatile row_major column_major struct or a user-defined type at line 40

Any ideas?

This is Unity 2018.2.2

Hi @Kronnect ,

The Graphics.Blit() issue is now fixed in 2018.2.

1 Like

Hi @jjxtra ,

Is it possible for you to post your shader? Thanks!

Hi, I’m running into the same issue as @jjxtra using an asset from the Asset Store, Aquas Lite. The shaders that provide this error are AQUAS-Lite_Frontface.shader and AQUAS-Lite_Backface.shader. The shaders use UNITY_DECLARE_SCREENSPACE_TEXTURE without a semicolon, which also provides an error. Adding the semicolon gives the same error as @jjxtra . I’m running Unity 2022.3.20f1.