Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Sunshine! - Official Thread

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

  1. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Since you're using Deferred rendering, Sunshine Shadows ("Custom Shadow Mapping") should work without modification.
     
  2. foxache

    foxache

    Joined:
    Feb 8, 2015
    Posts:
    8
    Hi. Since updating to Windows 10, I'm not able to import Sunshine. It stops responding and eventually fails. I can't get the project from our Perforce server or import Sunshine from the Asset Store into a new project. Any ideas?
     
  3. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I haven't tried Windows 10 yet, but Unity has some trouble with the (very large) SpeedTree shader on certain machines. You could try not importing Sunshine's SpeedTree shader and see if that helps.
     
  4. foxache

    foxache

    Joined:
    Feb 8, 2015
    Posts:
    8
    Thanks for thequick reply! Funnily enough, I'm trying to import it without SpeedTree shader at the moment. It's still not happy though. Is there any others that I could try leaving out that would make a significant hit on the size?
     
  5. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    You could try leaving out all of the "Built-In Replacements" folder, and then import those shaders as needed later. That would save the shader importer a lot of work, and might prevent the hang.
     
  6. foxache

    foxache

    Joined:
    Feb 8, 2015
    Posts:
    8
    I've just been going through importing a piece at a time and it is with the built in replacements that it hangs. If I can narrow it down any more than that I'll let you know on here. :)

    *edit* if I leave the built-in replacements folder out, it installs almost instantly and works fine. I've picked a few at random from in that folder and it doesn't seem to want to import them at all. It's more than likely just my machine or something confilcting here.

    On a different note, thanks for an awesome plug-in! I'll send you over some screenshots when we've got it back up and running. :)
     
    Last edited: Aug 6, 2015
  7. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thanks for your patience with this issue. I'm hoping Unity improves the stability of the shader compiler soon, since hangs like this can be incredibly frustrating.
     
    hopeful likes this.
  8. foxache

    foxache

    Joined:
    Feb 8, 2015
    Posts:
    8
    No problem at all. These things happen. Really appreciate your help! :)
     
  9. cjrussel14

    cjrussel14

    Joined:
    Jun 20, 2014
    Posts:
    69
    Hi, i always got this error..

    Shader warning in 'Hidden/Sunshine/PostProcess/Scatter': loop only executes for 1 iteration(s), forcing loop to unroll at line 72 (on d3d11)

    Compiling Fragment program with SUNSHINE_ONE_CASCADE SUNSHINE_OVERCAST_OFF
     
  10. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    It sounds like you can safely ignore the warning, is Scatter rendering properly?
     
  11. cjrussel14

    cjrussel14

    Joined:
    Jun 20, 2014
    Posts:
    69
    yes it works fine
     
  12. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    Really love what this asset doing, my only problem is with performance. isn't there any way to make it a little more optimized?
     
  13. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Sunshine is heavily optimized, I would recommend lowing quality to find the right balance for your game.
     
    ksam2 likes this.
  14. Pale_Rider

    Pale_Rider

    Joined:
    Aug 14, 2015
    Posts:
    12
    Hi I'm having a couple of issues with Sunshine in unity 4 free.

    The first is the keyword limit problem I have seen but was not resolved to my satisfaction above. If sunshine adds a ridiculous number of keywords to the point it breaks the system I would like to know how to disable all these that I'm not using in order to prevent these errors please. I use only the deferred method in linear colorspace and at DX11.

    The second is this problem in the image. I was surprised to find that sunshine's shadows begin to look very bad at anything above around 100m range. Adding cascades improves this but the FPS drop is massive so not a solution. The problem is that if a mountain is more than that distance away, the sun streaks will come straight through the mountain and it looks awful. Your documentation states to increase Padding-Z to prevent this, but as you increase padding Z it gradually fixes the mountains but cuts out all shadows of nearby objects in the process.

    I assume you intended Sunshine to be used on scene's larger than a very tiny 100m range, so how do you configure it to always be occluded by large objects in the distance such as mountains? My camera view range is 6000m and I use Time of Day.
     

    Attached Files:

    TheMasquerader likes this.
  15. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I would highly recommend upgrading to Unity 5, since the version of Sunshine running on Unity 4 is quite a few versions behind and all future development is targeting Unity 5.

    Keyword Limit: Sunshine uses somewhere in the range of 12-15 keywords, I can't remember the exact number. Unity 4 has a limit of 64 keywords, and Unity 5 doubles that to 128, so Sunshine can't take all the credit for using them up. Here's some tips to reduce your keyword usage:
    • Remove any shaders/packs from your project you aren't using. Most shader packs will contribute to the total and it doesn't matter if you're actually using them or not.
    • Restart the Editor. This is required for Unity to reevaluate the number of keywords used.
    • If all else fails, you can remove keywords from Sunshine that you don't require, although there are probably only a few. The keywords must be removed from any/all shaders that use them, and of course this requires a healthy bit of shader knowledge.
    100m Range Quality: Even if you're draw distance is 6km, you would never want the shadowmap to cover all of that distance, so make sure you're using a reasonable range. Effective shadow resolution does decrease as range increases, so you might consider increasing the shadowmap resolution to compensate.

    Cascades: These do require some care to keep the performance impact minimal as you've noticed:
    • Make sure to adjust the Cascade spacing to a visually pleasing level to make optimal usage of each cascade. Sometimes you can get away with less cascades if they're spaced nicely
    • Adjust the Layer Mask per cascade. Farther cascades might not need to render shadows for tiny rocks, etc
    Terrain: The Unity terrain system uses some trickery in conjunction with their built-in shadows that is inaccessible from outside scripts. This makes matching up the terrain shadow caster/receivers nearly impossible to do correctly, so Sunshine will probably never be as well integrated as built-in shadows... Try enabling the "LOD Fix" setting, if your version of Sunshine has it, it can help in many situations.

    My biggest recommendation is still to upgrade to Unity 5, and download the latest version of Sunshine.

    I hope this helps,
    Oren Kurtz
     
  16. Pale_Rider

    Pale_Rider

    Joined:
    Aug 14, 2015
    Posts:
    12
    You said to raise the shadow resolution but I can't raise the shadow resolution past it's current maximum, which is where it's at. Could you explain how it can be raised past 4096?

    Regarding the terrain issue; It isn't a terrain issue. The scattering light will blast through any solid object at range, including buildings, walls, etc if they happen to be outside of the range.

    Mostly I'm just not understanding why you have such a huge maximum light range distance in the slider if Sunshine is only capable of scenes at a fraction of that scale. Could you explain that please, and also correct usage (in plain English) of the "padding-Z" thing I mentioned before?

    There is also no mention of "Sunshine uses a lot of keywords that will cause you serious problems if you're running Unity 3 or 4, so Buy At Your Own Risk" on the store page. If what you're saying is how it's going to be, ethically, you need to add that line and also the "Sunshine is only 100% applicable for scenes at or below 100m in size" to the page to prevent those making normal-sized games from making similar mistakes.

    Thanks.
     
    Last edited: Aug 14, 2015
  17. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Correct, you cannot raise the shadowmap past 4096, that is the limit.

    This is how volumetric lighting works, it uses the shadowmap to estimate the contribution of particles to the lighting. It sounds to me like you might be happier with a screenspace scatter effect if you want extremely distant objects like clouds and mountains to occlude light, there is a free one that comes with Unity.

    There is no such thing as a standard scene scale. Yes, it's common practice to use 1unit = 1meter, but it's also not uncommon to see 100units=1meter. In the later case, 10,000 units would only be 100m distance.

    I really don't know what to say except that we've always strived to be fair and ethical in all of our projects. You are more than welcome to a refund if you are unhappy.
     
  18. Pale_Rider

    Pale_Rider

    Joined:
    Aug 14, 2015
    Posts:
    12
    For the sake of argument I spend the last two days importing my game into Unity 5 with the latest version of Sunshine. Still lots of materials that would have to be updated and many more scripts but i wanted to at least see if it was worth it. It seemed ok but for some reason no shadows will show. I've checked to make sure the player is set to Deferred, and the main camera is also set to deferred. The scattering appears to work, but with the custom shadows on, no shadows will draw on anything. You can clearly see it's rendering the shadow map in the visualizer below, but not translating to the screen for some reason. What could cause that? I'm using Time of Day for the main light but i also tried with just a regular directional light in the scene and no change.
     
  19. KWaldt

    KWaldt

    Joined:
    Nov 1, 2013
    Posts:
    127
    Did you also change the deferred rendering shader in the Graphics options? That step is easy to miss.
     
  20. PeterFL

    PeterFL

    Joined:
    Aug 17, 2015
    Posts:
    2
    Hi, we just bought Sunshine to evaluate how it performs on iOS, but having problems.

    We used your example scene as test to run it on an iPhone 5S with iOS 8.4, where it crashes with the following error:
    Code (CSharp):
    1. Initializing Metal device caps
    2. Initialize engine version: 5.1.2p3 (65486b59c7a9)
    3. Metal: Failed to get shader entry point 'xlatMtlMain'
    I also attached a screenshot of Xcode that shows the crash and call-stack. In this particular case, it's using the Il2Cpp backend, but it does crash when using Mono as well.

    Any idea?
     

    Attached Files:

  21. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Looks like KWaldt beat me to it, make sure you've selected Sunshine's Deferred shader in the Graphics settings.

    I'll see if I can reproduce this today, but I would definitely report this directly to Unity. It sounds like an internal bug.

    Edit:
    After some tests I was able to reproduce this, and it does appear to be a Unity issue with Metal specifically.
     
    Last edited: Aug 17, 2015
  22. PeterFL

    PeterFL

    Joined:
    Aug 17, 2015
    Posts:
    2
    Thanks for taking a look at it.
     
  23. rdurnin

    rdurnin

    Joined:
    Aug 13, 2014
    Posts:
    16
    Hello PolyVector, we are evaluating your plugin as a means to achieve shadows with custom camera projection matrices. I read in a forum thread that this would be possible using your plugin with a moderate amount of support. Time is a major factor for us, and so any guidance or direction you can give would be of great assistance. We are using Unity version 5+.

    Please feel free to contact me directly, and post any support workflows to this thread.

    Thanks,
    r
     
  24. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    It is possible to get custom projection matrices working with Sunshine's "Custom Shadows", but many features such as multiple cascades, and shadow fading will not work. The best way I've found is to use a single Cascade and configure the "Custom Bounds" to fully surround your scene.

    Some additional caveats I've noticed with Custom Projection Matrices.
    • Unity only supports Forward Rendering, it does not matter what your Camera is configured for, you'll wind up in the Forward Path
    • Specular (specifically with the Standard Shader) is wrong, so it's best to stick to diffuse materials.
    This is all I can think of at the moment, I hope it helps.

    - Oren Kurtz
     
  25. rdurnin

    rdurnin

    Joined:
    Aug 13, 2014
    Posts:
    16
    Thanks for the quick reply Oren. Can I ask if the plugin still requires Unity Pro? We have been making use of RenderTextures in the 5+ versions with the non-professional version, although there may be further features disabled through the graphics pipeline.

    r
     
  26. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Sunshine works just fine in Unity Free 5+, I'm not aware of any missing graphics features.

    -Oren
     
  27. DanielZeller

    DanielZeller

    Joined:
    Nov 18, 2014
    Posts:
    17
    Quick question about the shadow solution. Is it possible to update the shadow of the main character on every frame, and the rest of the shadows manually or by X camera movement?
     
  28. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Unfortunately no, there is only a single shadowmap and any updates must be full updates.
     
  29. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    182
    I see the speed tree shader in the assetstore, however When I downloaded sunshine, it didn't give me any speedtree shaders for sunshine.
     
  30. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    If you're running an older version of Unity (pre-5.0) the Asset Store will give you an older copy of Sunshine.

    If you're running the latest version of Unity, and have the newest Sunshine, try importing a second time. Unity's shader compiler can get tripped up by Sunshine's SpeedTree shader during import.

    Hope this helps,
    Oren
     
  31. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    182
    do you know how to combine lightmap with shadows, most shaders here either support realtime shadow or support lightmap, but not both.
     
  32. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    After running some tests this morning I can confirm that lightmaps+shadows are not blending together as they should. Unity 5 changed a lot about how lighting is calculated, so something must have broken compatibility with Sunshine. I'll see what can be done to address this in an update.

    Thanks for catching this.
    -Oren
     
    hopeful likes this.
  33. FuzzyShan

    FuzzyShan

    Joined:
    Jul 30, 2012
    Posts:
    182
    I am not sure why, but having less drawcalls and verts compare to unity shadows for my scene, yet my scene runs 60fps on Samsung Note 2 with unity shadows, and runs 39fps with sunshine. (5 speed trees casting shadows.)
     
  34. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Unity's built-in shadows have come a long way in terms of performance, they make use of specialized hardware features on mobile, whereas Sunshine is implemented in a very general way allowing it to run on unsupported devices like the Tegra3/Ouya. Sunshine's strengths are definitely on Desktops, but there are some nice "runtime baking" style features that work very nicely on Mobile. There are cases where Sunshine runs faster, and vice versa, it all depends on what you're attempting.

    If you mostly need regular shadows, and Unity supports the device, I believe built-in shadows are the way to go.

    Make sure to try enabling the LODFix setting if you're using SpeedTree shaders, it helps with consistency.
     
  35. NikProductions

    NikProductions

    Joined:
    Oct 29, 2014
    Posts:
    95
    Hey, sunshine is not working in 5.2
    a9ab3263ebbbaa3250477e73a99f0fab.png
     
  36. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thanks for catching this, It will be fixed in the next release.

    In the mean time you can safely remove the 4 references to ".useMipMap" to get rid of the logspam.

    Edit: 4 references, on 3 lines.

    Cheers,
    Oren
     
  37. Skunkie

    Skunkie

    Joined:
    Jul 2, 2012
    Posts:
    75
    Sunshine 1.7.9 is Now Available in the Unity Asset Store
    • Fixed "useMipMap" Log Spam in Unity 5.2
    • Fixed Lightmap blending
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,898
    hi there,
    is there any way or are there any plans making sunshine utilizing unity’s (cascaded) shadow maps instead of rendering its own (like in the blacksmith demo)? i guess doing it twice is just a waste.
    lars
     
  39. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Yes! This was actually the goal of the project from day one, but was unfortunately impossible at the time. Believe me, I never wanted to reinvent the wheel and write a yet-another-shadowing system.

    It now seems that it should be possible with Light Command Buffers, but in all of my testing it doesn't appear to work on OS X, only Windows (even the Blacksmith demo doesn't have volume light on OS X). Since I'm developing on a Mac, and I'm concerned about compatibility, I'll be waiting for the Light Command Buffers+Shadow stuff to mature a bit before switching Sunshine over to it.
     
    hopeful likes this.
  40. Komikusac

    Komikusac

    Joined:
    Aug 11, 2012
    Posts:
    30
    A quick question for PolyVector! Sorry if it was adressed before... didn't find it elsewhere.

    So, my problem is the lack of vertex colored and vertex lit shaders. I have a game that is completely texture-free and is colored by using vertex colors. However, I would like to use Sunshing for shadowing but am unable.

    Is there a vertex colored shader in the works and/or how problematic would it be to make one?

    With regards
     
  41. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Shadows require per-pixel light calculations to function, so you can't have a true vertex lit shader using Sunshine. You could use a simple shader with no texture support and add Sunshine functionality to it, that wouldn't be hard.

    Cheers,
    Oren
     
  42. romaing

    romaing

    Joined:
    Feb 11, 2010
    Posts:
    24
    Any news about that issue? a workaround maybe for those who want to use Sunshine on iOS devices with metal?
    Would be great :)
     
  43. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    This appeared to be a Unity bug when I tested it originally, does it still happen in newer versions of Unity? If it's still happening I'll definitely investigate potential workarounds.

    Cheers,
    Oren
     
  44. romaing

    romaing

    Joined:
    Feb 11, 2010
    Posts:
    24
    Yes, it still crashes with 5.2.2p3 while using metal.
    It'd be great if you find a way to fix it, or a workaround.
     
  45. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    This turned out too be trickier to track down than expected, but I believe I've found what is tripping up Unity's shader system...

    For some reason it looks like the COLOR semantic is the culprit, which is strange but easy enough to fix:

    Change the v2f struct in Sunshine Occluder Common.cginc to this:
    Code (csharp):
    1. struct v2f {
    2.    float4 pos : SV_POSITION;
    3.    float2 uv : TEXCOORD0;
    4.    fixed4 color : TEXCOORD1;
    5.    float2 depthAndBias : TEXCOORD2;
    6. };
    Let me know if this solves your issue and I'll include it in the next update.

    Cheers,
    Oren
     
  46. Pomettini

    Pomettini

    Joined:
    Aug 29, 2013
    Posts:
    26
    Do you know why shadows are inverted on a Nexus 7? On a Samsung with Tegra 3 it runs fine.
    I'm using Sunshine 1.7.9 with Unity 5.3.
    Thank you!
     

    Attached Files:

  47. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Something might have changed in Unity 5.3, I'll look into this. This is a 2012 Nexus 7?

    Cheers,
    Oren
     
  48. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I just ran the test scene on my 2012 Nexus 7 with Unity 5.3 and Sunshine 1.7.9 and it looks fine.

    It could be related to the specific shader/settings you have, if you could PM me a scene that reproduces the problem I'll try and figure out what's going wrong.

    Cheers,
    Oren
     
  49. romaing

    romaing

    Joined:
    Feb 11, 2010
    Posts:
    24
    It works!

    Thanks Oren ;)
     
  50. Pomettini

    Pomettini

    Joined:
    Aug 29, 2013
    Posts:
    26
    Thanks for your answer. It's a 2013 Nexus 7 wi-fi with Android 5.1. I had that problem on Unity 5.2.3 too.

    I have to ask my bosses if I can share the project with you, in that case I'll send you a private message ;)