Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Sunshine! - Official Thread

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

  1. Jorge_Dantaz

    Jorge_Dantaz

    Joined:
    Mar 8, 2014
    Posts:
    3
    Hey is that compatible with Unistorm?:confused:
     
  2. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    We've actually talked about merging the two eventually... I think most Sunshine users primarily want the Light Rays(?), and Shadow Softener is easier to integrate, and more compatible... I might need to take a poll to see what people are actually using Sunshine for.

    I can't see why not, although I've never used Unistorm before. If you run into trouble I'm here to help. :)
     
  3. XilenceX

    XilenceX

    Joined:
    Jun 16, 2013
    Posts:
    122
    Oh that would be awesome! :) ShaderForge+Sunshine would be a powerfull combination to get the most out of Unity.
     
  4. Salmonela

    Salmonela

    Joined:
    Mar 9, 2014
    Posts:
    4
    Indeed it would.
     
  5. Dantas

    Dantas

    Joined:
    Mar 9, 2014
    Posts:
    28
    Hope you do that, since Shaderforge is the best shader solution for Unity atm.
     
  6. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I'm hoping to have some free time after GDC to look into this possibility. :)
     
  7. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    PolyVector, I found time this weekend to research the issue with shadows not being cast on drawmesh objects, and was able to create a small project to duplicate the issues.

    I'm attaching a small package. In it, there is a simple plant-thing which shows up in the scene as a gameobject.
    When you run it, you will see another on that is there because of DrawMesh. However, when you enable sunshine, it no longer shows shadows on the 2nd plant.

    In the player camera, you can see the postprocess script will not enable, but the camera script will. I'm not sure what is going on there, but maybe this has something to do with sunshine correctly identifying the camera.

    So...yeah, I think this has to do with sunshine and the player attached camera, rather than using DrawMesh.

    Here is the link to my dropbox folder:

    https://dl.dropboxusercontent.com/u/174731243/SunshadowsOnDrawMesh.unitypackage
     
  8. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hi jc_lvngstn,

    I'm so sorry, I didn't know you were still having this problem! For some reason I remembered it being resolved *facepalm*.

    The issue is simply that you're specifying a camera to draw the mesh into:
    Code (csharp):
    1. Graphics.DrawMesh(PlantMesh, transform.position, transform.rotation, PlantMaterial, 0, Camera.main);
    You want to draw the mesh with any camera that can see it (including Sunshine's Shadow Cameras). This change fixes the issue:
    Code (csharp):
    1. Graphics.DrawMesh(PlantMesh, transform.position, transform.rotation, PlantMaterial, 0);
    If you need to mask the mesh from particular cameras you could use the LayerMask parameter.

    Hope that helps! :)
     
  9. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    Good gracious, what a simple fix! Thank you!
     
  10. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hehe, no problem! :)
     
  11. Winterspree

    Winterspree

    Joined:
    Jan 8, 2013
    Posts:
    4
    Hi and thanks for a great product in Sunshine!

    I was tweaking around with it for our current game, and we get some results we really like. However, we are also getting performance issues that we don't like.

    We are working with quite an epic envrionment, resulting in large meshes, such as mountains and the likes, and a long render distance. To not get weird shadow issues (which change regarding to the cameras rotation) we pulled the "Padding Z" up, which works very well. However, that's when we get performance issues from the light scatter.

    So, when our character is completly in shadow (and no light scatter can be seen on the screen) from sources far away, we get a severe stuttering effect. Is there any way to work around this or do we have to look into how we have built our scene to be able to use Sunshine! ?
     
  12. venain

    venain

    Joined:
    Aug 10, 2013
    Posts:
    6
    Has anyone here tried using Sunshine! in tandem with skyshop and tc particles? It seems no matter what I do, I will get the following error spammed a billion times per second

    "Maximum number (64) of shader keywords exceeded"

    If anyones ever encountered this and has a workaround, I'd love to hear it!
     
  13. Winterspree

    Winterspree

    Joined:
    Jan 8, 2013
    Posts:
    4
    I tweaked on with the settings and finally got it to work together with some other adjustments. Just so that you know! Thanks again for a really pretty system.
     
  14. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I've never seen Sunshine/Scatter cause stuttering like this. When you disable Scatter does the stuttering stop?

    EDIT: Are you updating the shadowmap every other frame?

    Scatter is the most expensive part of Sunshine, so you might consider running it at half resolution, or lower sample quality... The next release will feature an improved dithered sample-pattern that will allow smoother rays with lower sampling quality.

    As far as general performance recommendations:

    • Place objects that don't need to cast shadows on a separate layer so that you can mask them off in Sunshine's settings.
    • Use as few cascades as possible. Remember, you can adjust the cascade spacing to make better use of them.
    • Make sure you aren't using Sunshine shaders in the Deferred renderer (unless they are specifically forward rendered shaders). This can result in double the shadow calculations.

    If you disable Scatter for a more direct comparison with built-in shadows, I've noticed that Sunshine tends to win at higher resolutions, but built-in can win at lower resolutions. They're just different, so sometimes it takes experimenting to see how to best optimize.

    This is something I plan to address in the next release by eliminating quite a few keywords. The problem is that Unity counts every #pragma multi_compile KeywordA KeywordB line in every shader in your project! Even if you aren't using a shader, those keywords contribute to the overall limit of 64. One simple solution is to remove any unused shaders that multi_compile from your project.
     
    Last edited: Mar 16, 2014
  15. venain

    venain

    Joined:
    Aug 10, 2013
    Posts:
    6
    Ah I see, thanks for the info! I'd love to use sunshine! in my project so I'm looking forward to that release:) Thanks for the awesome asset!
     
  16. RomanLov

    RomanLov

    Joined:
    May 5, 2013
    Posts:
    5
    Can someone answer me please? What fps i'll have with 100 dynamic objects with this shadow technic on mobile like Tegra 3? Or, better way, i ready to buy it, if demo scene "Robot Sunshine" will have 50-100 robots with shadows and it will work fine on android 4.x.
    Many Thanks
     
  17. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    There are so many factors like polycount, scene/shader complexity, etc. For example, the Robot Scene with 50-100 robots would probably grind to a crawl with or without Sunshine.

    That said, there are many provisions included for keeping performance reasonable on mobile, like not updating the shadowmap every frame, custom shadowmap resolution, etc. If you buy it and it doesn't work out for whatever reason I'll get you a refund, so no worries. :)
     
  18. negativecap

    negativecap

    Joined:
    Jan 27, 2013
    Posts:
    99
    Excited about this, as it's hard to use sunshine with other shader packages at this point w/o deleting a lot of shaders. Any idea on the time frame?

     
  19. RomanLov

    RomanLov

    Joined:
    May 5, 2013
    Posts:
    5
    In my current project (when camera see 90-100 objects) i have:
    - about 400-500k tris
    - about 300-400 drawcalls
    - fps about 30-40;

    and it work fine with realtime shadows on samsung note 2, but on devices with tegra shadows not working.
    if i will add your shadows to these 90-100 units, how will it affect fps, approx (when update shadowmap once at 5-10 frames)?
     
  20. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I've been crazy busy working with The Forest guys the last couple months, and we're going to GDC this week... So that's why updates have been delayed for so long. I'm really hoping that next week I'll be able to get back to work on our projects, so maybe in the next few weeks you'll see an update, but no promises just yet. ;)
     
  21. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    If you only update the shadowmap every 5-10 frames (or simply when the camera moves X distance) you might be okay. Any guess as to FPS I could offer would be just that. The best thing for mobile performance that I've found is to limit the fillrate... so limit the number of shadow casters, the shadow resolution/distance, the update frequency, and use Hard Shadows if possible. Tegra 3 is very limited, but it's possible to get shadows working if you're careful.
     
  22. Deleted User

    Deleted User

    Guest

    I also get this "Maximum number (64) of shader keywords exceeded" error when I try to use Sunshine with Skyshop shaders and a couple of custom ones. Can you be a bit more specific about how to solve this? How do I know which shaders use multi_compile? Do I have to check all their code? What If I found one, should I just remove this single "multi_compile" line? And what if there aren't any shaders I can remove? Can I ditch Sunshine then? Many questions...

    Sean
     
  23. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Yes, you'd have to look at shader code to find multi_compile lines, but that's what the Search Solution feature is good for in MonoDevelop (or VS). :)

    If you aren't experienced, I would caution against removing shader permutations, this is why I recommended simply removing any shaders you aren't using that use multi_compile.

    If you ditch Sunshine, that will save you keywords just like any other set of shaders using them. Like I said though, I'm going to reduce keyword usage in the next update.
     
  24. Deleted User

    Deleted User

    Guest

    What if I only use 3 or 4 shader types in my game, can't I just manually add the Sunshine code in the 3 or 4 shader files and in this way not run into the keywords issue?
     
  25. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Forward rendered shadows all use the same keywords for PCF filters (so if even one exists, those keyword slots are used up). You could probably delete the Scatter and Blur shaders in Sunshine/Core/ if you aren't using the Scatter effect and save some keywords.
     
  26. Deleted User

    Deleted User

    Guest


    I will try that later.
    When will the update come out?
     
  27. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    It's ready when it's ready. :)
     
  28. Deleted User

    Deleted User

    Guest

    Great to see you so super relaxed about it. Sorry if I can't share your humor. I paid $95 for your lovely plugin and it's not working. Apparently because you weren't very economical with keywords. So please just tell me when approx the next update is gonna be. I am a huge fan of actually USING the plugins I bought.
     
  29. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I've pointed you in the right direction and promised to address the issue as soon as I can. That's the best I can do, so let's keep things positive here. I'm working full time and traveling to GDC this week, and as soon as I get a free minute I'll be hard at work on it.

    The Shader Keyword system is intended to be used, and while Sunshine could stand to use less of them, the majority of keywords in your project come from other shaders.
     
  30. Skunkie

    Skunkie

    Joined:
    Jul 2, 2012
    Posts:
    75
    For the rest of the week PolyVector and I are going to be at GDC!

    Unfortunately that means we’re not going to be available for support until next week. So hang tight!

    If you’re going to be at GDC, don’t be afraid to say hi out on the expo floor. You can find us on the official GDC app and I’ll be posting all our antics on Twitter.
     
  31. Deleted User

    Deleted User

    Guest

    Saying "It's ready when it's ready" neither implies that you promise to address the issue as soon as you can nor that you will be hard at work on it as soon as you get a free minute.

    I hope you keep your promise.
     
  32. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Flattery will get you nowhere. ;)

    Here is what I was considering a promise:
    If you aren't happy then please just ask for your money back, this isn't productive.
     
  33. Deleted User

    Deleted User

    Guest

    Just do your job pls. I will decide when and if to ask my money back. And work on your attitude towards customers. You are a little too laid back in the way you communicate with your customers. After all you are selling quite a pricey asset here.
    Anyhow, let's stop it here.
     
  34. Psimoh

    Psimoh

    Joined:
    Apr 12, 2013
    Posts:
    22
    Hi, I hope you're enjoying GDC!

    I'm enjoying Sunshine. I have a request. I'm developing on Ouya and I need a Sunshine compatible shader for my environment. I have a fixed camera above the scene looking down so I can pre-bake my lighting for maximum fidelity. I'm using Sunshine for real-time shadows for my characters so my pre-baked terrain does not need to be lit, as such, but it needs to receive those shadows from Sunshine. So I need an unlit shader, so there is no lambert or blinn-phong lighting calculated or shading the terrain. However, I do understand that Sunshine works by calculating direction from the lighting. So is what I'm requesting even possible?
    I'm relatively new to shader coding so my attempts at writing my own based on your examples are less than optimal. Some guidance would be greatly appreciated.

    Thanks!
     
  35. TenTickles

    TenTickles

    Joined:
    Nov 17, 2012
    Posts:
    10
    This + any potential ShaderForge integrations for Sunshine sound very appealing indeed :)
     
  36. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    We really enjoyed it, GDC was an incredible experience! :)

    Sunshine is designed to work with Lightmaps, I just tested the stock Sunshine/Mobile/Diffuse shader with lightmaps and it appears to blend realtime shadows in the same way as built-in. Perhaps it's the particular shader(s) you're using for terrain. If you PM me a small scene I'll be happy to take a look and try to sort out any issues. :)

    Agreed! I haven't had a chance to work with ShaderForge and see if it's actually possible though. I know that there are "Custom Lighting Nodes", but am unsure of how flexible they are. The next version is going to be a pretty big overhaul, I would love to see it become easier to use with tools like Shader Forge!
     
  37. Psimoh

    Psimoh

    Joined:
    Apr 12, 2013
    Posts:
    22
    Thanks! I've just PMd you with a shader I've hacked together. If you wouldn't mind checking it for sanity I'd be very grateful.
     
  38. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384
    Hey Oren!

    Do you happen to be in the Unity 5 Alpha/Beta? I'm curious about compatibility for launch day.
     
  39. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    The Forest team and I have been trying to get an early copy, but no luck so far. ;)
    I'm really hoping that Unity 5 will open up some new possibilities for Sunshine, especially with the physical shaders and GI solutions. Only time will tell though.

    A quick progress update for those waiting on the next Sunshine version:
    The next version is a pretty big overhaul, which is why I can't simply toss it up on the Asset Store. I apologize for the delay, but I'm working full time on The Forest until May 22nd, which really only leaves nights and weekends for Sunshine. I'm hoping to finish up the next version in the coming weeks and get it in your hands as soon as possible!

    Thank you all for your patience.
     
  40. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384
    Absolutely, appears to be a lot of potential. I'm trying to aggregate potential big issues and given how integral Sunshine is in the project any step changes on your end that I would have to compensate for would be good to know of ahead of time. =)

    Btw, awesome work on The Forest, all the videos I see of it are totally juicy.
     
  41. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thanks! The Forest team is insanely talented, it's been an adventure working with them. :)

    I don't think the new version will have any breaking changes (mostly fixing changes, hehe), but you may have to tweak some settings... nothing major.
     
  42. Deleted User

    Deleted User

    Guest

    Hey guys! :) Now this asset looks bad-ass, allright!

    But here is a weird and probably dumb newbie question (sorry about that): does Sunshine work with an isometric camera? Just from the technical side, aside from whether or not it would be useful for an isometric game from the designer´s point of view.
     
  43. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I never thought about using an isometric/orthographic camera before. I'm going to have to say no, I don't think it works with non-perspective cameras due to the way rays are calculated in the vertex shader.. If this is something there's demand for, I can look into adding support.
     
  44. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    While we are waiting, can you give an idea of what the new overhaul changes will be?

    Cheers.
     
  45. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,457
    While we are waiting, can you give an idea of what the new overhaul changes will be?

    Cheers.
     
  46. Psimoh

    Psimoh

    Joined:
    Apr 12, 2013
    Posts:
    22
    Well, it works for me. I'm not using an isometric view (I'm actually settling on a narrow/distant fov, top-down) but I did consider an orthographic view to begin with. I couldn't remember if I'd tried it with Sunshine so I've just checked and it does seem to work with an orthographic view. Just so you know.
     
  47. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    This is all subject to change of course, but off the top of my head:
    • Scatter sampling will be greatly improved by using a dither pattern. This makes every sample count, so even using "Low" quality can yield nice results. It also makes the "Animate Noise" feature easier on the eyes... more like "dust" and less like "noise".
    • Rewritten Blur will perfectly blend the new dithered samples... This is just like the way classic SSAO works.
    • Keyword usage will be reduced. I'm recycling old keywords and repurposing them, which means we'll only be using about 50% of the keywords we are now.
    • VR/Stereoscopic Optimizations. If you were using an Oculus Rift for example, you will be able to have the shadowmaps created for one eye, and reused for the other...
    • Shadowing system will be considered an option. By default, you can simply use Sunshine to add volumetric light, and avoid the hassle of complicated integration. I think a lot of users really just want the light rays. If you have a particular need/desire to use Sunshine's shadows (say for the Ouya), you'll just check the "Custom Shadows" box and it will behave as it does today.
    • Terrain Tweak setting to get rid of some of those nasty shadowing artifacts on terrains
    • Misc bug fixes, optimizations, tweaks, and things I'm simply forgetting about. ;)

    I'm definitely excited about the upcoming release, but there's still much work to do!

    Interesting, I wonder if internally Unity just uses a very narrow FOV for Orthographic cameras... I wouldn't have thought that would work, thanks for letting me know! :)
     
  48. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384
    Amazeballs support/updates.
     
  49. Skunkie

    Skunkie

    Joined:
    Jul 2, 2012
    Posts:
    75
    Sunshine 1.5.0 has hit the Unity Asset Store

    • Major Overhaul!
    • Reorganized Inspector to make life easier for users who only want Volumetric Scatter.
    • Improved Scatter sampling! We're now using an SSAO-style Dither pattern to gather statistically better samples.
    • Scatter Blur is now Depth-aware to prevent light-bleeding.
    • Added Per-Cascade Occluder settings (Renamed from Shadow Casters)
    • Reduced Shader Keyword usage! NOTE: Requires restarting the Editor to take effect.
    • Added "Terrain LOD Tweak" for fixing self-shadowing issues on Terrain.
    • Fixed Unity 4.3 Compatibility issue with Deferred Rendered Point Lights.
    • VR/Oculus Rift Optimization! Lightmaps can now be shared between 2 nearby eye cameras!
    • Countless small fixes, tweaks, and optimizations!

    As stated, this is a HUGE overhaul, and there has been some internal structure changes, which might break some settings. It's as simple as going over the new options and making the desired tweaks.

    As always, if you need help or have any questions, lay it on us!

    Thanks for all the patience you guys have given us while we banged this out. Hopefully we didn't disappoint.
     
  50. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384
    Code (csharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. SunshineEditor.OnInspectorGUI () (at Assets/Sunshine/Scripts/Editor/SunshineEditor.cs:504)
    3. UnityEditor.InspectorWindow.DrawEditors (Boolean isRepaintEvent, UnityEditor.Editor[] editors, Boolean eyeDropperDirty) (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Mono/Inspector/InspectorWindow.cs:850)
    4. UnityEditor.DockArea:OnGUI()
    Went ahead and updated in the project, getting this error when looking at the Sunshine script in the inspector. It was also being cantankerous about the Occulder Shader and not showing any of the inspector settings, but I couldn't drop any shaders in, I just deleted/reimported until I get the above error. While this popping I can't change any inspector settings on the script.