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. Skunkie

    Skunkie

    Joined:
    Jul 2, 2012
    Posts:
    75
    In case you haven't seen it, The Forest developers have released a new trailer that makes excellent use of Sunshine!

     
  2. norbykov

    norbykov

    Joined:
    Jul 27, 2010
    Posts:
    23
    Hi PolyVector! Just bought the plugin, and it's really great. One quick question: I have a totally transparent plane that I'd like to receive shadow from other objects. Is that possible? Turning on "Alpha receivers" seem to not have an effect. Can you point me in the right direction? Cheers!
     
  3. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    You should be able to set the object's material to use Sunshine/Transparent/Diffuse instead of "Transparent/Diffuse"

    If you're using the Forward Renderer, all or most of your materials should use a Sunshine/... shader.

    If you're using the Deferred Renderer, you only need to use Sunshine/... shaders with transparent materials... You'll also want to enable Sunshine's "Manual" installation mode so it doesn't attempt to swap out shaders for you.

    Hope this helps. :)
     
  4. norbykov

    norbykov

    Joined:
    Jul 27, 2010
    Posts:
    23
    Thanks PolyVector, I did all that, but when I set the alpha to 0 on the plane, the shadow disappears as well. :) I have a shader that does what I'm trying to achieve with Sunshine, but if I want to modifying that according to the documentation, it results in an all-black texture. I'm not a shader expert by any means, that might be a problem... :)
     
  5. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    If you PM me the shader that does what you want, I could take a look at it and see if Sunshine support can be added. :)
     
  6. lisaiceland

    lisaiceland

    Joined:
    Nov 16, 2013
    Posts:
    7
    Hello:
    I downloaded sunshine today and I set it up as in the docs but I get no effects showing up.
    I've attached a screenshot of the component settings as well.
    Thnx
    Plz let me know what else I need to do to make this work.
    Thnx
    Lis
     
  7. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I can't see the screenshot, but the documentation should go over everything required. Sunshine only shows up in the Game tab, so be sure you're not just looking at the Scene view.

    If you're using the Forward Renderer, you'll need to use shaders starting with Sunshine/.... These can be automatically swapped out in most cases if you use Sunshine's Install feature.

    If you're using the Deferred Renderer, make sure you've restarted Unity at least once so that it can reload the shaders.

    If you set Sunshine's Debug mode to Status it will output some useful information as to what is going on in the Game tab.
     
  8. lisaiceland

    lisaiceland

    Joined:
    Nov 16, 2013
    Posts:
    7
    Hi. Do u have any issues with terrain shaders overwrites? Plz let me know. Thnx. Lis
     
  9. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    If you mean additive blending (for more than 4 textures), then there should be no problem. I've designed Sunshine to play nicely with additive blending. :)
     
  10. lisaiceland

    lisaiceland

    Joined:
    Nov 16, 2013
    Posts:
    7
    I'm using RTP for replacing unity default terrain shader only. I installed Michael O's Autumnal pack and it cased me havoc...
     
  11. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I'm pretty sure people have successfully integrated Sunshine with RTP before. If you have any issues with Sunshine, or any of my packages, I'm always here to help. :)
     
  12. JFo

    JFo

    Joined:
    Dec 9, 2007
    Posts:
    217
    Hi!

    Any idea why using latest Unity 4.3.1 and enabling light scattering, it shows "upside-down"...?
    Also, there are errors showing when playing.

    Thanks!

    $Sunshine_bug2.PNG
     
  13. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I'm sorry you're experiencing problems, a few quick questions.

    What version of Sunshine are you running? (it says in the prefab's inspector at the top)
    What operating system are you on?
    Are you using DX11?
    Are all the errors you're getting the exact same? When you double click on them, what code do they bring up?
     
  14. JFo

    JFo

    Joined:
    Dec 9, 2007
    Posts:
    217
  15. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Has this flipped Scatter problem ever happened without the errors appearing? I'm wondering if the exception is preventing Unity from completing some code that enables the required UNITY_UV_STARTS_AT_TOP macro... hmmm

    As a temporary workaround you could probably set Scatter to full resolution without any blurring to avoid "ping ponging" buffers. I'll keep digging into this in case there's a flaw in the way I handle flipped buffers.
     
  16. JFo

    JFo

    Joined:
    Dec 9, 2007
    Posts:
    217
  17. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Okay, I can reproduce this on Windows (in VMWare) with MSAA enabled using the newest version of Unity. I'll keep you updated. :)
     
  18. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    @JFo

    I'm pretty sure that this is caused by a bug in Sunshine that was compensating for a Unity bug corrected in version 4.3.0...

    Symbiotic bugs... :D

    You should be able to fix it by editing the following line in Sunshine Post Scatter.shader:
    I can't put this in an update just yet because it breaks support for older versions of Unity... but I'm sure I'll find a work-around soon enough. :)
     
  19. JFo

    JFo

    Joined:
    Dec 9, 2007
    Posts:
    217
    Thanks for the solution, we'll use that. And keep up the good work!
     
  20. Skunkie

    Skunkie

    Joined:
    Jul 2, 2012
    Posts:
    75
    Sunshine 1.4.4 is available in the Unity Asset Store

    • Fixed Scatter appearing upside-down in Unity 4.3 on Windows with MSAA enabled
     
  21. rrh

    rrh

    Joined:
    Jul 12, 2012
    Posts:
    331
    I've been trying to do a sunrise in a Unity scene. So I animated a directional light that rotates, but then when the sun is low in the sky, I get HUGE peter-panning where my tree's shadows won't connect to their trunks. Even if I turn bias down to zero they still don't connect. (I know I'm supposedly in danger of acne, but I'm trying it.) And because I want the sun to move, baking the shadows doesn't seem like a good solution.

    Does this seem like something that Sunshine could get better results?
     
    Last edited: Dec 20, 2013
  22. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Peter panning could be caused by the built-in slope-scale bias. I wouldn't recommend Sunshine for merely resolving tiny issues like peterpanning or acne (all shadow techniques are imperfect). Sunshine is mostly intended to add volumetric light PCF filtering, and bring shadows to unsupported platforms.

    I would offer to take a look at your scene and see if I can work out a solution for you but my computer is in critical condition at the moment... Might be a week before this hardware scan finishes :|
     
  23. rrh

    rrh

    Joined:
    Jul 12, 2012
    Posts:
    331
    I have a video that shows what it looks like as the light moves, passworded with "shadow":
    http://vimeo.com/82341449

    It's not currently a tiny problem in terms of that doesn't look good, but if this is outside the realm of what Sunshine is meant to improve, I'll look into other ways of avoiding it.
     
  24. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    A-ha! This is a Unity bug I've run into when supporting Shadow Softener. It happens on Windows with some machines, and I've reproduced it in a VM... Notice the odd lighting/shadows below the ground, and I'll bet that if you lower the polls below the ground they can occasionally cast shadows above (depending on the camera position/angle)...

    I would report this to Unity and include your video in the bug report.

    It's very possible that Sunshine does not suffer from this problem, but I couldn't be sure. You might also try forcing Unity to use OpenGL since it appears to be render-texture related.
     
  25. Given_

    Given_

    Joined:
    Dec 31, 2013
    Posts:
    1
    Ciao Oren,
    I'm not so pro with Unity, but even following all your steps I cannot see your shadows working in my scene.
    I'm using deferred lightning.
    Added Sundhine prefab to the scene,
    linked prefab to my directional light with hard shadows,
    added sunshine camera script to my script.
    Even tryng just to see shadows, I have disabled light scattering in sunshine.
    But I see no shadows.
    When in play mode, If I disable the Sunshine prefab I can see the standard shadows, but when reenabling Sunshine, no more shadows are visible.
    Thank you for your help
    Donato
     
  26. PolyVector

    PolyVector

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

    Just a couple thoughts off the top of my head:
    • Try setting Sunshine's Debug View setting to Status to output some debug info, this can sometimes help spot compatibility issues.
    • Make sure you don't have Graphics Emulation enabled. You can set this in the Edit/Graphics Emulation menu.

    If you PM me your scene, I'll take a look at it and see what the problem is :)
     
  27. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    Does this play well with multiple cameras in deferred? For instance if I have a Main Camera for scene stuff, then a Background camera to render the background sky and such then is the effect going to work and carry through on the Main Camera's empty pixels? (or skybox?)
     
    Last edited: Jan 4, 2014
  28. PolyVector

    PolyVector

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

    I just made a small test with 2 cameras (Near and Far) using Sunshine+Deferred. Everything appears to clip exactly as you'd expect. If you only add the SunshineCamera component to the near camera, the far camera is completely unaffected by Sunshine.

    Hope that helps. :)
     
  29. moitias

    moitias

    Joined:
    Sep 17, 2013
    Posts:
    3
    Hi Oren,
    thanks for the wonderful package - the shadows look awesome!

    However, we're having a little trouble with the shadows on Tegra. The demo on the website does work on our Nexus 7, but when building and running the samples, they don't seem to work.

    Unity 4.3.1f1, Sunshine 1.4.4, Nexus 7 (model ME370T), Android 4.4.2 (kernel 3.1.0-g4776c68)
    1. create a new, empty unity project
    2. import sunshine
    3. open samples\sunshine sample mobile
    4. build and run for android

    Expected result: shadows on screen
    Actual result: no shadows visible

    Apk logcat shows no errors. I Tried with various settings as well, forward/deferred rendering, Android SDK v4.0, Fantastic rendering quality - none of which resolved the issue. Exactly the same package works on other non-Tegra devices well, so I'm leaning towards a problem with Tegra.

    Noticed something while debugging, though - the editor profiler shows 7 shadow casters but on the device it's 0. So, for some reason it seems to be getting turned off rather than not working (or that might just be for the Unity shadows?)

    Any ideas?
     
    Last edited: Jan 6, 2014
  30. PolyVector

    PolyVector

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

    I just tested on my Ouya with the newest Unity+Sunshine to rule out a regression bug and everything appeared to work. Did you press the "Install" Button in the Sunshine Prefab to swap out shaders? Skipping this step would explain the results you're getting, especially since there were no errors.

    It's admittedly a bit of an awkward step, and the documentation goes over the pros and cons of "Installing" vs. manually swapping out shaders.

    Let me know if that solves the issue for you. :)
     
  31. moitias

    moitias

    Joined:
    Sep 17, 2013
    Posts:
    3
    Hey Oren,
    We did indeed do that, but in the end it turned out to be a license mishap - the machine building the apk didn't have Android Pro.. Thanks for your help and attention, though, great support make me feel all warm and fuzzy inside :)
     
  32. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I'm glad you were able to figure it out, and a warm and fuzzy feeling sounds like a nice bonus, haha.

    If you have any further issues don't hesitate to ask. :)
     
  33. Atmey

    Atmey

    Joined:
    Nov 3, 2012
    Posts:
    88
    Hey Vector,

    I am having problems trying to add custom shaders (Toony Colors Pro), it gives me the following error when I include sunshine.cginc:

     
  34. PolyVector

    PolyVector

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

    That error sounds like you've included Sunshine.cginc but haven't added the required lines of code to make it work. I would strongly recommend reading through the documentation.

    If you scroll down to the Customizing Shaders section, there is an example with the required changes highlighted in bold and brief explanations of what they do.

    If you still are having trouble, feel free to send me a shader and I'll attempt to get it working for you. :)
     
  35. Atmey

    Atmey

    Joined:
    Nov 3, 2012
    Posts:
    88
    I did copy and paste the whole thing between the CGPRORAM, it gave another errors like parameters missing, thats why I started doing line by line, I could give you the shader script, but I don't think I should post it in public as it is a paid asset, it also references other files included with the shader, do you have Toony Colors? if yes that would save a lot of trouble.

    EDIT: Okay, I managed to get the shader compiling without errors, thanks to the keyword: highlights, I just inserted the highlighter parts into the existing shader.

    But now I am unsure if it is working correctly, I can see the shadow in the editor window, but I can't see it in game.
     
    Last edited: Jan 12, 2014
  36. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Sunshine only shows up in the Game view, so it doesn't sound like it's working.

    First, be sure you've set up Sunshine correctly:
    • Added the Sunshine Prefab to your scene
    • Selected "Manual Installation" or pressed "Install"
    • Selected your primary Directional light
    • Attached SunshineCamera to your Camera(s)
    If you've done all that, you could try setting the Debug View to Status to see if there's any obvious problems going on.

    I don't have Toony Colors, but if you PM me a scene, I will try to fix the issue for you and send it back.
     
  37. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    I've noticed an issue where meshes draw with Graphics.DrawMesh don't appear to cast shadows. They seem to received them fine.

    Disabling the Sunshine script causes the objects to cast shadows. For the record, in the code I am passing in both bools as true to cast and receive shadows. Again, if I disable sunshine, the objects receive and cast shadows.

    I have some meshes that I combine together, and also some meshes that I display individually (both cases are drawn using Graphics.DrawMesh). They both behave the same way I described above.

    Any thoughts on this?
    Thanks!
    JC
     
  38. PolyVector

    PolyVector

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

    I just tested Graphics.DrawMesh() in the Sponza demo and the object both Cast and Received shadows in both Forward and Deferred renderers.

    The cast/receive options are mostly useless with Sunshine (with some exceptions mentioned in the docs), instead you have to use Layers to determine what casts shadows and Materials/Shaders to determine what receives them.

    A couple things to check:
    • Be sure the Layer you are passing to DrawMesh is set to cast shadows in Sunshine's Settings (in the Prefab you set in your scene)
    • Be sure you are letting DrawMesh draw to every camera.

    If you still are having trouble, feel free to PM me a scene demoing your problem and I'll get to work solving it. :)
     
  39. Atmey

    Atmey

    Joined:
    Nov 3, 2012
    Posts:
    88
    Yes, I did that, everything seems to be working fine with sunshine diffuse.

    Okay I found something that might be of relevant, Toony Colors does not have a Lambert property, when I add it, the shadows are cast, but the material loses it's cell shading effect, which is the whole point of it.

    Is there a way to apply it on non-lambert?
     
  40. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Okay, then it's definitely the shader if you have it working with Sunshine Diffuse. Hrmmm.

    Sunshine should work with custom lighting models, I spent quite a bit of time focusing on that.
    This might be a silly question, but did the shader utilize shadows before? I couldn't find a demo/screenshot of Toony Colors using shadows.

    I think your best bet is probably to PM me a small scene/package and I'll try to quickly narrow it down for you.
    Don't worry, I never keep support projects. ;)
     
  41. Atmey

    Atmey

    Joined:
    Nov 3, 2012
    Posts:
    88
    Sunshine ticked off:
    https://dl.dropboxusercontent.com/u/2853559/sunshine01.png

    Ticked on:
    https://dl.dropboxusercontent.com/u/2853559/sunshine02.png

    I failed to replicate the scene as export, I am just going to send you what I think are the relevant folders.
     
  42. Atmey

    Atmey

    Joined:
    Nov 3, 2012
    Posts:
    88
    I found what is the problem, I had to enable "Use Direct3D 11" in the player settings.
    Everything works as it should.

    Thanks.
     
  43. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I'm so glad you were able to find something that works. Sunshine doesn't utilize DX11, so it's interesting that it affected things for you. Might be worth investigating further when I get the time. :)
     
  44. Katarak

    Katarak

    Joined:
    Feb 19, 2013
    Posts:
    13
    Hey PolyVector, I was looking to purchase this tool, but I hade a few questions before that, just to make sure I could totally do what I wanted.
    I have 2 current problems with the game I'm working on that I feel maybe Sunshine could help with.
    1. We create procedural cities, So it's impossible to bake shadows. I see that Sunshine allows for update intervals. Would it be possible to bake the whole scene once? and then use that as baked shadow maps?
    2. We want our shadows to really look different than just a shadow, it is possible to change the texture applied to the shadow? so we could have say circles, or squares or lines, or whatever we wanted as opposed to a regural shadow?

    Thanks for your help,
    K
     
  45. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hey Katarak,

    1. Yes, you can set the Update Interval to Manual, and only call it once if you choose. You would need to use the Shadow Volume feature and place the target/radius around your scene to control the area that the shadows cover. A little work, but totally possible. You can always update again at runtime if the player destroys a building. ;)

    2. It's certainly possible, but it will require a bit of shader knowlege to set up the custom shadow filter just right. Also, keep in mind that not every type of shadow style you can envision will be possible, it would have to work within the constraints of a ShadowMap. There is an included sample of a custom shadow filter to get you started.

    Hope that helps. :)
     
  46. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    Hey,

    Awesome plugin. It's totally tits.

    I have some odd-ball space stuff and weird issues (not really failures, just issues) I'd like to get some support on, could we skype over it? Makes things so much easier to explain and faster.

    If thats fine add me (zer0bounds), otherwise np, I'll drop pics and stuff in the thread here.
     
  47. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thanks for the kind words!

    Sorry for the slow reply, I'm working on a project fulltime for the next couple months, so my time is limited.

    It's easier for me if you can post the details here (or PM me) I'll do my best to help. :)
     
  48. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    I'm using the Oculus Rift and Sunshine in space. I have Sunshine scattering light all through a bunch of asteroids. Bad thing is that the Rift uses two cameras, one for each eye, and they are offset left and right just a bit. Another bad thing is that the player can see forever in any direction, basically.

    The first thing is I can't seem to stop the scattering from going really, really far into the background and looking ridiculous. Like if I've got a set of asteroids kind of making a wall, sunshine on the left, then long rays casting to the right, if I walk into those rays I can see really far to the right and there are some undesirable artefacts with it. Is there a way to control the distance it will keep a ray going? I'd like it to blend out over the span of nth units then fade out to nothing - that would pretty much fix the neverending ray problem.

    Other thing is the double cameras going on for the Rift. It's pretty easy to feel any discrepancies between your eyes and Sunshine basically works fine out of the box for the double camera but its when one camera is rendering a significantly different image than the other one that it starts getting painful to watch. I think this has some issues in my scene and might be solved with a more controlled environment (ie I need to polish my camera/light settings) but I'm still wondering if I can do anything about this on the front end to help with the issue.

    Also, is there anything in the script that would care if the light source couldn't see the camera? or if it was inside an object? This is sort of part of that last paragraph but I haven't nailed down why its happening, seems like when the light source has no LoS on the camera it acts funny, but this could be from casting shadows locally on the ship that's containing the camera.

    Heres a video, if you watch both cameras you'll see discrepancies between them and I'm trying to avoid that wherever possible because it is not pleasant.

    https://www.youtube.com/watch?v=liA-MXMFYMo

    Any thoughts would be appreciated. I just really got started on this a couple of days ago so I'm still looking into the whole thing and working on making some controlled tests for the stuff I haven't figured out yet.
     
  49. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    That looks incredible! I need to get an Occulus Rift already!

    I'm heading to bed, so if I make little sense I apologize... but the main issue appears related to the Padding Z setting, I would try increasing it to see if that helps. If you can't get it high enou, I'll bet your scene is scaled too large. You might also experiment with changing the number of cascades, since the splits can sometimes cause artifacts.

    As for fading out rays, that's not possible unfortunately. You could turn down the "Exaggeration", which should increase the realism a bit.
    Let me know if that helps.
     
  50. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,462
    Alright, so I made some more adjustments and brainstorming..

    $Sunshine.jpg

    Those are my options in Sunshine. This is the best balance I could find between Performance and Quality without things getting too slow or looking sloppy, and I'm getting the hang of using these to change the shape of the light without dumping performance.

    I didn't notice a big difference with Padding Z, and my project scale is pretty normal but the scenes are abnormally large in terms of what is playable/visible at any given time. But, its space, so everything is huge.

    This poses an issue with Shadow Distance and how the length of the rays are tied to the distance at which you can actually see shadows begin to appear. I don't know if it's terribly difficult to disconnect the two, but my problem with light length would be solved if I could use separate values for shadow distance:

    1) Distance at which shadows will begin to be seen by the camera (I want this high)
    2) Distance at which shadows will stop from the source that creates them (I want this low)

    #2 is basically what Shadow Distance does right now, 400 looks good, but doesn't allow me to see light rays from shadows that are far away from the camera and essentially breaks the scene. But, the scene is broken if I use a long shadow distance too because you can see light rays go on forever and they have some bad clipping issues when that happens.

    Does that make sense?

    I can provide some screenshots if necessary.

    $SunshineStack.jpg

    This is the stack I'm using. Due to acne issues I used Sunshine only for scattering and used a separate light to provide actual light to the objects. Is this a problem?

    I have one really huge asteroid block a lot of light in the scene to see what that would look like and the shadow distance value is quite a nuisance. If its too low I don't see the shadow when I move away from the object so for instance if I move close to it and get into its shadow area and then fly away from it then the light will eventually stop casting a shadow from it and as I'm moving away all of the shadows will disappear on the objects in front of me. Definitely doesn't work. Thats why I need to separate the two distances because if I raise the Shadow Distance to fix that then I get light rays that are ultra long and incorrectly clip through objects I'm looking at in this scenario.
     
    Last edited: Jan 24, 2014