Is the use of the /Resources folder in /Generated Shaders necessary?

Avatar
  • updated
  • Answered

Hello!

Is it necessary that the codegen shaders in /Generated Shaders be included in the Resources AssetBundle? Moving them out of that folder still renders things correctly in the Player and reduces Player build times in an empty project.

I did not find any use of the Resources API to load the shaders in /Generated Shaders/Resources. I only saw the Resources API used for loading the assets "Shapes Assets" and "Shapes Config".

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
3.2.0
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Pinned replies
Avatar
Freya Holmér
  • Answer
  • Answered

yep, they're there for immediate mode drawing specifically!
the issue is that there's no way for Unity to detect whether or not certain shaders are used when they are loaded through code, so they're always included as a workaround

Avatar
patrickdevarney

EDIT: Whoops, bad test on my side. Immediate mode drawing does appear to need the shaders in /Resources to render in the Player.

Additionally, I tested this with the immediate mode drawing example in the documentation that draws an RGB line gizmo. The lines still render correctly in the Player after moving the shaders out of the /Resources folder.

Avatar
Freya Holmér
  • Answer
  • Answered

yep, they're there for immediate mode drawing specifically!
the issue is that there's no way for Unity to detect whether or not certain shaders are used when they are loaded through code, so they're always included as a workaround