Re: [Feature request] Posterization effect
Posted: Sat May 09, 2020 5:30 pm
Thanks mate
I spent most of the day trying to optimize it further, but it's hard! Shaders really don't like branching (and do like unrolling), and the non-trivial k-d tree algorithm is all about decimating a search tree...
The best I managed so far is to increase k-d tree depth by one, going from 8 leaf functions to 16, and consequently to usually test 18 colors instead of 36. But ShaderCompiler takes ages, the Unity Editor complains about some timeout after 600s, the shader eventually compiles anyway and works perfectly. Not sure it's too safe though
All attempts to speed up compilation resulted in either no change (the optimizing compiler undoing all my modifications) or code that doesn't compile (if I try to handle my own stack, the compiler complains it can't unroll my main loop).
Unless somebody comes with a totally new approach I guess it'll stay as-is... in any case, I'm learning about shaders...
And now I understand why barely anybody tried such insane idea (only a few using the naive approach on shadertoy)
I spent most of the day trying to optimize it further, but it's hard! Shaders really don't like branching (and do like unrolling), and the non-trivial k-d tree algorithm is all about decimating a search tree...
The best I managed so far is to increase k-d tree depth by one, going from 8 leaf functions to 16, and consequently to usually test 18 colors instead of 36. But ShaderCompiler takes ages, the Unity Editor complains about some timeout after 600s, the shader eventually compiles anyway and works perfectly. Not sure it's too safe though
All attempts to speed up compilation resulted in either no change (the optimizing compiler undoing all my modifications) or code that doesn't compile (if I try to handle my own stack, the compiler complains it can't unroll my main loop).
Unless somebody comes with a totally new approach I guess it'll stay as-is... in any case, I'm learning about shaders...
And now I understand why barely anybody tried such insane idea (only a few using the naive approach on shadertoy)