Search Unity

Unity Sunshine - A replacement for built-in shadows

Discussion in 'Made With Unity' started by PolyVector, May 30, 2013.

  1. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Sunshine has been released!
    [Asset Store] [Official Thread]


    Hey all,
    I just wanted to show off a project I've been working on called Sunshine.



    It's a replacement for the built-in shadows that come with Pro. It supports soft PCF filtering, MSAA, should work on the Ouya (haven't tested with one yet)... Has a pretty killer Volumetric Light Scattering effect... all around good stuff!

    If there's any interest, I could release it to the Asset Store...?

    To try the demo, or learn more: UnitySunshine.com
     
    Last edited: Aug 22, 2013
    XCO likes this.
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    What's the speed like vs unity pro shadows?
     
  3. Z43D

    Z43D

    Joined:
    Jan 2, 2013
    Posts:
    100
    As long as there isn't a huge performance difference, I'd love to have this :) The more eye candy the better IMO!
     
  4. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Similar settings tend to yield similar performance (2x2 PCF with post-processing disabled, since there's no built-in equivalent)... I'd say within a few fps.

    At higher resolutions, Sunshine performs much faster than built-in! This is because Sunshine doesn't use a full-screen shadow buffer pass, instead calculating shadows during the regular forward pass. This reduces the fill-rate/draw-calls and is actually the reason I developed Sunshine in the first place.

    Having comparable-to-better performance is actually pretty awesome since Sunshine is doing a lot more than the built-in shadows (Overcast shadows, radial splits, jittered cascade divisions, PCF filtering)...

    I'm actually most excited about getting this running on my Ouya (if it ever gets here) since shadows are encoded in ARGB32, they don't need "Depth" support. ;)
     
    Last edited: May 31, 2013
  5. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    This is looking real good. I'm not working on anything that could use this at the moment, but I'm definitely interested in seeing it progress.
     
  6. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    I'd buy it although I have no need for something as complex as that demo.
     
  7. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,532
    It. Is. Amazeballs.

    Interest would depend on price for nearly everyone. The lure for me is the godray's finally leaving screenspace. That alone is worth the price of the asset because someone seriously needed to do that crap already.

    There's a lot right with this package if it is as advertised. Do you simply add new light objects in place of the default ones? Are there point/omni, directional and spot options? How is it implemented - hopefully just with new Light GameObjects you create and not some custom script or shader garbage on every object.

    I'd be interested, as long as it is affordable. It's definitely an integral asset.
     
  8. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    I've always hated the Unity standard shadows, they are absolutely not on par with the rest of the system. I can't understand why they don't put hands on it.

    This looks like something that could be the next big thing.

    This said, this thing is nice, but I would only buy it if it would blend seamlessly with Unity.
    A complete replacement, I mean.

    And we must see the price. Keep in mind that if you set the bar high, you will sell some 10 copies.
    If you lower it, you will sell much more. Hundreds, maybe thousands.

    For me, I think I would buy it immediately if the price is around 50 euros. If it's up to 100 I will wait until my game is released or nearly there.

    Finally, couple of questions: works with U3.5? Works with deferred lighting?
    Great that it's already working perfectly with lightmapping, wouldn't drop lightmapping for nothing in the world (apart real time radiosity eheh).
     
  9. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Price - I want to keep it as affordable as possible, and maybe even have a free/pro version? @megmaltese 50 euros or less sounds reasonable to me.

    Light Types - Directional lighting only (hence the name), because the techniques are very specifically optimized around Orthographic projection.

    Seamlessness - As it stands, you drop a single prefab into the scene, which automatically (or manually) picks the primary Directional Light as the Sun, and registers Camera objects with the required script to make the magic happen.

    Shaders need a couple lines of code, but you can automatically change all Materials to use the Sunshine equivalent shaders(included) with a single button press.

    3.5 support - I'm only using a couple small features from 4.0 to make the Inspector interface... So I'm sure 3.5 support wouldn't be too hard to achieve if there's a need for it.

    Deferred Lighting - Currently Sunshine works with Forward rendering only. That could always change in the future though.

    Realtime Radiosity - Could be fun to look into that. ;)
     
  10. Daniel-Talis

    Daniel-Talis

    Joined:
    Dec 10, 2011
    Posts:
    425
    Does it work with Unity free?
     
  11. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Unity Pro only (it requires RenderTargets)
     
  12. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
  13. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    I'd be very interested in this for deferred rendering and some basic high performance radiosity
     
  14. silkroadgame

    silkroadgame

    Joined:
    Apr 9, 2013
    Posts:
    101
    Oh,it's looking so impressive!
     
  15. jman12

    jman12

    Joined:
    Feb 10, 2013
    Posts:
    103
    50 euros? That is a bit expensive.
     
  16. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    this looks pretty interesting. I notice in your video that the unlit areas are extremely... bright... is this just because you're using on top of a lightmapped scene? will you be able to control the shadow intensity to make the rest of the scene darker? I can't tell from the video, does it work per pixel, with lit normals, or is it per vertex? Also, how do point lights react on top of this in the same scene?

    I would love to see deferred rendering up and running, and of course radiosity... :D
     
  17. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    I'd say: Calculate the time it would take you to implement it yourself, multiply it with an "hour rate" and check back...
     
  18. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    €50 is cheap considering what the system does.
    If you include support for differed rendering i would most likely buy it for the current game im working on, Unitys shadowing is getting pretty outdated.
     
  19. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    50 euro is good if this gets constant updates and features. If it's one of those assets that gets dumped onto the asset store and forgotten about then maybe it's a little much
     
  20. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    A well working shadowing system can be pretty costly.
    That's why you don't have updates in this point in Unity since a lot of time.

    Just think on how much time coding it yourself (if you were able) would take. Debug, polish, integration, etc. You wouldn't come out with less than a couple of weeks, maybe one month, of work.

    50 euros is not really much but the count should be done on the number of copies he would sell.

    I want to invite everybody who reads here to post if they would buy it, so that the author can have a glimpse of how much he is going to sell if he sets a budget price.
     
  21. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,790
    I understand there are a lot of people coming from a lot of different viewpoints here... but 50Euros seems to be a very generous price for a system like this. Of course it remains to be seen just how useable/flexible it is for a wide range of projects, but assuming it integrates well into Unity a fair price would easily be twice this. How many copies it would / could sell is beside the point of what value do you give it personally for your own projects...
     
  22. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    I'm interested, and the price is a good price...if there are more details about how it compares to the Unity directional lighting and such. Documentation. Unity's lighting may not be the best, but it does work for most situations.
     
  23. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    There's no lightmapping in the demo... The brightness is simply due to the Ambient setting I selected.
    Edit: Now that I look at it, it is kinda bright! I must have turned that up to test something... :confused: The demo is now a bit darker if you want to check it out. :)

    Sunshine respects the "Shadow Intensity" slider on your Directional Light. :)

    It's per-pixel, and the api plays nice with normals/bump/etc. It even works nicely with custom light models in custom shaders, since only the shadow attenuation is changed.

    Just as they normally would in the Forward Renderer. Additional lights are additively blended.
     
    Last edited: May 31, 2013
  24. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    be nice if you were able to magic up a mobile version that's as fast as unity's mobile shadows, and smoother. I suspect it's possible with some workarounds... pretty much would be a sale to me.
     
  25. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    That's fine for calculating freelance work rates for items used by ONE party, but it's a really, really dumb way for pricing things for sale to the public (potentially many parties).


    The point of selling something to the public is that you spread out development costs and manufacturing costs (if applicable).
     
  26. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    He's not saying thats how to calculate how to sell something, he's saying that's how to calculate if something at its current price is any value to you. Regardless of your personal philosophy on how to price things, if you absolutely needed a lighting system like Sunshine, and you value your time at, say, 25 euros an hour... unless you think you can build it in two hours, it is of value to you.
     
  27. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    As soon as I get my Ouya, and an Android Pro license, I'm getting to work. ;)
     
  28. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327

    Don't JUST focus on mobile though :)
     
  29. user150221

    user150221

    Joined:
    Nov 10, 2012
    Posts:
    25
    @PolyVector

    I'm curious, how do you do the light scattering? It can be extremely expensive. Do you use epipolar sampling? There is some great information (including source) on the process from Intel:

    http://software.intel.com/en-us/vcsource/samples/light-scattering (Original)
    http://software.intel.com/en-us/blogs/2013/03/18/gtd-light-scattering-sample-updated (Updated)
    http://download-software.intel.com/sites/default/files/blog/379498/gdc2013-lightscattering-final.pdf (Presentation, PDF WARNING)

    Is any kind of non-homogenous participating media support planned (e.g. fog or smoke)? There seems to be some kind of media participation simulated in the lit parts of the surfaces but not in the air... looks kind of like smoke/dust. Doesn't seem nearly large or dark enough to be cloud shadows. Speaking of cloud shadows, can there be fuzzy/blurry shadows or areas that are between 0-100% shadowed, aside from the PCF filtering? Clearly at least "hard" cloud shadows are possible, by sticking cloud shapes in front of the orthographic camera. But I assume you're just generating some kind of noise to change the brightness on the surface slightly, and maybe this is configurable?

    And, similarly, what about translucency / "stained glass" effects in the light scattering? The Intel implementation manages to do so by storing a color at the sample along the surface of the translucent material. They also managed to get their implementation working for spot lights and point lights as well.
     
  30. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    @jonwd7

    The shadow cascades, and by extension the light scattering is achieved through a technique I came up with in 2009/2010 for an Xbox game I was working on called Dead Shift. I call it "Orthographic Shadow Reprojection" to sound fancy, and I don't believe it's a known technique.

    It allows me to pack the data required to traverse up to 4 shadow cascades into a single 4 component interpolator. The math is so lightweight that I can easily utilize up to 4 cascades in the pixel shader for the light scattering.

    The basic premise for the scattering is that I project the eye ray into shadow space, then I uniformly divide up the ray to sample N times. The buffer is generally lower resolution, and the starting point for sampling is jittered, so it bares a resemblance to SSAO... The buffer is then blurred with a separable gaussian (or optional radial) blur and upscaled if needed... Since light rays are generally low frequency, I think it looks pretty good, and definitely lightweight... I'd rather not get into an in-depth analysis of the tech here.

    The next step for me is to find some free time to actually get this ready for the Asset Store (a new concept to me)... I'm hoping to do a Free Version first which I'm sure everyone will enjoy, plus it will give me an opportunity to work out the kinks... Then when I'm confident it's stable/compatible, I'll release a Pro Version for sub-50-euros, as that seems to be what people expect. ;)

    Thank you all for the feedback, it's been invaluable. :)

    Edit... Non-Homogenous: Nope, but you can optionally allow the Overcast Shadows to attenuate the scattering. It's more expensive, but looks awesome! There's even an option to use a separate Overcast Texture for scattering, to create a "light dancing" effect... Basically, it's very tweakable.
     
    Last edited: Jun 1, 2013
  31. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    I hope you will try and get it to work in deferred?
    Please : D
     
  32. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    I'll definitely have fun playing with it when you release it :)
     
  33. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Any news on this?
    Looks awesome and I'm really interested in trying it out : D
     
  34. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Having this not working in deferred rendering would be a huge waste :|
     
  35. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Also noticed it wont work with point lights, but i guess its possible to use Unitys shadows for those and use this system for the "sun" and other directional lights?
     
  36. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I've been working on optimizations, and improving the quality on the Ouya. Don't worry, it's still slated for release. :)

    As for mixing with built-in shadows, I haven't tried this, but I suspect it would work since "ForwardAdd" lights have no problems..
     
  37. tabor

    tabor

    Joined:
    Nov 29, 2011
    Posts:
    42
    I'll buy for 50€ it works with deferred and forward and has a clear tutorial on how shaders would need to be modified.

    If you had a red light and a blue light crossing would their volumetrics add up?
     
  38. brilliantgames

    brilliantgames

    Joined:
    Jan 7, 2012
    Posts:
    1,937
    I take it this requires Unity pro?
     
  39. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    @tabor
    This is for a single Directional Light, so there wouldn't be multiple volumes.

    @brilliantgames
    Yes, because shadow mapping requires RenderTargets.
     
  40. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Hmm, single light you say, would it be possible to change light source during runtime to support both a sun and a moon for example?
    If that's the case and you will support deferred its probably an instant buy for me since it looks way better than the built in stuff : )
    Also, would it be possible if you could test so it works well with point lights using Unitys built in system as well?
     
  41. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    @virror
    You can switch light sources at runtime, yes. It's a simple parameter.

    I will be doing a lot of compatibility testing as I near release. :)
     
  42. RideTheT

    RideTheT

    Joined:
    Jun 11, 2012
    Posts:
    23
    Deferred lighting support would make it an instant buy for me.
     
  43. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    The initial release is pending approval. I'll investigate deferred support for an update.:)
     
  44. kenli

    kenli

    Joined:
    May 20, 2013
    Posts:
    6
    This look interesting.

    Keep this good work! :)
     
  45. ShadyAlien

    ShadyAlien

    Joined:
    Aug 28, 2009
    Posts:
    210
    Beautiful. Can't wait to try it out.
     
  46. dahrrr

    dahrrr

    Joined:
    Jun 4, 2012
    Posts:
    52
    How about compare this with unity 4.2 shadows ? Is it have shadows static/dynamic batching?

    System use normal deferred light or I need to rebuild my scripts to get into parameters?
     
  47. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    As soon as I get paid I'm getting this (I currently only have 50p in my account lol)
     
  48. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    @Chaoss

    I know how that is. ;)

    Let me know what you think if you pick up a copy!
     
  49. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I probably should have made an official announcement here... So here goes:

    Sunshine has been released!
    [Asset Store] [Official Thread]
     
  50. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    May I trouble you for another web player demo where we can control the player rather than an on-rails demo?