IssuesCategory: MagioShader issue on Build
Tommy Wilkinson asked 10 months ago

Whenever I try to build my project using Magio effects I keep getting this strange error regarding the maximum number of Shaders:
Shader error in ‘Arctibyte/MagioHDRP’: maximum ps_5_0 sampler register index (16) exceeded at line 12630 (on d3d11)
 
The full error in console:
Error building Player: Shader error in ‘Arctibyte/MagioHDRP’: maximum ps_5_0 sampler register index (16) exceeded at line 12630 (on d3d11)
Compiling Subshader: 0, Pass: Forward, Fragment program with DECALS_4RT DIRLIGHTMAP_COMBINED DYNAMICLIGHTMAP_ON LIGHTMAP_ON PROBE_VOLUMES_OFF SCREEN_SPACE_SHADOWS_OFF SHADOWS_SHADOWMASK SHADOW_MEDIUM USE_CLUSTERED_LIGHTLIST _BLENDMODE_OFF _DISABLE_SSR_TRANSPARENT _ENABLE_FOG_ON_TRANSPARENT _REFRACTION_OFF _SURFACE_TYPE_TRANSPARENT
Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PBS_USE_BRDF3 UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
Disabled keywords: DEBUG_DISPLAY DECALS_3RT DECALS_OFF DECAL_SURFACE_GRADIENT INSTANCING_ON PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 SCREEN_SPACE_SHADOWS_ON SHADER_API_GLES30 SHADOW_HIGH SHADOW_LOW SHADOW_VERY_HIGH UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_FRAMEBUFFER_FETCH_AVAILABLE UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_PBS_USE_BRDF2 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_UNIFIED_SHADER_PRECISION_MODEL UNITY_VIRTUAL_TEXTURING USE_FPTL_LIGHTLIST _ADD_PRECOMPUTED_VELOCITY _ALPHATEST_ON _BLENDMODE_ADD _BLENDMODE_ALPHA _BLENDMODE_PRE_MULTIPLY _DISABLE_DECALS _DISABLE_SSR _DOUBLESIDED_ON _REFRACTION_PLANE _REFRACTION_SPHERE _REFRACTION_THIN _TRANSPARENT_WRITES_MOTION_VEC
 
Exploring it on my own seems to point to some problem in the shader graph component of the base magio effect, but I don’t know if that is accurate or which part might be causing an issue. I’m using the HDRP package in Unity 2021.3.1f1 using the HDRP render pipeline.

1 Answers
Thomas Staff answered 10 months ago

Hello!
 
I am sorry you have encountered problems. Have you tried Magio with a new project? By creating it from new->hdrp template in hub. The issue sounds like there is something wrong/different with your hdrp setup. You could also reach out to Unity since this sounds like a Shader Graph bug. I’ll also try to reproduce this when I get back to office from holidays 🙂
 
I hope this helps!
-Thomas

Tommy Wilkinson replied 10 months ago

Thank you for the quick response! I didn’t want you to work on holiday so I delayed a bit in testing this out 🙂 Trying this out with a brand new HDRP project it does indeed build just fine, so it doesn’t seem to be an issue with Magio directly but I’m not sure why Unity is pointing to it. I started up the original project the same way and I don’t think I’ve made any significant changes to HDRP settings that could cause this, but I might need to go through them all. The weird thing is I’ve been able to build the project just fine before with Mario in the project. The only change this time was I included a scene that actually had Magic assets in the scene, but when I removed that scene it still wouldn’t build like the first time… So it’s probably a Unity bug but I have no idea where to start on fixing this. Thank you for the help!

Thomas Staff replied 10 months ago

Thank you for minding my holiday! I am back at work 🙂

Seems like this is a common issue with new Unity versions and with any shader: https://forum.unity.com/threads/maximum-ps_5_0-sampler-register-index.562867/ (Scroll down)

It seems that workaround for the time being is to introduce “Sampler state” nodes in the shader graph. This works at least in URP (I haven’t been able to re-produce this in HDRP). I’ll try to incorporate this fix to the next update if there is no downfalls. Here are instructions if you want to try it your self:
1. Open Magio/Core/Shaders/MagioHDRP shader graph
2. Look for all SampleTexture2D nodes.
3. Create and Attach Sampler State nodes in all SampleTexture2D nodes like here: https://forum.unity.com/attachments/capture-png.949555/
4. Save the shader graph

Another option would be just downgrading the Unity minor version and testing if it works there.
I hope this helps!

All the best,
Thomas

Thomas Staff replied 10 months ago

New version with supposed fix is now online in the asset store.

All the best,
Thomas

Your Answer