Wednesday, 20 May 2015

The quest for the perfect gradient.

I often have to create linear or radial gradients to use as masks or UV input. I’ve always created them in photoshop using the gradient tool and I’ve always been frustrated by the fact that you cannot place them numerically.
Today I’m rolling up my sleeves and I’m going to sort this out instead of grumbling internally.

This might seem a bit extreme but this sort of issue gets on my nerves if I encounter them every single time.

Case study 1: Photoshop and the gradient tool.


My problem is: I’m eyeballing it. The snapping doesn’t work on the gradient tool so I have to use the grid or some guides and zoom in as much as possible to try and be accurate but I cannot guarantee I’m not a couple of pixels off.

I can prove myself it’s not perfect however. It’s subtle but look at the gif below (yes it’s animated I promise). I’ve flipped the ramp horizontally and vertically, and you can see it jump back and forth a few pixels. I’m not happy.








Case study 2: Photoshop again


I asked our UI guy for advice and he uses layer styles to create gradients.



Nice one. It’s editable, you can modify it at will and the align with layer makes it clean and fully accurate.
But hang on, what does the flipping test tell us? Dammit! Still not perfect!




Case study 3: Illustrator


I normally have a thing for illustrator, just like after effects. All that numerically placing everything and oh my, those smart guides… They’re just heaven.
But in this case Illustrator the Great disappointed me. The gradient tool is very neat, the UI is clear, contextual just where need be and super clever as usual but the smart guides don’t work with it. Shame on you Illustrator. I just have to leave you there.
(I still appreciate that your gradient can be either edited numerically in the gradient window or intuitively on the fly with the mouse cursor.)



Case study 4: After effects


Aaah, shape layers. What a bliss.
The gradient fill won’t disappoint you. The shape layer path will define the bounds, you can tweak the start / end positions on top of it using the well-named start and end options, and the whole gradient is editable.



Yet there again, the flipping test shows that the gradient is not perfectly centred. I’m starting to see a pattern here. Could it be I am asking for the moon?




Case study 5: Substance


I'm lucky enough to know a beta tester so I was able to quickly try it in substance. I definitely want to spend more time with substance which looks mind blowing but I’m still very limited with using it right now.
Using the Tile_generator with a paraboloid pattern type I was able to create a radial gradient. I have no control over the shape of the gradient with that option. There are obviously much better ways of doing it but that was the easiest way to test quickly it. 

 
And you know what ? It flips perfectly. Tadaaa.


Conclusion.                                                                           

 I thought about it for a second and it hit me. I always work with power of two textures. If I’ve got a 128*128 texture, surely that’s great caus’ my centre is at 0. Yeah but no. With any adobe method, it looks like the gradient won’t start in between two pixels. It needs a pixel to use as a centre, it seems. I tried it on a 129*129 square and the flipping would leave the gradient unchanged.
I suppose substance handled it better because the creation of the gradient comes from maths rather than a tool.



Epilogue.

Unfortunately, substance isn't part of my day-to-day workflow. I hope it will some day.
I currently go with the Photoshop gradient overlay layer styles for all my gradients. If I use the gradient tool to create a gradient and want to modify it months later but I've forgotten to save it, then I'm screwed and I have to try and recreate it. The layer styles mean my gradient always remains editable.