Search Unity

Unity Sunshine - A replacement for built-in shadows

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

  1. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I'll add it to my TODO list! For the time being, you can right-click and drag up/down to change speed.
     
  2. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    @dahrrr
    I'm so sorry I must have skipped over your question! :)

    The batching is controlled by Unity internally, so however Unity handles batching when using RenderWithShader() is how Sunshine handles batching. I don't believe I have control over that.

    Deferred Shadows are NOT supported. Sunshine only works with your Forward-Rendered primary directional lights. Additional lights are unaffected.

    Shaders do need to support Sunshine, but Sunshine! comes with the majority of the built-in shaders edited for you included... There are also instructions on adapting existing shaders.

    I hope this answers your question, sorry I skipped over it!
     
  3. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    @Chaoss
    I've just submitted version 1.2 to the Asset Store, and updated the Demo accordingly... The demo was updated with a free-cam as you suggested... Just right-click until you get to the last camera, and you can use the mouse and keyboard to fly around. :)
     
  4. TacticalDan

    TacticalDan

    Joined:
    Jan 1, 2013
    Posts:
    35
    I've had some trouble with vert-frag shaders (Sunshine VertFrag Example.shader) and dx11. Fixed by changing the line in sunshine.cg

    #define SUNSHINE_INPUT_PARAMS float4 sunshine_lightData

    to

    #define SUNSHINE_INPUT_PARAMS float4 sunshine_lightData : TEXCOORD2

    For anyone who's incredibly baffled by this :p

    Nathan
     
  5. PolyVector

    PolyVector

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

    Thanks for sharing this. :)

    It sounds like DX11 requires the semantic to be specified on every parameter. I'm on a Mac, so I haven't been able to test DX11 support yet unfortunately.

    You might want to specify float4 sunshine_lightData : TEXCOORD2 in your VertFrag shader rather than edit Sunshine.cginc, since specifying the semantic globally might conflict with other shaders once they're recompiled. The terrain shaders already use TEXCOORD2 for example.

    I'll look into this further if I can get DX11 running.
     
  6. Fourthings

    Fourthings

    Joined:
    Feb 15, 2010
    Posts:
    313
    Ok so I dropped the prefab into the scene, hit the fix buttons, and the volumetric lighting showed up, but no shadows. So I turned on hard shadows on the directional light and they look terrible http://cl.ly/image/3m3E360r2J0V

    What am I doing wrong?

    Edit - Also I keep getting "Cleaning up leaked objects in scene since no game object, component or manager is referencing them
    Texture2D has been leaked 1 times."
     
    Last edited: Apr 24, 2014
  7. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Assuming you're using the Forward renderer, make sure you either "Install Forward Shaders", or check the "Manual Installation" box and set your materials to use "Sunshine/"shaders.

    The Texture2D "leaking" is due to a tiny 4x4 Dithering texture Sunshine generates. It's just a warning in the Editor and doesn't affect the build, but I have it on my TODO list.
     
  8. Deleted User

    Deleted User

    Guest

    Thanks for the quick response. This is happening with Deferred Lighting. I followed your instructions in the manual.
     
  9. Epictickle

    Epictickle

    Joined:
    Aug 12, 2012
    Posts:
    431
    Man, UT needs to just buy this from you outright and slap this in as their default pro lighting solution. This is freaking beautiful, and it already has Ouya support!
     
  10. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hehe, thank you! I simply wish Unity would open up a shadowing API so these types of effects could be added using the built-in shadows instead of an entire rewrite. Ah well. :)
     
  11. Jaqal

    Jaqal

    Joined:
    Jul 3, 2014
    Posts:
    288
    Do you know many shader keywords this uses? I am using RTP, LUX and AFS so I am already near the max.
     
  12. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I believe Sunshine currently uses 14 keywords.
     
  13. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    When using a custom projection matrix for asymmetrical frustum rendering Unity has major issues with shadows. Do you know if your plugin works properly if the user uses a custom projection matrix?
     
  14. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I would have to assume there could be an issue with the way distance/cascades are handled, and quite possibly the way frustum rays are interpolated. Orthographic frusta work, so there is a chance an asymmetric frustum could too.

    One benefit of Sunshine is that you can modify the source to fit your needs if you have the knowhow. Feel free to give it a try and I'll issue a refund no questions asked if it doesn't work out.
     
    Jaqal likes this.
  15. hypnoticshark

    hypnoticshark

    Joined:
    Sep 20, 2012
    Posts:
    20
    Hi,

    we just purchased sunshine for our studio but we are having issues moving it. We would like to move it to our third party assets folder but doing just that does not work. We did a find and replace in files to the "#include "Assets/Sunshine/Shaders/Sunshine.cginc"" to "#include "Assets/thirdparty/code/Sunshine/Shaders/Sunshine.cginc"". I am guessing we are missing a few steps as the shadows do not work yet. Do you know what these steps might be or what would be the best way to move the folder? Also we cannot have our shadow receivers placed in "Sunshine/...." due to our project requirements. Where do we change that? We are using custom shaders throughout the project. This is a mobile project and we are using unity's forward renderer.
     
  16. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,204
    @hypnoticshark

    From the official Sunshine thread.

    Question:
    Answer:
     
  17. hypnoticshark

    hypnoticshark

    Joined:
    Sep 20, 2012
    Posts:
    20
    Thanks Ben, we managed to go through all the shaders and scripts and replace all the paths and managed to get it to work. We are using unity 4.6 as of now. The only issue is I am getting shader errors in 'Hidden/Internal-DefferedShading' I am guessing this is referencing unity 5 shader code. Is it safe to delete this?
     
  18. hypnoticshark

    hypnoticshark

    Joined:
    Sep 20, 2012
    Posts:
    20
    Since we were able to successfully move this package and not have any errors I am going point out the process we used to do this.

    In our case we wanted to move this package from "Assets/Sunshine" to "Assets/thirdparty/code/Sunshine"
    We did this by doing a find and replace in files. Ignore the brackets. We searched for( "Assets/Sunshine ) and did a replace with ( "Assets/thirdparty/code/Sunshine ) and that worked for us. The only issue we had in the end is that we are on unity 4.6 and there were some shaders referencing the defferred stuff in untiy 5 included in the package and we just deleted these shaders and have had no problems after.

    Note: there were 2 c# files with hard coded path names as well that we replaced. The search and replace should take care of it. Hope this helps. Its a wonderful package :)

    Thanks!