Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Fast Shadow Projector [RELEASED]

Discussion in 'Assets and Asset Store' started by grimworks, Jul 7, 2014.

  1. grimworks

    grimworks

    Joined:
    Jul 7, 2014
    Posts:
    5
    Fast Shadow Projector is a blazing fast, easy-to-use alternative to the Blob Shadow Projector. This projector can render lots of blob shadows that fall correctly on any surface while still maintaining high framerate even on mobile devices.​

    Check it out!:
    Features:
    • Shadows fall correctly on any surface
    • High performance!
    • Render many shadows on a mesh with one draw call
    • Highly customizable: opacity, shape, size, etc.
    • Shadows maintain object’s orientation
    • Use for both - Shadow & Light effects
    • Supports Unity’s terrain – Requires Unity 4.x
    • Supports lightmaps
    • Shadow Triggers – use to determine if GameObject is in shadow area
    • Contrary to many plugins, shadows are projected instead of being quads hovering above surfaces
    • Simple to use – coding is not required for most situations

    Requirements:
    • Unity Pro 3.5.x – 4.x

    Limitations:
    • Supports one projection/light direction at a given time – meaning projection direction is global to all shadow casters, but other shadow settings (size, shape, opacity, etc) can be customized individually.
    Support:
    • We are always thrilled to hear back from our users and we are very open to any suggestions, improvements, etc. regarding Fast Shadow Projector. We are also very quick replying e-mails, so if you'd rather have a personal discussion please don't hessitate to drop us a line at support [AT] thegrimworks [DOT] com.
    Finally, if you've found our asset useful, please don't forget to rate us on the Asset Store. Even a single high rating means everything to us as we can continue developing and updating our assets!
     
  2. zugsoft

    zugsoft

    Joined:
    Apr 23, 2014
    Posts:
    443
    Hello,
    I bought your asset and for moment I have a big issue.
    If I add only a sphere in my scene, and add your Projector Shadow on it, my frame per second drop rapidly to 45, 40,30,25,20...... to 10 in less than 10seconds.

    I sent you a email, I hope you will find the reason.
    I don't use Terrain in my game, I will try to find how can you reproduce this issue.
     
  3. grimworks

    grimworks

    Joined:
    Jul 7, 2014
    Posts:
    5
    Hi menfou,
    Thank you so much for purchasing our asset! The problem you're facing must be due to your scene setup that has something unusual going on. We've received your email and already sent you a reply.
     
  4. grimmgames

    grimmgames

    Joined:
    Jan 11, 2011
    Posts:
    44
    Wow man thanks for this incredible asset. I was able to at least quadruple the number of on-screen enemies in my game by replacing the unity projector with this asset.

    If I could ask for anything it would be some kind of falloff and scaling, so that it gets more transparent and larger as it gets further from the surface it is projecting on to.

    Thanks again for this, as it has really opened up some huge doors for my game.
     
  5. grimworks

    grimworks

    Joined:
    Jul 7, 2014
    Posts:
    5
    Thanks for the kind words, grimmgames. It motivates us to work even harder!

    Regarding falloff-scaling, you can adjust size and opacity of each shadow individually (just set the opacity and size values by code and this will give a feel of falloff) if you can determine the distance from your enemies to the ground.

    Implementing falloff/scaling inside Fast Shadow Projector in a flexible/generic manner would require us to use raycasting for each shadow caster and this would degrade performance as it's expensive if called many times per frame. Usually the user code that moves characters around the scene knows/has calculated most of the info regarding the distance from ground to character. This means FSP would have to recalculate this again. So in the near future we're planning to at least provide a method that you could call and fetch the distance to ground of a shadow projector, then FSP would scale/change opacity of the shadow accordingly.
     
  6. grimmgames

    grimmgames

    Joined:
    Jan 11, 2011
    Posts:
    44
    I went ahead an created a code-based solution for scaling and alpha based on distance from the ground. I ran into the global shadow resolution issue, where it gets set to low when I play the scene. Easy enough to Invoke a method to set it as a workaround.

    Any way to limit the projection to certain relative angles? i.e. I have mesh objects that include the floor and walls as part of the same mesh, but I don't want the projector to hit the walls... only the floor.

    Thanks again for this great asset.
     
  7. grimworks

    grimworks

    Joined:
    Jul 7, 2014
    Posts:
    5
    Regarding, floor vs walls projection problem. One rather simple, but maybe not that practical solution, would be this:
    1) produce a very low poly version of your floors - actually the less polygons the better.
    2) add them to the scene
    3) adjust the Transform to match the original floor's position/rot/scale (don't remove the orignal floors/walls)
    4) disable MeshRenderer on the new floors
    5) remove shadow projector from the wall/floor mesh and add it to the new invisible floor instead.
    6) result: you'll have shadows being projected onto invisible floors.

    This approach has 1 additional benefit: even more performance gain. FPS won't spend time processing wall geometry as there will be none and if you can make the "invisible" floors extremely low polygon you can gain even more fps. Of course, the main drawback is that the 3d artists of your game will need to spend additional time preparing low-poly versions of floors and similar objects.

    If this solution doesn't fit your development process, please e-mail us at support@thegrimworks.com so that we can look closer into your problem and exchange scripts/scenes/packages easier.
     
  8. grimmgames

    grimmgames

    Joined:
    Jan 11, 2011
    Posts:
    44
    lol yeah that is exactly what I did immediately after I posted my last message, and it works perfectly for my game. Thanks again!
     
  9. grimworks

    grimworks

    Joined:
    Jul 7, 2014
    Posts:
    5
    No problem, we're glad the plugin fits your needs!
     
  10. BonyYousuf

    BonyYousuf

    Joined:
    Aug 22, 2013
    Posts:
    110
    Hey,
    I sent you an email yesterday and still haven't heard from you. I was interested in your Fast Shadow Projector. But I was hoping if there is a way by which I can try it out before paying for it. Maybe a demo version or something? Just so I can check if this plugin meets my need or not?

    Please let me know.
    Thanks
     
  11. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,183
    So as far as the limitations go, you cannot have multi-directional lights that cast multi-shadows from one object? Is this assumption correct? Would it be possible to add this if it is missing?
     
  12. BonyYousuf

    BonyYousuf

    Joined:
    Aug 22, 2013
    Posts:
    110
    Hey, is this working on Unity5? I need it to work on Unity5 with WebGL.
     
  13. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    1,171
    If this runs faster than the built in blob shadow projector, how does it achieve that boost?
     
  14. springbaby

    springbaby

    Joined:
    Nov 20, 2014
    Posts:
    1
    hello I bought your asset and i have a problem that how can i projector my custom model such as tank,actor...
     
  15. TheEvilRabbit

    TheEvilRabbit

    Joined:
    Aug 25, 2014
    Posts:
    26
    Hi guys. getting weird shadow artefacts other gameobjects now - and they are not projectors. Only one light and 1 place set to receive. See attached: http://prnt.sc/ceql85
     
  16. TheEvilRabbit

    TheEvilRabbit

    Joined:
    Aug 25, 2014
    Posts:
    26
    SOLVED: Quick replay from the developers and turns out I have other game objects set to the GlobalProjectorLayer layer.
     
  17. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    734
    Great asset but I have some corruption (possibly precision problem) going on. Long procedural race track. at th start line, shadow looks okay, but random noise pixels all over my terrain mesh.
    At >20 or 30 Units from 0,0,0, the shadow becomes skewed ad unrecognizeable, (it should be ortho, top-down shadow) and random noise pixels dance all over the terrain (receiver) geometry.

    How do I get rid of the noise?... and do I need to constantly update bounds(assuming generating track as user plays) ? if so, how / what bounds please ?

    Help appreciated, thanks
    Jon
     
    haim96 and vincespeed like this.
  18. vincespeed

    vincespeed

    Joined:
    Mar 8, 2014
    Posts:
    51
    Know this thread has being quiet for a long time, but I stumbled into the exact same problem reported from you, did you find a solution to that?
     
    haim96 likes this.
  19. haim96

    haim96

    Joined:
    May 24, 2013
    Posts:
    93
    yap, i have the same issue! i have a procedural track made from blocks, each block have shadow receiver script.
    for the few first blocks, everything looks great. but after that, over time the shadow start flickering.
     
  20. vincespeed

    vincespeed

    Joined:
    Mar 8, 2014
    Posts:
    51
    I solved this issue by setting the "shadow cull distance" in the update. If you cull too far shadows, the ones near to the camera will keep being good. But for some strange reason setting "shadow cull distance" in the editor doesn't seem to work properly. Try setting that in the update :)
     
    JonnyHilly likes this.
  21. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    734
    The shadow quality may decrease if you have multiple shadow projectors that are far apart. In this case the shadow resolution starts decreasing as the shadow texture has to zoom out more and more to accompany all shadows. Setting the global culling options usually helps, alternatively you can track the projectors yourself and make sure you turn of projectors that are not visible or very far away from the viewer.
     
  22. haim96

    haim96

    Joined:
    May 24, 2013
    Posts:
    93
    well... answers came too late. i drop the solution and use unity's projector. even if it's less effective it's still much better then real time shadow and give me the results i need. thanks!
     
  23. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    8,319
    I've been using Unity's projector this week, but I'm very frustrated with it — it's terrible in terms of draw calls and materials, and it draws right through higher-level terrain onto lower levels.

    I'm hoping this asset will do a better job. We will be drawing a lot of shadows (one per enemy) all over the level. And this is for Oculus Go, so it really needs to perform well. Anyone want to share their impressions?
     
  24. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    8,319
    I decided to give this asset a try. Right away though I see it suffers from the same problem as the Unity projector: it projects right through things.

    upload_2018-9-28_18-43-5.png

    Is there any simple way to fix this? I guess I can cast a ray down and adjust the cutoff distance accordingly...

    EDIT: No I can't, because the cutoff distance is a global property. How are people solving this?
     
    Last edited: Sep 28, 2018
  25. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    8,319
    Hmm, and the other thing I notice upon testing on the device (Oculus Go) is that the shadows wiggle and squirm around quite a lot, even for completely stationary objects.

    I imagine this is because there are other shadow casters moving around, causing the whole combined texture to be recomputed (perhaps at varying size depending on their combined bounding box?). It's quite noticeable on stationary objects. Not sure if it's a show-stopper for this game, as we won't have too many stationary objects most of the time, but we do have a few.

    Is there any way around that?
     
  26. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    734

    Just getting back to trying this again... @vincespeed where is that variable you are trying to continuously set? not unity settings is it ? unity quality settings, has this variable..."QualitySettings.shadowDistance"
    but I cannot find "shadow cull distance" on the fastShadow scripts or docs
    Camera component has "layerCullDistances" but which one did you adjust ?

    also...anyone know "why" the resolution gets super blurry if you move the camera around the level ? do new shadows just expand a max bounds or something ?

    Why doesn't shadow res stay same size, and just follow the camera around the map, centered on the camera.... that would be preferable... Where is the code that controls that part ?
     
    Last edited: Jan 11, 2019
  27. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    734
    I looked through the code to figure out how it works...
    It uses the shadow projectors to calculate the render bounds for the shadow texture, so if the projectors are far apart the showoff resolution is stretched very thin low res. and if they are close together the shadow resolution is sharp.
    If objects are turned on and off dynamically, the resolution can flicker dramatically from frame to frame.

    I'd like the shadow render's texture bounds to be a "fixed bounds", around the main camera's position, so the shadow quality is consistent.

    I tried changing the code a bit, but without success (see below) any other ideas or suggestions welcome....

    See GlobalProjectorManage.cs ~line 460

    Code (CSharp):
    1.          
    2.             bool useLocalCamHack = true;
    3.             if(useLocalCamHack)          //true = user main camera, position and fixed bounds
    4.             {
    5.                 _projectorBounds.center = Camera.main.transform.position;
    6.                 _projectorBounds.size = Vector3.one * 45f*.5f;
    7.             }
    8.             else if (projectorIndex == 0)
    9.             {
    10.                 _projectorBounds.center = shadowProjector.GetShadowPos();
    11.                 _projectorBounds.size = Vector3.zero;
    12.  
    13.             }
    14.             else
    15.             {
    16.                 _projectorBounds.Encapsulate(shadowProjector.GetShadowPos());
    17.             }
     
    Last edited: Jan 18, 2019
  28. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    734
    bump ? anyone ?
     
  29. S-Miyahon

    S-Miyahon

    Joined:
    Jun 30, 2016
    Posts:
    12
    Has this asset been abandoned, or can we still get support here?
    Today I made an attempt to use blob shadows in connection with Unity's standard scene fog, and this happened:
    upload_2019-1-22_15-41-32.png
    Is there any way of making the multiplicative shadow shader handle Unity's scene fog correctly?
     

    Attached Files:

  30. JonnyHilly

    JonnyHilly

    Joined:
    Sep 4, 2009
    Posts:
    734
    So when fog is on, its making that double ghost shadow for each cube? but when fog is off, the shadows look normal with no ghosting? Maybe you can edit their script when it does the shadow render, disable fogging first.... then re-enable after the render is finished... You want the fog to only effect the main camera, not their render camera.

    also check your shadow price texture.... make sure alpha/color is zero. Just a random thought that anything non-zero might be affected by the fog.

    I think no support anymore on this forum.. :/
     
    Last edited: Jan 30, 2019
  31. akirabeta

    akirabeta

    Joined:
    Apr 12, 2018
    Posts:
    1
    I ran into this issue as well, after comparing the shader of FSP with the official one from the blob shadow projector, i managed to solve this issue.

    1. Open Assets\FastShadowProjector\Shaders\BlobShadowMultiplyShader.shader
    At line 9 locate:
    Fog { Color (1, 1, 1) }
    replace with:
    Fog { Mode Off }

    2. Open Assets\FastShadowProjector\Resources\Shaders\FastShadowProjectorMultiply.shader
    Step.1 At line 19 it was:
    Fog { Color (1, 1, 1) }
    delete or comment out it like:
    //Fog { Color (1, 1, 1) }

    Step.2 At line 24 (it was an empty line) add:
    #pragma multi_compile_fog

    Step.3 Locate struct v2f it was:

    struct v2f
    {
    float4 pos : SV_POSITION;
    float4 uv_Main : TEXCOORD0;
    float4 uv_MainClip : TEXCOORD1;
    };
    add a line:
    struct v2f
    {
    float4 pos : SV_POSITION;
    float4 uv_Main : TEXCOORD0;
    float4 uv_MainClip : TEXCOORD1;
    UNITY_FOG_COORDS(2)
    };

    Step.4 Locate v2f vert(appdata_tan v)
    add a line:
    v2f vert(appdata_tan v)
    {
    v2f o;
    o.pos = UnityObjectToClipPos (v.vertex);
    o.uv_Main = mul (_GlobalProjector, v.vertex);
    o.uv_MainClip = mul (_GlobalProjectorClip, v.vertex);
    UNITY_TRANSFER_FOG(o,o.pos);
    return o;
    }

    Step.5 Locate half4 frag (v2f i) : COLOR
    add a line:
    half4 frag (v2f i) : COLOR
    {
    half4 tex = half4(i.uv_Main.w, i.uv_Main.w, i.uv_Main.w, 1);

    if (i.uv_MainClip.w < 1.0f) {

    tex = tex2D(_ShadowTex, i.uv_Main.xy);
    }
    UNITY_APPLY_FOG_COLOR(i.fogCoord, tex, fixed4(1,1,1,1));
    return tex;
    }

    hope this helps.