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
    That's great, I'll include this fix in the next version.

    I think the 2013 model had a Snapdragon chipset so that might be why I don't see it on my 2012. A small project (a couple of cubes) that reproduces it is just as good for me. It might just be a specific shader/setting your using that I haven't thought of.
     
  2. Issam

    Issam

    Joined:
    Dec 18, 2012
    Posts:
    37
    Hi,

    I was curious if Sunshine support Unity 5.3 WebGL Build? I tried building out game and it seems the shadows are not working correctly. I just want to make sure if it's supported or not before spending time on it.

    (sorry if that was already answered, can't seem to figure out how to search a thread)
     
  3. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I haven't had a chance to try the new WebGL yet. I'll give it a try and see if something needs to be tweaked to properly support it.

    Cheers,
     
  4. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I just ran some tests with the sample scene on my Mac with Firefox 42 and everything initially worked, both Custom Shadows and Scatter. Then I switched to using Sunshine's modified Standard Shader and shadows stopped working. There might have been changes to the Standard shader that need updating in the included copy.

    I'd like to eliminate the need for modified shaders at all, and this is something I'm investigating for the future. I'd like to see Sunshine seamlessly integrate without any effort, but for the moment I'll see if I can patch the Standard shader in the next release. A temporary workaround would be to disable Custom shadows, or use a different shader.

    Cheers,
    Oren
     
  5. Skunkie

    Skunkie

    Joined:
    Jul 2, 2012
    Posts:
    75
    Sunshine 1.8.0 is Now Available in the Unity Asset Store
    • Updated Standard Shader for Unity 5.3
    • Fixed bias with scaled meshes
    • Fixed dither texture leaking
    • Fixed Metal compatibility
     
  6. Pomettini

    Pomettini

    Joined:
    Aug 29, 2013
    Posts:
    26
    I don't know if this has been asked before, but is there a way to change the intensity and the color of the shadows? I've tried to tweak the parameters of the directional light, but I cannot find a proper way to do it. Thank you
     
  7. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    The intensity of the shadows should respect the light's "Strength" setting. Let me know if it's not on a specific platform.

    Color is generally not applied and winds up being whatever the ambient light is when the directional light is occluded. I've seen some people write shaders that specifically change color in shadow, so it should be possible.

    Cheers,
    Oren
     
  8. atalStorm8

    atalStorm8

    Joined:
    Aug 12, 2015
    Posts:
    1
    Hi PolyVector,

    Could you point me in the correct direction for adding Sunshine shadows to a custom fragment shader please? I'm confused about using the SUNSHINE_INPUT_PARAMS returned from SUNSHINE_WRITE_SURF_VERTEX in the fragment function.

    Thank you,

    Shader "Sunshine/SunshineDiffuseBRDF" {
    Properties {
    _MainTex ("Base (RGB)", 2D) = "white" {}
    _BrdfMap ("BRDF Map", 2D) = "white" {}
    }
    SubShader {
    Pass {
    Tags { "LightMode" = "ForwardBase" }
    // make sure that all uniforms are correctly set

    CGPROGRAM
    #pragma vertex vert
    #pragma fragment frag
    #include "UnityCG.cginc"
    #include "LightingModels.cginc"

    #define SUNSHINE_MOBILE
    #include "Assets/Sunshine/Shaders/Sunshine.cginc"
    #pragma multi_compile SUNSHINE_FILTER_PCF_2x2 SUNSHINE_FILTER_HARD

    #pragma exclude_renderers flash

    sampler2D _MainTex;
    sampler2D _BrdfMap;

    uniform float4 _LightColor0;
    // color of light source (from "Lighting.cginc")

    struct vertexInput {
    float4 vertex : POSITION;
    float3 normal : NORMAL;
    float2 texcoord : TEXCOORD0;

    };
    struct vertexOutput {
    float4 pos : SV_POSITION;
    float3 normal : NORMAL;
    half2 texcoord : TEXCOORD0;
    float3 worldSpaceViewDir;
    float3 lightDirection;
    // Required Sunshine Params:
    SUNSHINE_INPUT_PARAMS;
    };



    vertexOutput vert(vertexInput input)
    {
    vertexOutput output;

    float4x4 modelMatrixInverse = _World2Object;

    output.pos = mul(UNITY_MATRIX_MVP, input.vertex);
    output.texcoord = input.texcoord;
    output.normal = normalize(mul(float4(input.normal, 0.0), modelMatrixInverse).xyz);
    output.worldSpaceViewDir = normalize(WorldSpaceViewDir(input.vertex));
    output.lightDirection = normalize(_WorldSpaceLightPos0.xyz);
    SUNSHINE_WRITE_SURF_VERTEX(input, output) //"Input" should be the name of your Input struct
    return output;
    }

    float4 frag(vertexOutput input) : COLOR
    {

    float4 diffuseMultiplier = BRDF(input.normal, input.lightDirection, input.worldSpaceViewDir, _BrdfMap);

    fixed4 c = tex2D(_MainTex, input.texcoord) * diffuseMultiplier;
    c.rgb *= c.a;
    return c;
    }

    ENDCG
    }
    }
    }
     
  9. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    You mostly have it right, but SUNSHINE_WRITE_SUFR_VERTEX(input,output) is intended for Surface Shaders. You'll want to switch to SUNSHINE_WRITE_VERTEX(input,output).

    The only step left is to do something with the shadow term in your frag() function. Here's a quick and dirty (and ugly) test you can throw in to make sure things are functioning properly:
    Code (csharp):
    1.  
    2.         //Get Sunshine Light Attenuation:
    3.         fixed shadowTerm = SUNSHINE_ATTENUATION(input);
    4.         c.rgb *= shadowTerm; //TODO: Something fancier with shadowTerm
    5.         return c;
    6.  
    There's an example Vert/Frag shader in Sunshine/Shaders/Examples/Sunshine VertFrag Example.shader that shows the basics.

    If it's working shadowed areas will become black. You'll want to do something nicer with the shadowTerm once you get it working. If your BRDF() code already supports built-in shadows, you can probably modify it to accept Sunshine's shadowTerm instead.

    I hope this helps,

    Happy Holidays!
    Oren
     
  10. Stormbreaker

    Stormbreaker

    Joined:
    Aug 15, 2012
    Posts:
    161
    Hey PolyVector,

    I've used Sunshine for a couple of projects now and it's awesome! However, my current project is set in space and I think Sunshine is running into issues due to the distances involved. For example, if there is an asteroid occluding the directional light, I'm able to see the scatter effect very very faintly when in Scatter debug mode, but is invisible otherwise. Do you have any tips to get it working nicely in large space scenes? I saw another user ran into similar issues last year and was posting in this thread but even his effect looks better than mine. Is the quality tied to Unity's shadow draw distance / cascades by any chance?

    Thanks,
    Marc
     
  11. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hi Marc,
    Sunshine uses its own distance/cascade settings, so the project's QualitySettings shouldn't be causing any issues. Since most of your scene is space, my guess is that Sunshine is treating it as "Sky", which it normally tones down the scatter effect for to avoid washing out skyboxes. I would try increasing the "Sky Intensity" slider and see if that helps any.

    Cheers,
    Oren
     
  12. Stormbreaker

    Stormbreaker

    Joined:
    Aug 15, 2012
    Posts:
    161
    Hi Oren,

    I gave that a go but none of the settings seem to make the asteroid occlusion visible. I've attached a picture of the in-game view, then another with the scatter debug option (notice how the asteroid occlusion is there - but very faint). The third is a picture of my Sunshine settings.
     

    Attached Files:

  13. Stormbreaker

    Stormbreaker

    Joined:
    Aug 15, 2012
    Posts:
    161
    Here's another screenshot with a sky intensity of 0.2, the asteroid scatter doesn't become any more visible.
     

    Attached Files:

  14. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    This is a tough scenario because 99% of the scene's volume would be lit by that star, and the asteroid is only occluding a small fraction of maybe 1%. Since space is supposed to be dark, you only have a subtle scatter effect in which 1% of it is occluded.

    The math is roughly this:
    .372 (37.5% Scatter Intensity)
    *
    .20 (20% Sky Intensity)
    =
    .075 (7.5% Brightness overall)
    *
    .10 (10% Occlusion from an extremely large asteroid)
    =
    0.0075 (0.75% difference in brightness relative to the scene)

    My recommendation at this point would be to raise the sky intensity much higher and use a ramp texture to control the falloff. This way the effect is more intense as you look towards the star, but it doesn't wash out the entire scene.

    Another solution might be to modify Sunshine's postprocess effect to perform a custom blend with your scene that's more appropriate for outer space.
     
  15. daville

    daville

    Joined:
    Aug 5, 2012
    Posts:
    303
    Hi, I have a question before buying, I'm interested, I took a look at the documentation, and as I guessed this Asset requires to replace the Deferred Shader.

    I have other plug ins that I'm trying to make them work together that also require to replace the Deferred Shader... and I would like to know how compatible can this Asset be to those Assets.

    - Alloy ( https://www.assetstore.unity3d.com/en/#!/content/11978 )
    - UBER ( https://www.assetstore.unity3d.com/en/#!/content/39959 )
    - Physically Based Area Lights 2.0 ( https://www.assetstore.unity3d.com/en/#!/content/29575 )
    - Shadow Softener ( https://www.assetstore.unity3d.com/en/#!/content/11102 )

    Basically
    Shadow Softener is easy to make compatible with others.
    Alloy + Uber is provided by Alloy.
    PBAL + Alloy is provided by PBAL
    Alloy + Uber + PBAL kinda works, but not exactly right I'm still trying to figure that out.

    But now I see your Asset and I got interested on it also, but would like to know if there could be any problems with the previous mentioned assets.
     
    hopeful likes this.
  16. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    How compatible Sunshine is depends on what features you're using.

    If you are only interested in the light Scatter, this can safely be combined with everything you listed to my knowlege.

    If you are interested in the custom shadowmapping, this will be more difficult:
    Shadow Softener operates on built-in shadows, not Sunshine, so this will not be compatible. It is possible to use Shadow Softener for Point/Spot lights, and keep Sunshine for Directional, but this could be tricky to pull off.

    Custom shadowmapping with third party shader packs can be difficult since it generally requires shader modification. As you pointed out in the Deferred renderer you would need to merge the replacement Deferred Shaders into a single one. In forward rendering, it would require heavy modification of those shader packs and isn't for the faint of heart.

    I hope this answers your questions.

    Cheers,
    Oren
     
    daville likes this.
  17. zhulaober

    zhulaober

    Joined:
    Jan 19, 2016
    Posts:
    21
    Hi, I'm very interested, and the effect looks amz, but there is only one thing I would like to ask before I purchase ,

    I took a look at the documentation I noticed this is screen based effect , but now, I have mirror in my game.(the mirror is based on water shader) I'm afraid my mirror will not reflect the light Scatter and so on, isn't it ? if so , is there any way I can use it for the mirror ?

    thanks ,
    Laober
     
  18. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I'm pretty sure it would be possible, but at the same time it would be an expensive effect to calculate twice. What you would need to do is attach the SunshineCamera component to the camera rendering reflections. If this camera is created in code and hidden, you'd need to call AddComponent<SunshineCamera>() when it is set up.

    One way to reduce the cost would be to write a script that changes Sunshine's quality settings (accessible through Sunshine.Instance.*) in the Camera's OnPreCull() method. You'd want to use your same script on the main camera to increase quality again.

    I hope this helps,
    Oren
     
  19. zhulaober

    zhulaober

    Joined:
    Jan 19, 2016
    Posts:
    21
    Hi Oren,
    It's very kind of you . thanks for your reply ,
    I'm going to purchase right now, I will try it out :)

    Regards,
    Laober
     
  20. buFFalo94

    buFFalo94

    Joined:
    Sep 14, 2015
    Posts:
    273
    Hi Polyvector your terrain shader does not work it's broken in unity 5.x try to help us
     
  21. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thank you for catching this, it looks like there were some breaking changes in the terrain shaders that I didn't notice. I'll try to get an update out as soon as possible.

    Cheers,
    Oren
     
  22. Skunkie

    Skunkie

    Joined:
    Jul 2, 2012
    Posts:
    75
    Sunshine 1.8.1 is Now Available in the Unity Asset Store
    • Updated replacement Terrain Shaders with newer versions
     
    ksam2 likes this.
  23. PatataFrita

    PatataFrita

    Joined:
    Oct 17, 2014
    Posts:
    50
    Hi, this asset could work with a voxel game that generates all (terrain, house, caves, etc) procedully in runtime?
     
  24. atomicjoe

    atomicjoe

    Joined:
    Apr 10, 2013
    Posts:
    1,869
    Yes, it works in realtime, just like Unity's realtime shadows.
    However it is prettier and a little slower, but you have much more room for optimizations: I used Sunshine with a realtime terrain generator and set it up to update shadows every 2 frames instead of every frame. This way I had actually better performance than unity's builtin shadows.
    It really is an awesome piece of code ;)
     
    Skunkie and PatataFrita like this.
  25. darktide

    darktide

    Joined:
    Mar 31, 2014
    Posts:
    5
    Too much macros used ,so i cant use it with other Shaders.:(
     
  26. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    If you mean Shader Keywords, Sunshine uses about 15 of of the 128 available (or 64 available in Unity 4.x). This problem springs up most in projects that have a ton of installed assets, and frequently many aren't being used. The best thing you can do is remove any shaders you aren't currently using from your project.

    Important: You must restart Unity after cleaning up your project so it can refresh the number used, otherwise the problem will persist.

    I hope this helps.

    Cheers,
    Oren
     
    atomicjoe likes this.
  27. dsmeathers

    dsmeathers

    Joined:
    Jun 12, 2013
    Posts:
    7
    Hi Oren,

    It's a cool package. I've got a bug fix for you though. On Vive (and presumably other VR platforms) it only renders to one eye, the fix was to change:

    Code (csharp):
    1.  
    2.     void OnPostRender()
    3.     {
    4.         if(ShadowsActive)
    5.         {
    6.             Sunshine.Instance.SunLight.shadows = _lightShadows;
    7.             Sunshine.Instance.SunLight.renderMode = _lightRenderMode;
    8.         }
    9.  
    10.         //Turn off Sunshine in the Editor...
    11.         SunshineKeywords.DisableShadows();
    12.     }
    13.  
    To:


    Code (csharp):
    1.  
    2.     void OnPostRender()
    3.     {
    4.         if(ShadowsActive)
    5.         {
    6.             Sunshine.Instance.SunLight.shadows = _lightShadows;
    7.             Sunshine.Instance.SunLight.renderMode = _lightRenderMode;
    8.         }
    9.  
    10.         //Turn off Sunshine in the Editor...
    11.         if ( Application.isPlaying == false )
    12.         {
    13.             SunshineKeywords.DisableShadows();
    14.         }
    15.     }
    16.  
    Cheers,

    Dave
     
  28. dsmeathers

    dsmeathers

    Joined:
    Jun 12, 2013
    Posts:
    7
    One more thing! I ran into the "not enough texture interpolators" problem. It seems like an easy fix for this is to add noshadow to your #pragma line. This stops unity from generating the shadow map coords which gives you a texture interpolator back. If you're using sunshine for shadows then you don't need the built in unity shadow map coords anyway!

    Dave
     
  29. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Hi Dave,
    Thanks for catching this! Just to be sure, this VR issue exists in the latest Sunshine version? (1.8.1).

    I'm a little concerned it could hide built-in shadows from the Scene View when playing the game though. Would it work for you if I only apply the fix on the target platform by checking for UNITY_EDITOR?

    That's a clever trick for sidestepping the interpolator limit, I should add that to the documentation. I'm not sure about adding it to the included shaders though since this will break shadows in the Scene view, and not allow fallback to built-in shadows where Sunshine isn't supported. I'll have to experiment. :)

    Thanks again Dave, I'll see what I can do about pushing an update out... just as soon as I get some much needed caffeine of course.
     
    Last edited: Mar 30, 2016
  30. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Also note that Unity 5.4 has the ability to show effects in the scene view, so that kind of thing will probably become more normal/expected at some point.
     
  31. darktide

    darktide

    Joined:
    Mar 31, 2014
    Posts:
    5
    Thanks very much.I'll try as you sayed.:D
     
  32. dsmeathers

    dsmeathers

    Joined:
    Jun 12, 2013
    Posts:
    7
    Yeah it occurs in the latest version. As I understand it the issue stems from the fact that in VR you will get two OnPostRender() calls between each Update(). It looks like you enable the shadows in Update() and disable them in OnPostRender(). The problem in VR is that after the first eye renders the shadows get disabled, so they're turned off when the second eye gets rendered.

    If you use UNITY_EDITOR rather than Application.isPlaying then the issue will still occur when playing the game in the editor using a HMD. If you can find a way to not need to disable the shadows in OnPostRender() that would be better :)

    Cheers,

    Dave
     
  33. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I see what you mean, hmmm. I'll look into new ways of solving the Scene camera problem today, but we might just have to go with your Application.isPlaying fix.

    Cheers,
    Oren
     
  34. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Just realized you said shadows are set up in Update(), but they are actually set up in OnPreCull() and OnPreRender() which should pair nicely with the OnPostRender() calls.

    Just to be 100% sure, you're running Sunshine 1.8.1?
     
  35. zhulaober

    zhulaober

    Joined:
    Jan 19, 2016
    Posts:
    21

    I tried the method you suggest, but got the error: Recursive culling with the same camera is not possible.
    I use the code below to get mirror reflection,
    https://github.com/AmbBAI/learn_unity/blob/unity4.6/Assets/_Script/MirrorReflection.cs
    and I called
    go.gameObject.AddComponent<SunshineCamera>();
    in CreateMirrorCamera(), then I got the error.
    Can you help me to resolve this problem?
    Thank you.
     
  36. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    You're going to want to put your mirror on its own layer, let's call it "Mirrors".
    Then in Sunshine's settings, make sure that this "Mirrors" layer is not included in the "Occluders" LayerMask.

    I believe that should fix the recursion.

    Cheers,
    Oren
     
  37. zhulaober

    zhulaober

    Joined:
    Jan 19, 2016
    Posts:
    21
    Thanks for your reply. It did fix the recursion, but the sunshine behaves wrong in real world when the camera look at the mirror, also did the mirror reflection, is it possible to fix this? One more question, is the Sunshine support VR? I tested on old run time 0.5 mac, it didn't work, but I have not test on new run time, so I am not sure.
    Thank you.
     
  38. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Behaving wrong in the real world might be caused by the shader you're using to display the reflection. Using a surface shader will probably fix that. Edit: I'm thinking that it might not be filling the CameraDepth buffer, which would screw up the Scatter calculation.

    There are quite a few people using Sunshine for VR successfully. There is a report in this thread a couple posts up but I haven't confirmed that the problem is happening with Sunshine 1.8.1 specifically (we fixed some VR stuff in 1.8.0 so I'm reluctant to issue another bug fix). So basically it should work, and if you run into problems I'll try to work through them with you. :)

    Cheers,
    Oren
     
  39. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    I've been thinking about purchasing this for a while but haven't seen any colorful demos with a transition from being outside to going indoors. I'm also wondering about performance cost if it's the same or is there a boost and lastly will this work with Time of Day - day and night cycling?
     
  40. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    I agree the demos/videos are lacking (and outdated), but Sunshine has been used in quite a few successful commercial titles.

    The cost (of the shadow mapping) is different from built-in; In some cases it's faster, in some cases it's slower, it all depends on your bottleneck. The Volumetric Scattering is quite efficient compared to even the screenspace scatter effect that comes with Unity.

    I haven't used Time of Day, but there's no reason Sunshine can't work with a day/night cycling system. The amount of work to make them play nicely together depends on the package, and I haven't used that particular one before. In Forward rendering, you may need to edit the custom forward-rendered shaders ToD comes with (if any). In Deferred rendering, you may need to edit the replacement Deferred shader ToD come with (if any).

    I hope this answers your questions.

    Cheers,
    Oren
     
  41. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,080
    Can you please reduce the price? I think it's a little expensive and can sell better if price go a little down
     
  42. zhulaober

    zhulaober

    Joined:
    Jan 19, 2016
    Posts:
    21
    Thanks for the reply.
    I tried to change the shader of mirror to a surface shader, but still not work. I am not sure if it can be done by modify the mirror only. So, may I suggest if you could help to do this as outsource, and we will pay for the development for this purpose.
    My game is using mirror from unity water http://wiki.unity3d.com/index.php/MirrorReflection4, and I changed the MirrorReflection code a little, so the mirrors can reflect each other. I need to see the sunshine in the mirror like in real world. Most of my scene is baked.
    I would like to know is it possible the mirror can reflect sunshine correctly no matter what kind of shader it use, as long as it can function like real mirror and reflect with each other.
    Please let me know if you could accept it as outsource.
     
  43. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    That's a different MirrorReflection script, did you just switch? Unfortunately I don't do contract work, but I will spend some time looking into why reflections aren't working properly for you. I'm suspecting now it may be due to the way Sunshine calculates camera vectors, which probably aren't compatible with custom projection matrices.
     
  44. MarcopoloR

    MarcopoloR

    Joined:
    Feb 4, 2015
    Posts:
    114
    Hello, I just got your package, works great in 5.3x, however, you may already be aware of this, but it doesn't seem to work with 5.4 public beta. When I try to run it unchecks(turns off) the sunshine script everytime for some reason, and doesn't show on the game view.
     
  45. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Thanks for the heads up. We're probably going to wait until the beta is a little closer to final release before starting work on compatibility.
     
  46. zhulaober

    zhulaober

    Joined:
    Jan 19, 2016
    Posts:
    21
    Thanks for your time. I did not switch, I used this https://github.com/AmbBAI/learn_unity/blob/unity4.6/Assets/_Script/MirrorReflection.cs c# code and this shader http://wiki.unity3d.com/index.php/MirrorReflection4 to get a mirror. After you mentioned surface shader, I tried to use another c# code and a surface shader to get the mirror, you can find in attached files. If it's impossible or too hard to get the effect, please let me know, I may get some other solution.
     

    Attached Files:

  47. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Okay that makes sense, I must have misread something!

    I spent some time looking into the problem yesterday, and from what I can gather the assumption in my last reply is correct. Sunshine is using a lot of built-in functionality like Camera.WorldToCameraPoint, Camera.CameraToWorldPoint, and Transform.TransformPoint and I believe these calculations break when using custom matrices for reflection. I think if this portion of Sunshine was rewritten to something derived directly from the camera matrices the scatter would look correct in reflections.

    I spent some time attempting this last evening, but my lack of math skill started to show as I only managed to break Sunshine's normal functionality. I will continue to look into this issue, but I can't make any promises. If this is time sensitive, I would look into other solutions.

    Cheers,
    Oren
     
  48. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Anyone has ran a mobile performance comparison between Sunshine and the standard Unity shadows?
    I'm using real time Unity shadows right now on my android/ios and it runs fine but at about 25 fps. I wonder if Sunshine will run faster or at the same speed but looking better.
     
    hopeful likes this.
  49. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    Oren, I use Vertex Colored geometry that uses baked lighting. I have a simple vertex color shader but am having trouble getting it working with Sunshine.



    Here is what my shader looks like (before I modified for Sunshine):
    Code (CSharp):
    1. Shader "Vertex Color/Basic/Basic" {
    2.     Properties {
    3.         _Color ("Color Tint (RGB)", COLOR) = (1, 1, 1, 1)
    4.         _Strength ("Vertex Color Strength", Range(0, 1)) = 1
    5.     }
    6.     SubShader {
    7.         Tags { "RenderType"="Opaque" }
    8.         LOD 200
    9.        
    10.         CGPROGRAM
    11.         #pragma surface surf Lambert vertex:vert
    12.  
    13.         float _Strength;
    14.         float3 _Color;
    15.  
    16.         struct Input {
    17.             float3 vertColors;
    18.         };
    19.        
    20.         void vert(inout appdata_full v, out Input o) {
    21.             UNITY_INITIALIZE_OUTPUT(Input, o);
    22.             o.vertColors = v.color.rgb;
    23.         }
    24.  
    25.         void surf (Input IN, inout SurfaceOutput o) {
    26.             float3 c = IN.vertColors.rgb * _Strength;
    27.             o.Albedo = c.rgb * _Color;
    28.         }
    29.         ENDCG
    30.     }
    31.     FallBack "Diffuse"
    32. }
    33.  
    Can this work with Sunshine?
     
  50. PolyVector

    PolyVector

    Joined:
    Dec 24, 2011
    Posts:
    765
    Yes, but the changes required are slightly different than usual since you have a vertex modifier. Try using this code:
    Code (csharp):
    1.  
    2. Shader "Vertex Color/Basic/Basic" {
    3.    Properties {
    4.      _Color ("Color Tint (RGB)", COLOR) = (1, 1, 1, 1)
    5.      _Strength ("Vertex Color Strength", Range(0, 1)) = 1
    6.    }
    7.    SubShader {
    8.      Tags { "RenderType"="Opaque" }
    9.      LOD 200
    10.    
    11.      CGPROGRAM
    12.  
    13.      #include "Assets/Sunshine/Shaders/Sunshine.cginc"
    14.      #pragma multi_compile SUNSHINE_DISABLED SUNSHINE_FILTER_PCF_4x4 SUNSHINE_FILTER_PCF_3x3 SUNSHINE_FILTER_PCF_2x2 SUNSHINE_FILTER_HARD
    15.      #pragma target 3.0
    16.  
    17.      #pragma surface surf Lambert vertex:vert exclude_path:prepass
    18.  
    19.      float _Strength;
    20.      float3 _Color;
    21.  
    22.      struct Input {
    23.        float3 vertColors;
    24.        SUNSHINE_INPUT_PARAMS;
    25.      };
    26.  
    27.    
    28.      void vert(inout appdata_full v, out Input o) {
    29.        UNITY_INITIALIZE_OUTPUT(Input, o);
    30.        o.vertColors = v.color.rgb;
    31.        SUNSHINE_WRITE_SURF_VERTEX(v, o);
    32.      }
    33.  
    34.      void surf (Input IN, inout SurfaceOutput o) {
    35.        float3 c = IN.vertColors.rgb * _Strength;
    36.        o.Albedo = c.rgb * _Color;
    37.      }
    38.      ENDCG
    39.    }
    40.    FallBack "Diffuse"
    41. }
    42.  
    I hope this helps.

    Cheers,
    Oren
     
    Last edited: Apr 20, 2016