Search Unity

Sunshine! - Official Thread

Discussion in 'Assets and Asset Store' started by PolyVector, Aug 1, 2013.

  1. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Well I specify Ouya/Nexus because they Unity doesn't implement shadows on those platforms, so it's a good way to get shadows there... I'll look into picking up some other androids for testing some time. I'd really like to get the "slow loading" issue sorted out as well.
     
  2. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    i think your nexus 7 2013 has an adreno 320, so i havent gotten any error reports from nexus 7 or nexus 4, which tells me its something to do with the drivers in galaxy s4 =/
     
  3. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    also, the issue might not be with sunshine at all, so he can call it android compatible until the issue arrises and then he can just fix it if it was broken
     
  4. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    @tripknotix

    Yeah, I was reading the hardware specs and they're quite similar. You may very well be right that it's a driver issue, especially considering it's a relatively new chipset.
     
  5. Deleted User

    Deleted User

    Guest

    Hi,

    so just to make sure before I buy it:

    - With Deferred Lighting, shadows will also work with complex customs shaders like Marmoset Skyhop, Relief Shaders (by Tom), Tree Creator shaders etc. without any manual modifications whatsoever? Also the terrain material doesn't have to be modified?

    - I am working on a medium to large outdoor scene (2km * 2km terrain) and the builtin directional soft shadows are flickering like crazy even as near as 30m-40m away from the first person camera. My quality settings are set to "Fantastic" and the shadow resolution to "Very High". Do the Sunshine shadows also suffer from this kind of flickering or do they completely eliminate it no matter how far from the camera?

    Thanks!
    Sean
     
  6. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Deferred Renderer - You shouldn't shouldn't need any shader modification or additional effort. The shadows themselves are applied during a fullscreen pass, and the Light Rays are regular post-processing, so they should work with anything you can throw at them (terrain/trees/shader packs). This also applies to Light Scatter in both Deferred or Forward renderers. Forward Shadows are the only feature of Sunshine requiring "work". ;)

    A current limitation to be aware of is the inability to disable Shadow Receivers in the Deferred Renderer, so everything will receive shadows.

    I'd need more clarification on what you mean by flickering specifically, but I'll go over some issues/artifacts of both systems:

    Sunshine shadows are better at...
    • Quantizing - If you mean that random shadow texels are turning On/Off rapidly as the camera moves, this is a quantizing issue. Both systems attempt to stabilize everything as the camera moves. For built-in you must set the shadows to "Stable", but Sunshine always does it this way... I think the floating point accuracy of both systems is comparable, but I've added some temporal tricks in Sunshine to reduce the flickering as far as possible.
    • Screen-Space Noise - Sunshine does no screenspace filtering whatsoever, so you won't see that noisy "swimming" effect.
    • Camera Spinning - Sunshine fades the shadows out radially, so you can spin the camera while maintaining a stable shadow distance... With built-in you'll see the shadows pull in/out which can look pretty bad on things like buildings.
    • Resolution - You'll get approximately the same shadow resolutions with Sunshine as with Built-in, only you'll have much more control with Sunshine... The ability to specify an exact resolution, or where cascades are split for example. Also, PCF shadows tend to appear as though they are higher resolution. ;)
    • Penumbra Uniformity - Zoom your camera in close to a shadow edge with built-in, and you'll see it become pixelated... Sunshine will maintain a the same smoothness no matter how close you view shadows.
    Built-in shadows are better at...
    • Terrain Pop-In - The Terrain system is a black box, so there are some LOD shadow artifacts if you require Terrain to cast shadows with Sunshine. I'm not sure how this works with built-in shadows specifically (high bias?), but I don't have control over specific LOD patches to make shadows uniform...
    • Shadow Acne - If you're not familiar with this artifact, google some images. The built-in takes a single shadow sample, and blurs it in screen space, so you rarely see any acne... Sunshine performs up to 4x4PCF, which will increase visible acne. It can be corrected by adjusting the Shadow Bias, but of course that comes with the risk of "peter panning".
    I hope this helps you make your decision. :)
     
    Last edited: Sep 18, 2013
  7. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hey guys,
    I'm looking into the "slow loading" problem some of you have reported on mobile devices.

    I've put together a small experiment (based on the Android Robot demo) that reports how long a few things take to load... If you could download it and let me know what values you get on a particular device, that would be helpful.

    Here's the TEST

    Here's what I get:

    It appears that the initialization is taking the bulk of the time, which makes sense since shaders need warming, and buffers need allocating... That, or LoadLevel() isn't blocking. ;)

    Let me know what numbers you get! :)
     
    Last edited: Sep 19, 2013
  8. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    Hello PolyVector, I was looking at your demo and I noticed something that doesn't look right. as the camera is moving around the room the lights shining on the floor seem to moving too, but the light in the sky or whatever is still, or is it moving?

    Edit: to be more accurate, I mean the volumetric part of the light.
     
    Last edited: Sep 19, 2013
  9. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    You mean the load time test I just linked to or the official demo on the site?

    If it's the demo...
    The light should be still, but you can rotate it with a controller on the Ouya.
    The Shadows and light rays should be subtly moving because of the tree's movement.

    If you mean the volumetric light is getting stuck, what device are you using?
     
  10. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
  11. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Whoah, that's embarassing! :confused:

    So if you left-click and drag, the shadows spin around, but the light scatter stays frozen on the screen?

    What OS are you running? Is the webplayer up to date?

    Edit: I just booted into Windows, and see the problem... Looks like the UV is flipped! Oops! I'll look into this immediately! :oops:
     
    Last edited: Sep 19, 2013
  12. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    All fixed! I'll try to submit an update today...

    The problem was happening because _MainTex is nulled out in some situations when it isn't needed, but the UV flipping data is tied to that buffer. Guess none of my beta testers were running Windows. ;)
     
  13. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Version 1.4.1 has been submitted, and it should take care of the bug (The Webplayer has been updated as well)

    Thanks so much for pointing that out, MoHoe. It just might explain the sudden drop in new users. *facepalm*
     
  14. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    That's great you fixed it so fast :)

    " It just might explain the sudden drop in new users. *facepalm* "

    maybe thats reason for the drop in sales, that was the main reason stopping me from purchasing.

    Anyway, keep up the great work :)
     
    Last edited: Sep 19, 2013
  15. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Embarrassment is a powerful motivator!

    Thanks again for pointing that out, I'm sure the fix will make it's way through the sausage factory by early next week. ;)
     
  16. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Hurray, Deferred shadow support : D
    Will most likely pick this up soon.
    You said there were some problems with the terrain shadows, how bad are they? Any screen to show the problem?
     
  17. Skunkie

    Skunkie

    Joined:
    Jul 2, 2012
    Posts:
    75
    Sunshine 1.4.1 has hit the asset store!

    • Fixed Scatter impropperly flipped on Windows in some situations.

    Sorry about that guys!
     
  18. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    It mostly happens when the light hits different LOD's at a grazing creating false shadows. If you don't allow terrain to cast a shadow there is no issue at all. I'll try to get a screenshot of the problem for ya. :)

    Edit: Screenshots Sent!
     
    Last edited: Sep 20, 2013
  19. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    I'm very interested in this but it's out of my price range right now. Any idea if there's a sale price to be had in the near future I'll pick it up? Thanks
     
  20. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    None planned at the moment, but I'll probably schedule something after I see how or first sale goes with Shadow Softener.
     
  21. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    Hello PolyVector,

    Have you implemented Shadow softener into Sunshine plugin?
     
  22. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    They are two very different systems.

    Sunshine - A shadow system completely separate from the built-in.
    Shadow Softener - Customized filtering for the built-in shadows.

    That said, they can technically be combined, if you only use Sunshine's Scatter effect, and use Shadow Softener to augment the built-in shadows... I don't recommend this (unless you use Shadow Softener sparingly), since both Sunshine and the Built-in shadows create their own shadowmaps and that's not optimal. If you need PCF filtering, and Scatter, it's best to stick with Sunshine-only. ;)
     
  23. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    OK thanks. What drawcalls do your shadows create, is it much the same as unity shadows? Could you compare the 2 please?
     
  24. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    There's no clearcut answer. Sunshine avoids the Shadow Collector pass, but I believe the built-in utilizes better batching than is exposed to users. They're just different.

    I ran some tests on the "Sponza Demo" scene...

    With Baked Occlusion Culling + Static/Dynamic Batching:
    Built-In: 302 Draw Calls
    Sunshine: 300 Draw Calls

    Without Baked Occlusion Culling + Static/Dynamic Batching:
    Built-In: 440 Draw Calls
    Sunshine: 404 Draw Calls

    All batching/culling disabled (I was curious):
    Built-In: 1390 Draw Calls
    Sunshine: 1093 Draw Calls

    I think this shows that the built-in shadows recieve an unfair advantage from their improved batching... If they ever bring that optimization to Camera.DrawWithShader(), Sunshine will probably beat the Built-in shadows in terms of draw calls every time...
     
    Last edited: Sep 27, 2013
  25. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Thanks. What were the scenes drawcalls without shadows at all?
     
  26. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Ran it again (it varies of course depending on the camera position where I paused)

    No Occlusion Culling, with Static/Dynamic Batching:
    No Shadows: 382
    Built-In: 436
    Sunshine: 430
     
  27. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Thanks :)
     
  28. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    if you turn on sunshine, then remove it from the scene, you still get the high draw calls, any idea what that might be from? did it break batching, or is it just shadow residue?
     
  29. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Well, I assume the built-in shadows take over, which results in similar drawcalls. Sunshine can't possibly be initiating drawcalls if it's not in the scene. ;)

    You might not be allowing the dynamic batching enough time to catch up, since it supposedly works over multiple frames (which may require clicking around if the game isn't running).
     
  30. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    i have a button to add the prefab with sunshine, then i remove that prefab. the camera comes with its components when the scene starts ofcourse.
     
  31. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    It should be smart enough to do nothing when the Prefab isn't there.
     
  32. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    sadly , polyvector, i can confirm the issue with crashing on galaxy s4, htc one, lg optimus g, and sony z1, as well as a number of other devices using qualcomm quad core devices with adreno 320 and adreno 330.

    Pretty much every top class android device is crashing when using sunshine, i can confirm however, that it happens with the post effects. im not sure which of the 2 plugins that are on the camera cause the crash, but its 1 of those or both of those.

    i really wish i had a device to test and send you a log, but i've been spending quite a lot on assets this month that i cant just go buy one to test with =X

    please fix this, its by far the best plugin ive ever added, and it makes my game look AAA =)

    as far as my research goes, theres a few things i know crash the cpu/gpu from those devices. lowp and gllinkprogram in shaders, try/catch in classes and certain forms of "array use" in shaders.

    good luck
     
  33. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    If lowp is the source of the problem, you might try commenting out this line in Sunshine.cginc:

    Code (csharp):
    1. //#define SUNSHINE_LOW_PRECISION
    Edit: You will need to force Unity to reimport your shaders, since it doesn't do this automatically!

    If that solves the crashing, I'll take out all the lowp "xfloat" code in future versions... I had this as an optimization for mobile, but if it's not stable, there's no point! :eek:
     
  34. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    so according to my testers, looks like that fixed it. interesting that it was that simple =)
     
  35. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thank you very much for testing this, I would have never guessed that lowp would crash such common devices...

    It's quite strange, especially considering that lowering precision is probably the most common shader optimization for mobile devices... I've read a number of presentations from chipset makers recommending it, so I simply assumed it was reliable...

    I'll be taking the lower precision (and xfloat madness) out of the next release... Pfffft. :roll:
     
  36. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    im sure it is the best choice polyvector, its just a simple bug that needs to be addressed by unity or samsung, not sure who, its possibly a combination of low precision with something else. that causes it, but so far, even the old mobile bloom shader going around the forums has the same issue on galaxy s4
     
  37. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Not much you can do about wonky drivers I suppose. At least stripping the lowp stuff out will simplify the codebase a little. ;)
     
  38. CoastKid

    CoastKid

    Joined:
    Jan 8, 2013
    Posts:
    64
    Hello PolyVector,

    Is it possible to get access to your SunShine's shadow maps in custom shaders?

    For example: I'm using Deferred rendering and I need to implement shadows receiving by particles with shader that used alpha blending or additive blending, built-in shadows doesn't allowed to do so, because I can't access the maps to replicate the custom shadow pipeline inside of my transparent shader.
    Does "SunShine" allow this? Or maybe you already have some examples of transparent shadow receiving shaders?

    Edit: I just read Feature List on Sunshine site, so I found that your system support alpha receivers, hope that means that alpha receivers works in Deferred rendering, am I right?
     
    Last edited: Oct 16, 2013
  39. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    They should work, but to be honest I hadn't thought of trying forward/alpha receivers in the Deferred renderer! I'll experiment with this to verify it's possible and get back to you. :)
     
  40. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    It looks like everything works!

    The transparent shaders that come with Sunshine receive shadows just fine as long as you leave the "Alpha Receivers" option checked. ;)

    Edit: Forgot to mention that yes, custom shaders are fully supported. I recommend reading through (the documentation) to learn more.
     
    Last edited: Oct 16, 2013
  41. CoastKid

    CoastKid

    Joined:
    Jan 8, 2013
    Posts:
    64
    Thanks for answers PolyVector!

    I have another question about Sunshine: Does shadows works correct with Reflected/Mirrors cameras, for example with water reflections?
     
  42. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Another interesting question!

    Well it deffinately works with multiple cameras (split screen, etc), but I haven't tried with a camera that manually calls Camera.Render(). According to the docs, all the events such as OnPreCull() are sent when using Camera.Render() so I'm fairly certain it would work. :)

    You would need to make sure that SunshineCamera is attached to the reflection camera. You'd likely have to do this in the script that sets up the camera, but that shouldn't be too tricky.
     
  43. Skunkie

    Skunkie

    Joined:
    Jul 2, 2012
    Posts:
    75
    Going to be a tiny bit annoying and post some cross promotion for our other asset.

    Shadow Softener is 70% off in today's Asset Store Daily Deal!

    That's right guys! This is the first time we've offered one of our assets for sale and we're hoping everyone can get in on it. We'll do our best to be available to answer questions and don't forget to check out the documentation!

    Go get it!
     
  44. Don-Gray

    Don-Gray

    Joined:
    Mar 18, 2009
    Posts:
    2,278
    Gettin' it now!
     
  45. TobiasB

    TobiasB

    Joined:
    Jul 4, 2013
    Posts:
    4
    Runs for 2 seconds (you just get to see the Robot with shadows on and the camera zooming in a bit) and then crashes on my Galaxy Nexus...

    Kind regards, Tobias Biehl
     
  46. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thanks for letting me know. Can anybody else with a Galaxy Nexus confirm this?
     
  47. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    I can tell you it crashes 2 or 3 times on my Tmobile G2 (800mhz 512mb of ram, android 2.3.4) qualcomm snapdragon. But i was able to see the shadows when it did run.

    I'm pretty sure it was because of the trees high poly count in some way or another.
     
  48. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Was this always the case, or is this a recent problem? I updated the demo early this week after taking out the "lowp" code that was reportedly crashing some devices, so I figured it would be more compatible now.

    Edit: I'm running it right now on my Nexus 7 2013 (also a snapdragon) and I can't get it to crash.
     
    Last edited: Oct 18, 2013
  49. tripknotix

    tripknotix

    Joined:
    Apr 21, 2011
    Posts:
    744
    it was always the case, its just an old phone, this phone has trouble with many trees, let alone 1 tree with really nice shadows =P , it could just be the polygon count or the shaders who knows, its a single core 800mhz, yours is a far newer and better cpu poly, i wouldnt worry about it
     
  50. Skunkie

    Skunkie

    Joined:
    Jul 2, 2012
    Posts:
    75
    Sunshine 1.4.3 has been released!

    • Fixed Alpha Shader compatibility in Unity 4.3