Home Technical Talk

God's Rays 101

polycounter lvl 7
Offline / Send Message
KateC polycounter lvl 7
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

  • Eric Chadwick
    Options
    Offline / Send Message
    I've done godrays recently with custom game rendering tech. This way it's dynamic and reacts to clouds passing in front of the sun, trees occluding the sun, etc. I've also done it your method, but that's harder to control.

    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.
  • Kurt Russell Fan Club
    Options
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    God rays post process shaders are good, like the one in BlackLight: http://i.imgur.com/KFvyP.jpg

    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.
  • KateC
    Options
    Offline / Send Message
    KateC polycounter lvl 7
    Thanks for this, I wasn't sure of the options out there, and it's hard to do any decent research without a solid starting point. Appreciated!
Sign In or Register to comment.