<@!784729418484547605> in case you have any questions / feedback, here would be the right place!
#🥝-shader-variant-explorer
📦 : https://github.com/needle-tools/shader-variant-explorer
I have yet to write anything that works with this tool because all my shaders that I tested were too big
But for it worked for a couple other shaders and was pretty interesting too look into
Oh, interesting. Would you mind sending me one of those shaders that didn't work? I'm aware some HDRP shaders might be too big, is it for HDRP?
My bad, actually it does work there was a issue with my project I think, It works in a fresh project. No its a forward BiRP shader. it produced a 200MB file. this is the shader https://github.com/Float3/shaders
🙂
Are these all shader_feature? Can you still build?
Yeah they are shader_feature_local Yeah I can still build even with this shader
Nice. I've got some ideas on how to make it work with the Variant Explorer, might lose some convenience features but otherwise should be possible
Those Billions of Variants are with “Skip unused shader_feature” unchecked right so the actual amount isn’t too big
Also I strip unneeded variants with a editor script that inherits from IPreprocessShaders so that speeds up builds by a lot https://github.com/Float3/3s-Unity-Stuff/blob/master/Assets/Scripts/3/Editor/ShaderPreProcessor.cs
Huh interesting what do you have in mind?
Most ops inside it are already "on-demand", that is, you compile the variant you want to see and just that (which is fast). What makes it slow right now for big shaders is a preprocessing step that attemps to figure out which keywords are part of the same define group
Removing that step means you'll be able to debug if you know which keywords belong to each other, which you usually do as the author anyways
I see
Unity will still compile every combination of keywords for the following example
#if KEYWORD_A
#if KEYWORD_B
#endif
#if KEYWORD_C
#endif
#endif
The compiler has all that info anyways, but there's no (good) way that exposes it. I'm using the bad one...
Does it though
The shader compiler does not seem to care/know what keywords rely on each other
If keyword A isn't set then B and C are irrelevant, but Unity will still generate variants with every combination of A, B, and C by default.
I think they compile this correctly but the numbers shown don't reflect that
The numbers are guesstimates
If you do #pragma shader_feature_local A B C D it will not compile all combinations of these
And you sadly can’t #if check #pragma otherwise could do conditional #pragma skip-variant
At least not until this version
"New #include_with_pragmas directive (from 2020.1.0a18)" in https://forum.unity.com/threads/new-shader-preprocessor.790328/
Yep, continuous movement in that area I started the Variant Explorer when the pass compile API was like a week old Immediately found 10 bugs and shader compiler crashes just by pressing random buttons 😄
That sounds about right
In 2021.2 or 2022.1 there's now dynamic_branch as "keywords"
Hm
It does nothing more than turn "actual variants" into bool switches, but makes sense for e.g. the myriad of debugging variants they introduced for URP/HDRP
at a certain point with the mess that is shader variants I feel like variants should be standardized and drivers should be able to handle "jitting" the variants for you
actually SPIR-V has that - but a giant ship like Unity likely won't support special features that only work on some platforms
unless they continue their tooling stuff and just make "everything is SPIR-V anyways" toolchains
Interesting
How does it work?
With a hint thing and say "this is a variant switching over this variable"?
And then during the jit it just displays one that does branching?
I'm absolutely no expert in either Vulkan or SPIR-V though 😄
Yeah same here, I don’t really understand that article
Unity HLSL and ShaderToy GLSL are the only the are shader stuff I have any experience with
<@!784729418484547605> the shader that has these billions of variants isn't in the repo, right?
<@!784729418484547605> which Unity version are you on btw?
I usually use 2019.4.31f1
But I made a 2021.2 project to test stuff in the shader variant explorer
So I just copy stuff over when I wanna test
OK 🙂 I just released a 0.3.0-pre, which should effectively remove any limits to how many variants your shaders have
The "new stuff" (aka removing that limit) uses some 2021.2 APIs, so that's only available starting there
New Release, 0.3.0-pre! ✨ This release leverages new shader APIs on Unity 2021.2+ that allow fine-grained control over variant compilation. In practice, it means that you can now explore the individual variants of huge shaders such as HDRP/Lit:
Another new feature is that you can now select which pass you actually want to see, and log a list of valid keywords for that pass.
Changelog:
## [0.3.0-exp] - 2021-11-23
- fixed: compiles on 2021.2
- added: support for 2020.3.16+ ShaderCompiler API
- changed: preprocessing now happens on demand only for selected variants (giant shaders can now be explored!)
- added: copy/paste shader variant combinations from the breadcrumb navigation
Ohh nice that’ll be interesting to play around with
<@519636239658385605> heyo i was wondering
if this shader works with needle
also while im at it, does cinemachine work?
Hey, please ask questions about Needle Engine in <#1024686103598477383> - thanks! This channel here is about a particular package
alright sorry
Hi, I've just come across this tool, it's very useful. Unfortunately my specific problem is related to compute shader variants which doesn't seem supported. Do you think if I bodge the input to select .compute files instead of .shader it might just work? Or are the underlying unity mechanics likely to be significantly different between the two types?
Greetings, is there a shader collection which is compatible with Needle Engine? Specifically webxr image tracking unity scene. I am interested in axis based direction dissolve shader. Tried several but they didn't seem to work.
Hi, please open a question on https://forum.needle.tools for anything related Needle Engine. Thank you!