Search Issue Tracker
Fixed in 5.4.0
Votes
0
Found in
5.4.0b8
Issue ID
774822
Regression
Yes
[Regression][5.4][RTP] RTP Terrain shader rendering is broken after upgrading project to 5.4
Preconditions:
Download Relief Terrain Package (https://www.assetstore.unity3d.com/en/#!/content/5664) from A$.
Steps to repro:
1. Open Unity 5.3.3f1;
2. Create new project and scene;
3. Import downloaded previously Relief Terrain Package;
4. Create terrain gameobject (GameObject -> 3D Object -> Terrain);
5. Go to 'Paint Texture' tab of Terrain component;
6. Add 4 different terrain-layer textures (e.g. Grass, Rocks, Ground, Snow);
7. Add Relief Terrain Engine component (Add Component -> Relief Terrain -> Engine-Terrain or Mesh);
8. Select ‘RTP_LODmanager’ gameobject in the Hierarchy panel;
9. In the Inspector scroll down and click ‘Recompile shaders for given feature set’ button;
10. Wait until shaders recompile;
11. Notice that after recompilation terrain shader is rendered stably without any errors (expected behaviour);
12. Save scene and project;
13. Close Unity;
14. Open Unity 5.4.0b8;
15. Open the same project and scene;
16. Notice that after the project is opened in 5.4.0b8 shader error is displayed:
Shader error in 'Relief Pack/ReliefTerrain-FirstPass': maximum ps_4_0 sampler register index (16) exceeded at Assets/ReliefPack/Shaders/ReliefTerrain/RTP_Base.cginc(664) (on glcore) Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN LIGHTMAP_OFF DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF RTP_PM_SHADINGPlatform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP UNITY_TEXTURE_ALPHASPLIT_ALLOWED.
Also notice, that shader rendering terrain is broken (see attached actual.png and gif video).
17. Repeat steps 8-10 (shader recompilation).
Actual result:
Terrain shader is partially broken - texture is visible when viewpoint is far from terrain, however when scrolling in, it all goes purple (see attached gif video).
Regression introduced in Unity 5.4.0b8.
Expected result:
- Terrain shader should be rendered normally without fallbacks after upgrading project to 5.4.
- No errors should be shown after upgrading/recompiling shaders in 5.4.
Expected behaviour could be found in 5.3.3f1.
Notes:
- Reproducible in: 5.4.0b8;
- Not reproducible in 5.3.3f1;
- Reproducible on: OSX 10.11.3 and Windows 10;
- This bug could be package related;
- Opening project again on 5.3.3f1 after having received broken shader rendering in 5.4.0b8 leads to broken shader in 5.3 as well.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Profiler - Taking you to the wrong section when using 'show'
- Draw Renderers custom pass doesn't work with SSGI
- WebCamTexture does not set the requested resolution when used in WebGL
- Editor default Stylesheet/Matching Selector buttons in Debugger don't do anything
- Graphics.DrawMeshNow stops rendering Render Texture after a few frames when viewed in the Player
crypt0
Jul 31, 2016 11:31
I have the same problem in Unity 5.3.5f1 - Can't fix it.
Here my error message:
Shader error in 'Relief Pack/ReliefTerrain-FirstPass': maximum ps_4_0 sampler register index (16) exceeded at Assets/ReliefPack/Shaders/ReliefTerrain/RTP_Base.cginc(661) (on d3d11)
Compiling Fragment program with DIRECTIONAL SHADOWS_SCREEN LIGHTMAP_ON DIRLIGHTMAP_OFF DYNAMICLIGHTMAP_OFF FOG_EXP RTP_PM_SHADING
Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING
w1shmast3r
Apr 14, 2016 17:53
Fix has been merged and verified in 5.4.0b15.
w1shmast3r
Apr 07, 2016 13:24
Sorry for little misspelling - we could expect a fix in Version 5.4.0b15-b16.
w1shmast3r
Apr 07, 2016 13:22
Hi,
The problem was caused by a couple of new #defines enabling features in 5.4 that added some samplers.
Firstly, UNITY_SPECCUBE_BLENDING. This is already disabled in the shader like so:
CGINCLUDE
#if defined(UNITY_SPECCUBE_BLENDING)
#undef UNITY_SPECCUBE_BLENDING
#define UNITY_SPECCUBE_BLENDING 0
#endif
ENDCG
But this doesn't work as expected anymore in 5.4 since we pass the define on the command line based on the platform rather than defined in code based on the platform. Basically that means it's not undefined early enough before it's already used in a unity #include.
If the user shader does #include "Lighting.cginc" or #include "UnityPBSLighting.cginc" manually, we won't do it in the compiled surface shader. This allows the above #undef to happen before the macro is actually used (by default in 5.4 right now, those files are included before the CGINCLUDE is run).
There is also a feature in 5.4 UNITY_LIGHT_PROBE_PROXY_VOLUME which can be disabled in a very similar way:
#if defined(UNITY_LIGHT_PROBE_PROXY_VOLUME)
#undef UNITY_LIGHT_PROBE_PROXY_VOLUME
#endif
#define UNITY_LIGHT_PROBE_PROXY_VOLUME 0
Of course the user might not want to disable this feature, but it adds some samplers so the shaders will not compile as-is without either disabling it or some other modification.
So, for now there we don't have a certain workaround for this case. We need to wait until the fix successfully lands in 5.4 betas builds - hopefully in the next next or in 2 builds from now. After it's there, it will need some fixes to the shaders as described above to #include those two system files (#include "Lighting.cginc" and #include "UnityPBSLighting.cginc" ) manually.
Regards,
Vladimir,
Unity QA team.
G33RT
Mar 22, 2016 13:41
Any known workaround for this in 5.4b11?