Hey PC,
I've done a handful of god's rays in previous (Unity based) games, but was never sure if I was approaching it in the smartest way.
In the past, I made a simple gradient in a cone shape in Photoshop, then softened the edges and saved it out as a PNG with transparency before tossing it in game and putting something like an additive particle shader on it.
Are there better ways of going about this that you've found, or will sticking to a plane with alpha on it work out fairly well in most situations?
Thanks so much!
Replies
I've talked with the graphics programmers when they've implemented systems like this, so I could get suitable controls for the effect... brightness, color, falloff, shadow sampling frequency, etc. Then the game would dynamically generate it whenever the camera is looking at the sun.
Take a good look at how UDK and CryEngine do it, those are dynamic solutions.
It's a shader a lot like a blur, but it's a directional blur away from the light source. You can also throw down a sprite quad over the sun's position for a halo/corona effect as well.
But if you're using a version of Unity without post processing, a plain corona as a sprite is good. Your way of doing it is good. You can also make an actual cone geometry (or other shape matching the rays) and apply a gradient to it. If you use a Fresnel alpha fade shader, you don't see hard edges where the cone ends.