Author Topic: Unity Editor Crashes / Shader Stripping  (Read 18 times)


  • Newbie
  • *
  • Posts: 7
    • View Profile
Unity Editor Crashes / Shader Stripping
« on: October 12, 2021, 04:43:33 PM »
Hi there,
We recently came across an editor issue with using beautify. It has been reported by our art team intermittently, however, I was tasked with making an editor tool, and I came across it quite frequently, enough to reproduce it consistently enough to isolate the problem. The issue appears to be present most when previewing the game view while not in play mode. I've been tasked with making an asset review scene, which takes multiple assets and generates a scene to preview the assets side by side for color correcting and scaling. Our game uses beautify so I also included this into the render pipeline of this customized scene. This custom editor would display a list of our prefabs and use PrefabUtility.LoadPrefabContents to swap out items in the scene.  When focused on the game view, the editor UI would essentially become non-responsive, however, the file, edit, view... menus would work, as well as the close window button, but nothing else would redraw. This issue was reported by our art team because they would frequently stage scenes in editor mode using the game view to preview their work. We submitted a few unity crash reports, which lead to them reporting an issue with something shader related as it was directX related. Digging deeper, I tuned off beautify and the crashes stopped. I swapped out for the unity post processing stack for the time being for this scene as it doesn't have the same behavior. Not sure if you have anything you can report on this but if there's a fix, please let me know.

Secondly, I would like to know what the best process is for manually stripping the shader variants. I know the plugin has a strip shaders option, however, using this option from our main scene (every other scene is loaded additively from AWS) didn't seem to yield any better results in terms of compile time on build. What's the best way to strip unused variants manually ?

Cheers !


  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Unity Editor Crashes / Shader Stripping
« Reply #1 on: October 12, 2021, 04:45:27 PM »
I should probably mention we are using :
Unity 2019.4.28f1
URP 7.6.0
Beautify 10_7_2021


  • Administrator
  • Hero Member
  • *****
  • Posts: 7361
    • View Profile
Re: Unity Editor Crashes / Shader Stripping
« Reply #2 on: October 12, 2021, 08:21:14 PM »
Regarding stripping options, Beautify takes care automatically of the keywords but if you want to fine-tune the shader automatically for any reason, you can do that. Find the file BeautifyCore.shader and edit it. Most shader variants are generated for Pass 2:

  Pass { // 2  Main Beautify Pass (core)
      #pragma vertex VertBeautify
      #pragma fragment FragBeautify
      #pragma multi_compile_local __ BEAUTIFY_TONEMAP_ACES
      #pragma multi_compile_local __ BEAUTIFY_LUT BEAUTIFY_NIGHT_VISION
      #pragma multi_compile_local __ BEAUTIFY_BLOOM
      #pragma multi_compile_local __ BEAUTIFY_DIRT
      #pragma multi_compile_local __ BEAUTIFY_PURKINJE
      #pragma multi_compile_local __ BEAUTIFY_VIGNETTING BEAUTIFY_VIGNETTING_MASK
      #pragma multi_compile_local __ BEAUTIFY_EYE_ADAPTATION
      #pragma multi_compile_local __ BEAUTIFY_OUTLINE
      #pragma multi_compile_local __ BEAUTIFY_COLOR_TWEAKS
      #pragma multi_compile_local __ BEAUTIFY_TURBO
      #pragma multi_compile_local __ BEAUTIFY_DITHER
      #pragma multi_compile_local __ BEAUTIFY_SHARPEN
      #pragma multi_compile_local __ BEAUTIFY_FRAME BEAUTIFY_FRAME_MASK
      #include "BeautifyCore.hlsl"

If you want to use a feature, you can replace each "#pragma multi_compile_local xxx" with "#define xxx 1" or "#define xxx 0" to disable it completely.
For example, replacing the #pragma multi_compile_local __ BEAUTIFY_DITHER with #define BEAUTIFY_DITHER 0 will disable dithering and wlil also remove that keyword (it will save lot of variants as well).

Regarding the Editor crash, I think it could be project specific as the asset has not shown this behaviour AFAIK. Could you please create an empty project using the same Unity/URP versions and import just Beautify. Use the same effects and settings in the demo scene included with the asset and verify if the crash persists. If it does, please send me that project by pm. Otherwise, try to reproduce it somehow in a repro that you can send me and I'll take a quick look into it. Thanks!