This simple Unity asset provides a few components to render a shadow onto a render texture so that the render texture can be used with Blob Shadow Projector. Blob Shadow Projector is usually used for dropping a round blurry shadow which is not suitable for a skinned mesh object. This asset enables a projector to drop a dynamic shadow which is perfect for skinned mesh objects.

Below images are examples of shadows generated with this asset. As shown in these images, this asset can generate various shadows such as a hard shadow (left), a soft shadow (center), and a blob shadow (right).
hardshadow softshadow blobshadow

This asset can be a good alternative of shadowmap for mobile platform, because it doesn’t require depth textures, and it works on almost all devices. However, Blob Shadow Projector can be very slow on mobile platform. If you are satisfied with the quality of the shadows but not satisfied with the performance, please try our another asset, Fast Shadow Receiver. It really improves the performance of Blob Shadow Projector.

Using with Lightweight/Universal RP

Projector component doesn’t work under Scriptable Render Pipeline. You need to install the following components from Github. If you are using Lightweight RP, please checkout master branch, If you are using Universal RP, checkout master-universalrp branch. If you are not using Git, you can download zip files.

Documents

Links

126 thoughts on “Dynamic Shadow Projector

  • 2015/04/24 at 3:45 AM
    Permalink

    Is Dynamic Shadow Projector part of the Fast Shadow Receiver plugin, or is it a separate plugin? When will it be available?

    Also, does the Dynamic Shadow Projector support multi-shadow casting from multi-directional lights in the scene? This would be a huge plus and make the asset extremely valuable.

    Reply
    • 2015/04/24 at 11:05 AM
      Permalink

      Thank you for the comment.

      Dynamic Shadow Projector is a separate plugin, but it will be free. I will submit this asset this weekend. I hope it will be on Asset Store in a week.

      It is possible to cast multi-shadow, you will need a projector for each directional light.

      Reply
  • 2015/04/25 at 2:34 AM
    Permalink

    Thank you for the information. I’m looking forward to using it. Will we be able to combine this with Fast Shadow Receiver, or are they used separately?

    Reply
    • 2015/04/25 at 2:44 PM
      Permalink

      Yes, it is recommended to combine this asset with Fast Shadow Receiver. In fact, I made this asset for promoting Fast Shadow Receiver 😉

      Reply
  • 2015/05/05 at 6:30 AM
    Permalink

    Any updates on how development of this plugin is going? 🙂

    Reply
    • 2015/05/05 at 12:48 PM
      Permalink

      I already submitted this asset but it is still pending for review. Also I found a little bit severe bug. I don’t know if it affects the review or not. I am waiting for a response from Unity 🙁

      Reply
      • 2015/05/06 at 1:43 AM
        Permalink

        No problem. That’s great to hear it’s going live soon. All the best. 🙂

        Reply
        • 2015/05/08 at 10:16 AM
          Permalink

          It is now on Asset Store! Thanks for waiting for long time.
          But it still have a bug (a memory leak). I will update the asset soon.

          Reply
          • 2017/06/19 at 6:02 PM
            Permalink

            I assume the memory leak was fixed some time ago?

            Reply
          • 2017/06/20 at 6:27 PM
            Permalink

            Yes, it was fixed in version 1.0.1.

            Reply
  • 2015/06/10 at 7:16 PM
    Permalink

    Hi, I’m trying to make car headlights shadows, but when i set up everything I get sharp shadow at projectors borders. How can I get the borders soft like the rest of the shadows? I wanna buy the Receiver but I have to be sure that it works as I want.

    Reply
    • 2015/06/11 at 3:41 AM
      Permalink

      Hi, thank you for using my asset! Are you using SpotlightWithShadow shader for your headlights shadows, like Spotlight sample? If you want to make the shadows softer, please try to make the light cookie texture more blurry. Then, the borders will look more natural.

      Reply
  • 2015/09/15 at 11:06 AM
    Permalink

    Hello, if I add your projector to a mesh, the tris count doubles. Is there any way to minimize this number for mobile?

    Reply
    • 2015/09/15 at 12:31 PM
      Permalink

      A projector acts like a camera. So, if you add a projector into your scene, that means you add a special camera into your scene. It will increase the actual count of tris, but it seems like the tris count displayed in the stats window does not count the triangles drawn by a projector. So, I guess the reason why the tris count doubled is you have a hipoly character and tris count for rendering shadow texture doubled the tris count. It is inevitable if you want to have a dynamic shadow. Using shadowmap will also double tris count. If you want to reduce it, please consider using a low-poly character for the shadow.

      Reply
  • 2015/10/01 at 9:47 PM
    Permalink

    Hi!
    first, thank you very much for creating this plugin! it is exactly what i have been looking for and works great! Thanks!

    at the moment i am facing one problem: i have a plane in the scene which is the shadowreceiver and it uses the “light with linear fallof” shader. when i create another plane underneath of my shadowreceiverplane and assign a Unlint/Transparent shader to this second plane, the shadowreceiverplane gets invisible.
    i tried already pretty much, but it is always the same, when the second plane unterneath get a shader with transparency.

    can you help me out here or give me a hint how to solve that problem?
    i would appreciate your help! thanks!! 🙂

    Reply
    • 2015/10/01 at 11:29 PM
      Permalink

      Hi, thank you for your feedback.
      The default render queue value of the “light with linear falloff” is “Transparent-1”. That means shadowreceiverplane will be drawn after all the opaque polygons are rendered, and before any of transparent polygons are going to be rendered. Also, it doesn’t write z value on depth buffer. So, it is easily overdrawn by transparent polygons. I guess, that is the reason of your problem. To solve the problem, you can change the render queue value of the material.
      Please try material.renderQueue = 3000; 3000 means “Transparent”.
      http://docs.unity3d.com/ScriptReference/Material-renderQueue.html

      Reply
    • 2015/10/01 at 11:33 PM
      Permalink

      hi, i solved the problem. had to change the transparent shader. (Queue to Geometry and RenderType to Opaque)

      🙂

      Reply
  • 2016/02/28 at 2:50 PM
    Permalink

    The basic demo runs but with the following errors. It won’t do a build.

    “RenderTexture.Create failed: format unsupported.
    UnityEngine.RenderTexture:GetDepthBuffer(RenderBuffer&)
    UnityEngine.RenderTexture:get_depthBuffer() (at C:\buildslave\unity\build\artifacts\generated\common\runtime\TextureBindings.gen.cs:911)
    UnityEngine.Graphics:SetRenderTargetImpl(RenderTexture, Int32, CubemapFace) (at C:\buildslave\unity\build\Runtime\Export\Graphics.cs:186)
    UnityEngine.Graphics:SetRenderTarget(RenderTexture) (at C:\buildslave\unity\build\Runtime\Export\Graphics.cs:201)
    DynamicShadowProjector.ShadowTextureRenderer:OnPostRender() (at Assets\DynamicShadowProjector\Scripts\ShadowTextureRenderer.cs:871)
    UnityEngine.Camera:Render()
    DynamicShadowProjector.ShadowTextureRenderer:Update() (at Assets\DynamicShadowProjector\Scripts\ShadowTextureRenderer.cs:575)”

    Help please.

    Reply
    • 2016/02/29 at 1:25 AM
      Permalink

      Thanks for the feedback.
      Could you tell me about your environment (OS, target platform, Unity Version, etc.)? I can’t reproduce the problem.

      Reply
  • 2016/04/15 at 3:52 PM
    Permalink

    I follow the tutorial to setup shadow projector.
    But after I add “Draw Target Object” script and try to assign the material into projector, Unity crashes. (100%)

    My environment :
    OS is PC, Win 7
    Unity version is 5.3.3f1

    Reply
    • 2016/04/18 at 11:49 AM
      Permalink

      Can you try to change Multi Sampling to “x1”? Another person reported me that Multi Sampling caused a crash on a specific device before. Please let me know if it works or not.

      Reply
      • 2016/04/18 at 6:07 PM
        Permalink

        Thanks for your reply.
        I’ve tried to change Multi Sampling to “x1″ but Unity still crashes.

        Reply
        • 2016/04/19 at 5:08 PM
          Permalink

          Maybe you miss a camera in the Scene!

          Reply
          • 2016/04/20 at 10:28 AM
            Permalink

            Yes! I don’t have camera in my scene hierarchy (Due to some reason, I create camera at run time).
            After I put camera in scene hierarchy, everything works fine. Thanks a lot!

            May I consult a question? If I have 2 models, model A & model B project their shadows on floor. But some part of model A is cover on model B, can I project model A’s shadow on model B too ? How to do it?

            Thanks.

            Reply
          • 2016/04/20 at 3:01 PM
            Permalink

            Hi Iceman, thanks for the information! Yesterday, I could not reproduce the crash, but somehow, I could get the crash today. I sent a bug report to Unity already.

            Hi Kidd, you might need to use different layers for object A and B, and only the layer of A should be ignored by the projector of A.

            Reply
        • 2016/04/19 at 6:01 PM
          Permalink

          Whatever you (and I) did, Unity should not crash. Try the latest version of Unity, and if it still crashes, please send a bug report to Unity. I cannot reproduce the crash on my PC.
          Thanks

          Reply
        • 2016/04/19 at 7:11 PM
          Permalink

          By the way, can you open and play a sample scene? Also, try another shader for the material.

          Reply
  • 2016/06/27 at 4:16 AM
    Permalink

    Hi Nyahoon,

    Really liking the projector, but I am running into one problem. When I put the shadow caster onto my character and stand close to a wall, I see an inverse shadow going in the opposite direction on that wall.

    See this for example: http://starvingeyes.com/temp/shadowProjectorProblem3.jpg

    I have discovered that turning off HDR on my main camera fixes this, however, I definitely need HDR in my game. It seems that the ortho camera attached to the shadow caster when partially inside a wall creates this strange effect. Is there any trick to fixing this? I’ve fiddle around with the settings a lot and cannot find a simple solution.

    If this does not work, would getting the fast shadow receiver prevent this problem?

    Thank you very much,
    Jason

    Reply
    • 2016/06/27 at 12:47 PM
      Permalink

      Hi Jason,

      Thank you for using our asset and letting me know about the problem. I had not considered about floating point render target. Maybe I need to fix my projector shaders. Can you try the following fix?

      In DynamicShadowProjector/Shaders/Projector/DSPProjector.cginc, there is a function named “DSPGetShadowAlpha”. Please change this function as follows (add one more “saturate”):

      I hope it can fix the problem. Also, it might be better to push the near clip plane of the shadow projector up to the feet of the character.

      Reply
      • 2016/06/27 at 7:44 PM
        Permalink

        Excellent! Thank you. Yes, it worked. Great response time also! Loving the way this is working!

        Reply
  • 2016/09/05 at 10:35 AM
    Permalink

    Hi, due to the nature of my game I do not wish to use the lighting system on my character, so I was very happy to have found this asset, however, when I went to add in NPC characters I discovered that simply duplicating the projector and changing the target does not work the way one would expect. Rather than being separate, it seems like all the projectors are linked somehow? Is there a way to fix this so that my NPC characters can also have dynamic shadows?

    Reply
    • 2016/09/05 at 11:25 AM
      Permalink

      This is because you are using a same material for all the characters. As a result, all the characters share the same render texture. This problem will not happen when you run the scene, because the material will be duplicated at runtime. If you want to fix this problem in Editor, please duplicate the material for each character.

      Reply
  • 2016/12/07 at 8:52 AM
    Permalink

    Hi Nyahoon,

    The projector has been working great until I updated from 5.3.3 to 5.5.

    In my project I get:

    NullReferenceException: Object reference not set to an instance of an object
    DynamicShadowProjector.DrawTargetObject.AddDrawCommand (UnityEngine.Renderer renderer, Int32 renderTypeIndex) (at Assets/DynamicShadowProjector/Scripts/DrawTargetObject.cs:308)
    DynamicShadowProjector.DrawTargetObject.UpdateCommandBuffer () (at Assets/DynamicShadowProjector/Scripts/DrawTargetObject.cs:136)
    DynamicShadowProjector.DrawTargetObject.OnPreCull () (at Assets/DynamicShadowProjector/Scripts/DrawTargetObject.cs:259)

    When I create a fresh project and try to use the tutorial scene, I get a lot of:

    RenderTexture.Create failed: format unsupported – 5.
    UnityEngine.Camera:Render()
    DynamicShadowProjector.ShadowTextureRenderer:Update() (at Assets/DynamicShadowProjector/Scripts/ShadowTextureRenderer.cs:586)

    any guidance or help here? This is pretty important to my project and I don’t want to ditch this projector. I see you recently updated, but the package is using Unity 5.0.1.

    Thanks,
    Jason

    Reply
    • 2016/12/07 at 9:59 AM
      Permalink

      I think I figured out the problem. You have to make the draw target the skin of your animated character and not have it be targeted to the shell (like before). The second error in the tutorial can be eliminated by turning off the blob shadow sample. Not sure what that’s all about. Thanks, sorry for clogging up your boards with this.

      Reply
      • 2016/12/08 at 8:46 AM
        Permalink

        Hi, thank you for telling us about the problems, but I couldn’t reproduce them so far.

        Does the shell object have any invalid renderers? The first error means there was a renderer that has a null material or a null shader in the shell object or in its children.

        Reply
  • 2016/12/20 at 9:53 AM
    Permalink

    Hi!

    I got this Volumetric Light script that uses the built in shadow. It won’t work unless I have the Light Shadow set to either Hard or Soft. Is there a way to edit the shadow from the Light object instead of the one from the projector?

    Amazing asset by the way!

    Reply
    • 2016/12/20 at 12:43 PM
      Permalink

      Hi Carl,

      Thank you for using our asset! This asset uses a projector to cast a shadow, not a light, so built in shadow must be turned off. If you cannot see any shadow unless you set either Hard or Soft to Light Shadow, that means something was wrong with the projector setup. Please check if the projector has a right material.

      Reply
  • 2016/12/21 at 12:28 AM
    Permalink

    Hello,

    First of all I want to thank you for the complex and very useful asset, but I seem to have a single issue. If there is something placed between the projector and the shadow casting object, that thing gets shadowed. Is there a way to avoid that? Does your paid plugin handle such situations?

    Reply
    • 2016/12/21 at 11:30 AM
      Permalink

      Hi Teshla,

      Thanks for the comment. That is a common problem of a projector. You can set a larger value to the near clip plane of the projector. This value is not used for the shadow texture rendering, so the shadow casting object does not need to be entirely covered by the near clip plane.

      Reply
  • 2017/03/10 at 2:36 AM
    Permalink

    Hi Nyahoon Team,

    Does Dynamic Shadow Projector work with iOS?
    Sorry I was trying to find information but I couldn’t see anything.

    Regards

    Gareth

    Reply
    • 2017/03/10 at 11:05 AM
      Permalink

      Yes, it should work on any platform. Do you have any problems?

      Reply
      • 2017/03/11 at 8:56 PM
        Permalink

        Yes. The shadows work on Android but they are not visible in iOS. Do you think it may be something in my build settings I need to look at?

        Reply
        • 2017/03/11 at 11:31 PM
          Permalink

          Which shader do you use for your projector? Mipmapped shadow shader will not work on some devices. However, as far as I know, it should work on iOS devices.

          Reply
  • 2017/04/09 at 4:15 AM
    Permalink

    it works like a charm, but I get this errors in the console:

    Rendering camera ‘BlobShadowProjector’, but calling code does not set it up as current camera (current camera: ‘Main Camera’)
    Rendering camera ‘SoftShadowProjector’, but calling code does not set it up as current camera (current camera: ‘BlobShadowProjector’)
    Rendering camera ‘HardShadowProjector’, but calling code does not set it up as current camera (current camera: ‘BlobShadowProjector’)

    Unity 5.6.0f3

    Reply
    • 2017/04/09 at 4:12 PM
      Permalink

      Please ignore those error messages. You will get those errors only in edit mode. ShadowTextureRenderer calls Camera.Render function to render shadow textures in edit mode, but in game mode, the camera renders shadow textures normally and Camera.Render is never called. It seems like the error message is always shown when Camera.Render is called in Unity 5.6.

      Reply
      • 2017/04/09 at 6:29 PM
        Permalink

        Thank you for the quick response this great asset!

        Reply
  • 2017/05/21 at 3:50 PM
    Permalink

    Thank you for all of this, it help me to achieve the desired effect, but there is something wrong with Unity5.6.1

    Reply
    • 2017/05/22 at 6:19 PM
      Permalink

      Thank you for the bug report. I will investigate this problem.

      Reply
  • 2017/05/21 at 6:08 PM
    Permalink

    Hi,

    I’m really enjoying your Dynamic Shadow Projector, but I’m having some issue after upgrading to Unity 5.6.1. All my shadows are now just black squares. Just thought I would let you know in case no one has reported it yet.

    Reply
    • 2017/05/22 at 6:21 PM
      Permalink

      Thank you for your bug report. I will investigate this problem.

      Reply
  • 2017/05/24 at 5:22 PM
    Permalink

    Hi,
    I have the same bug using Unity 5.6.
    Have you managed to solve it?

    Thanks a lot for your help!

    Reply
    • 2017/05/24 at 6:14 PM
      Permalink

      No. Please use Unity 5.6.0 or lower for now. I already sent a bug report to Unity.

      Reply
      • 2017/05/24 at 6:39 PM
        Permalink

        I’m using already Unity 5.6.0, the bug happens in this version too… i’ll have to come back to 5.5

        Thanks a lot again

        Reply
        • 2017/05/25 at 11:03 AM
          Permalink

          Which version of the asset are you using? Version 1.0.6 has workarounds for Unity 5.6 bugs.

          Reply
          • 2017/05/26 at 9:53 PM
            Permalink

            I’ve just upgraded to the latest version but am still getting the same issues as the previous. Perhaps there was a mistake with the .unitypackage upload or something?

            I’m using Unity 5.6.0p4.

            Reply
          • 2017/05/27 at 12:00 PM
            Permalink

            I confirmed that Unity 5.6.0f3 doesn’t have the issue.

            Reply
          • 2017/05/27 at 11:09 PM
            Permalink

            Actually, Unity 5.6.0p4 had the same issue. This bug must be introduced at this version.

            Reply
  • 2017/05/28 at 3:20 AM
    Permalink

    That’s odd, I was getting these issues with the Unity 5.6 beta as well a few months back. Odd that 5.6.0f3 would be OK whereas p4 isn’t :/ Maybe they took something out of the beta for the initial release that went back in with a patch.

    Reply
    • 2017/05/28 at 7:37 PM
      Permalink

      This issue is very similar to the bug of Unity 5.6 beta, but different one. The workaround I added no longer works for this issue.

      Reply
    • 2017/06/08 at 12:08 PM
      Permalink

      You mean overlapping shadows? That is also a common problem of Unity’s projector, and handling this problem is beyond the scope of this free asset. From Unity 5.6, shadow mask is available, and if you can use it in projector’s shader, you might be able to handle this problem. However, it is a bit complicate. You will need to duplicate a projector for each static shadow receiver so that the projector’s shader can read a baked shadow mask texture.

      Reply
  • 2017/07/20 at 11:53 AM
    Permalink

    For some reason the shadow textures don’t seem to update when the object rotates.
    Even in the demo scenes…
    Any ideas as to why?

    Reply
    • 2017/07/20 at 7:42 PM
      Permalink

      In version 1.0.6, shadow textures are not updated automatically. Please select the shadow projector object in Hierarchy view to update the texture. I will fix this problem in the next version.

      Reply
  • 2017/08/11 at 3:14 PM
    Permalink

    Hi there!

    I really appreciate this asset you’ve created and the work you’ve put into it (and the fact that it’s free). Any idea when you might release the next update? Unfortunately in Unity 5.6.1 it’s broken for me 🙁

    Thanks again and I look forward to crediting you in my game once it comes out someday 🙂

    Reply
    • 2017/08/11 at 8:07 PM
      Permalink

      Thank you for your comment. Actually, this asset has a problem in Unity 5.6.1, and we couldn’t find any workarounds so far. We believe this is a Unity’s bug, and we sent a bug report already. Please use Unity 5.5 or Unity 2017 for now.

      Reply
  • 2019/06/02 at 8:07 PM
    Permalink

    How do I stop the shadow passing through solid objects?
    The clip planes don’t seem to have any effect.

    Reply
    • 2019/06/03 at 6:56 PM
      Permalink

      The clip planes are used for clipping receiver objects. If a part of a receiver object is inside the clip planes, it will receive a shadow, even if the shadow area is outside the clip planes. To prevent this issue, please use “With Linear Falloff” shaders instead of “Without Falloff”. Then, the shadow will be invisible outside the clip planes.

      Reply
  • 2019/09/13 at 7:16 PM
    Permalink

    m_BuffersToBind[shaderType][bind].buffer == NULL
    I used untiy 2019.2.4, open demo show this error

    Reply
    • 2019/09/16 at 10:06 PM
      Permalink

      Thank you for sharing the information about the problem. It seems like the error is shown when MipmappedShadow shader is used. Only Windows version had this problem. I couldn’t see any error on Mac version of Unity. I will investigate this issue more.

      Reply
      • 2019/09/17 at 6:47 PM
        Permalink

        I fixed this issue in version 1.0.9. It is already available on Asset Store.

        Reply
        • 2019/09/23 at 5:04 PM
          Permalink

          Good job! Its work o( ̄▽ ̄)d
          I found other two problem!
          1. DynamicShadowProjector.cs -> m_layerMask no use?
          2. In my project when rendering TextmeshPro must Crash.
          Error is Dynamic batching: index buffer source is NULL

          Reply
          • 2019/09/24 at 4:05 PM
            Permalink

            Thank you for the bug report!

            I forgot to use m_layerMask in version 1.0.8. I will fix it and update the asset soon.

            Do you mean you got a crash when trying to render shadows of TextMesh Pro meshes? I tried to reproduce the problem, but I couldn’t. Can you elaborate how to reproduce the error?

            Reply
        • 2020/04/05 at 8:55 AM
          Permalink

          Hi, I’m having a similar error in a shader I’m converting from built-in pipeline in URP.
          As there’s not much docs available on the web, how did you solve this error?
          Assertion failed on expression: ‘m_BuffersToBind[shaderType][bind].buffer == NULL’
          What was causing it in your case?
          Thank you very much for your help!
          G.

          Reply
          • 2020/04/06 at 11:27 AM
            Permalink

            Hi, in my case, the error happened if there are more than one CBUFFERs that have the same name.

            Reply
  • 2019/09/22 at 10:46 PM
    Permalink

    Hi,

    I am evaluating the Dynamic Shadow Projector ahead of purchasing the Fast Shadow Receiver. Is there a guide for integrating the two packages?

    I have found a bug in version 1.0.9 (confirmed in both Unity 2017.4.9 and 2018.4.9), the shadow is just a solid rectangle in edit mode if either Blur Level or Mip Level is greater than 0. There doesn’t seem to be an issue during PlayMode, but it makes it hard to setup the values when edit mode is broken.

    Broken Mips: https://ibb.co/k0PJTPw
    Broken Blur: https://ibb.co/fFH2vqg
    Working No Blur: https://ibb.co/pQ1LY4m

    I am also interested in the new material for blending projected shadows with baked shadows. I thought “Dynamic Shadow Projector/Projector/Dynamic/Mipmapped Shadow For Lightmap ShadowMask” might do what I want, but it still causes the double shadowing in overlapping areas. Any ideas?

    Any help is appreciated!

    Reply
    • 2019/09/24 at 3:12 PM
      Permalink

      Hi Niall, thanks for your comment.

      I admit that Fast Shadow Receiver is very complicated and hard to use. You can just follow the steps in Easy Setup Wizard for Projector Manager to integrate Fast Shadow Receiver. That is the easiest way.
      Once you understand the concept, you can manually integrate it without using Projector Manager. Please see the top page for the concept.

      Regarding the bug, we also noticed it since Unity 2017, but we couldn’t find any solutions. I’m sorry for the inconvenience.

      “Shadow For Lightmap ShadowMask” shader must be used with Fast Shadow Receiver. Unity Projector itself cannot use lightmaps. Please see this document to use Lightmap blending shaders.
      To avoid confusion, I will change the shader name later when I have a chance to update this asset. Thanks

      Reply
      • 2019/09/27 at 5:13 PM
        Permalink

        Hi,

        Thanks for the quick reply and clarification.

        It’s a shame that the blurred setting broke in 2017, and you haven’t been able to fix it yet.

        I took a look at the Setup Wizard you linked but it says “If you want to use shadow-map, you cannot use this wizard.”.

        As I’m hoping to blend your projected shadows with completely baked shadow-maps, can I use the wizard?

        Thank you,

        Niall

        Reply
        • 2019/09/28 at 11:28 AM
          Permalink

          Hi,
          “shadow-map” means the standard shadow technique that is used for dynamic shadows by Unity. It is different from “lightmap” that is used for static baked shadows. If you want to blend projector shadows with baked shadows, you can use the setup wizard.

          Reply
          • 2019/10/13 at 10:49 PM
            Permalink

            Great, I will try it, thank you!

            Reply
  • 2019/10/13 at 10:58 PM
    Permalink

    Hi,

    I am having an issue with the m_camerasForViewClipTest having a reference to a destroyed null Camera.

    Scenario:
    – The main game HAS a Camera tagged as MainCamera but NO Shadow Projectors.
    – The FrontEnd does NOT have a Camera tagged as “MainCamera” but it DOES have Shadow Projectors.
    – When quitting from the the main game to the Frontend “ShadowTextureRender.cs” line 688 is triggered (initialisaing m_camerasForViewClipTest with the MainCamera that is soon to be destroyed from main game)
    – This Camera from main game (tagged MainCamera) is then destroyed and m_camerasForViewClipTest has length 1 but a null Camera.
    – The game then crashes on “ShadowTextureRender.cs” line 703.

    Should I be making use of ShadowTextureRenderer::camerasForViewClipTest to manually set this to my shadow camera? I am unsure as to why this is an array instead of just a single camera (the shadow projector camera itself).

    Thank you,

    Niall

    Reply
    • 2019/10/14 at 11:55 AM
      Permalink

      Thank you for letting me know about the case of crashes. I will add null check in the future version.

      The reason why m_camerasForViewClipTest is an array is that some games might have multiple views for multi-players like Mario Kart. You can turn off “Don’t update while out of view” checkbox in Shadow Texture Renderer component, if you don’t need view clip test for the shadows. Or, you can manually set an array of cameras (not projector cameras, but view cameras).

      Reply
  • 2020/05/23 at 11:18 AM
    Permalink

    Hello. I am able to make it work. I just want to ask if the Fast Shadow Receiver is faster on mobile? This one puts my android game from 50 fps to 44 fps and lower for every shadow I put per character. I have max 8 characters per stage.

    Reply
    • 2020/05/23 at 12:49 PM
      Permalink

      Hi, yes, Fast Shadow Receiver can make projectors faster on mobile platforms. But it depends on scene structure. If you have large ground objects and cast shadows on them, Fast Shadow Receiver can improve the performance a lot.

      Reply
  • 2020/08/16 at 8:14 PM
    Permalink

    Hi Takao,

    I have been seeing lots of RenderTexture scene changes in my source control for scene files for a while now and finally decided to investigate. It turns out it is linked to the temporary RenderTextures that are created by ShadowTextureRenderer and assigned to the camera.

    These changes are problematic as it makes it more difficult than it should be to merge scene files, not to mention it dirtying the history of scene files that makes it hard to see the actual changes.

    It appears that simply setting the hideFlags for the Camera works fine from my limited testing (it seems to also work for prefabs despite reports to the contrary).

    m_camera.hideFlags = HideFlags.HideAndDontSave;

    Thanks,

    Niall

    Reply
    • 2020/08/17 at 2:12 PM
      Permalink

      Hi Niall, Thank you for your feedback!

      I admit that the camera component does not need to be serialized, but I saw a warning “SendMessage cannot be called during Awake, CheckConsistency, or OnValidate” when start a scene if hide flags changed. In addition, in URP version, ShadowTextureRenderer component needs to serialize UniversalAdditionalCameraData component which requires a Camera component. So, instead of changing hide flags, I will add ISerializationCallbackReceiver interface in the next release like this:

      I think that can prevent RendetTextures from being serialized as well.

      Reply
  • 2020/09/12 at 1:17 AM
    Permalink

    Good day. I am using this asset on Unity 5.5.4f1, and after I imported the scripts, I got the following errors:

    Assets/AAA_My_Assets/DynamicShadowProjector/Scripts/ShadowTextureRenderer.cs(756,10): error CS0019: Operator ==' cannot be applied to operands of type UnityEngine.Rendering.RenderTargetIdentifier’ and `UnityEngine.Rendering.RenderTargetIdentifier’

    There are six errors like this. Could you help me solve this issue? Or does it not work with Unity 5.5 anymore?

    Reply
    • 2020/09/12 at 1:10 PM
      Permalink

      Hi, unfortunately we do not support Unity 5.5 anymore. But it might be possible to make it work on Unity 5.5. Please try to replace operator == with Equals method like this:

      I’m sorry but I couldn’t try this by myself because I’m having an issue with installing Unity 5.5 on my Mac.

      Reply
  • 2020/09/15 at 2:35 AM
    Permalink

    Your method worked to remove the script errors. However, the asset doesn’t appear to work. Whenever the projector is active, the console is spammed with the following two errors:

    Cannot find a shader named DynamicShadowProjector/Blit/Blit

    and

    NullReferenceException: Object reference not set to an instance of an object
    DynamicShadowProjector.Editor.ShadowTextureRendererEditor+c__AnonStorey0.m__0 (Int32 id) (at Assets/AAA_My_Assets/DynamicShadowProjector/Scripts/Editor/ShadowTextureRendererEditor.cs:201)
    UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style) (at C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUI.cs:1960)
    UnityEditor.DockArea:OnGUI()

    The folder C:/buildslave/unity/build/Runtime/IMGUI/Managed doesn’t exist so I am guess there is something in the script that isn’t supported in the newer version of Unity thats causing this folder to be referenced.

    And the shadow itself ends up covering the entirety of any object that is being touched by the projector, even the parts that are not within the projector, or sometimes it just breaks and disappears altogether, there are a lot of visual errors.

    Is there any way to fix this?

    Reply
    • 2020/09/15 at 12:59 PM
      Permalink

      That’s weird. Can you find Blit.shader file in Assets/AAA_My_Assets/DynamicShadowProjector/Shaders/Blit folder? The file should begin with the following line:

      Reply
      • 2020/09/16 at 5:06 AM
        Permalink

        Yes, the shader is in that folder. But it appears there are errors related to this shader. When I check in in the Inspector, I see two errors:

        First one is marked as red and it says “Parse error: syntax error, unexpected TVAL_ID”
        The second error is yellow and it says “Shader is not supported on this GPU (none of subshaders/fallbacks are suitable)”

        Reply
        • 2020/09/16 at 12:20 PM
          Permalink

          I see. The keywords HLSLINCLUDE HLSLPROGRAM and ENDHLSL are not available on Unity 5.5.
          Please replace

          HLSLINCLUDE with CGINCLUDE
          HLSLPROGRAM with CGPROGRAM
          ENDHLSL with ENDCG

          Those keywords are used in almost all the shaders in Assets/AAA_My_Assets/DynamicShadowProjector/Shaders folder.

          Reply
          • 2020/09/18 at 8:02 AM
            Permalink

            I fixed all of the shaders, and I no longer get console errors. However, depending on the shader I use, the shadow still either doesn’t show up, or covers up the entire area of the projector.

            https://imgur.com/a/n7RtYsw

            I am really not sure what’s the problem here, unless I am just doing something wrong when setting it up.

            With that said, I have now learned that the system I was trying to set up which I was planning to use the projector with isn’t going to work anyway (due to unsolvable issues unrelated to shadows). Which means these projector shadows are no longer essential for me, and I feel like its not really worth trying to get them to work on a version they are not supposed to work with. If you could send me an older version of this asset that used to work with Unity 5.5 (if you still have it), I would take it, but if thats not possible, I feel like I should move on at this point.

            Reply
          • 2020/09/18 at 5:00 PM
            Permalink

            I guess, RenderTargetIdentifier.Equals method is not implemented on Unity 5.5 and it just calls Object.Equals. Can you check if sample scenes work or not?

            Anyway, I sent you an older version. Please try this version.

            Reply
  • 2020/09/22 at 6:54 AM
    Permalink

    I have tried the sample scenes and they appear to be working for both this version and old version. So it appears I was setting something up incorrectly, and the asset is working fine now. I will study the sample scenes and set them shadows up based on them.

    Reply
  • 2020/10/13 at 7:35 PM
    Permalink

    Hi,
    When I use this projector and build under Android system, I met below error:
    The type or namespace name ‘PrefabUtility’ does not exist in the namespace ‘UnityEditor’ (are you missing an assembly reference?)
    Could anyone can help? I try to search if exist PrefabUtility plugin, but failed.

    Reply
    • 2020/10/14 at 1:39 PM
      Permalink

      I’m so sorry for the problem. I will update this asset soon. For quick fix, please edit the source code like this (ShadowTextureRenderer.cs, move the “#endif” at line 577 to line 583):

      Reply
      • 2020/10/14 at 6:38 PM
        Permalink

        HI
        Thank you, with your suggestion, the error is fixed.
        But now I have another issue:

        In my project, I need to move my virtual object, so I manually calculate the near/far plane of the projector, and I dumped the rendertexture as png, only the first screen has a circle shadow, the left frames have nothing. and also my virtual object is a vase, not a circle.
        Could you help to check what happended?

        Reply
        • 2020/10/14 at 8:03 PM
          Permalink

          Hi,
          I had fixed the upper issues, now every frame I can get the correct shape of the shadow in RenderTexture saving png.
          But the shadow only can show on a un-transparent plane. When I changed my plane as transparent, I can not render the shadow.

          Reply
          • 2020/10/15 at 1:26 AM
            Permalink

            Hi,
            It seems like projectors cannot cast shadows on a material whose render queue value is greater than 2998. You need to make the render queue value of the transparent material less than 2999.

            Reply
  • 2020/10/15 at 5:02 PM
    Permalink

    HI,
    Thank you very much. Yes, with small render queue value, now it runs well.
    But if more objects, and for each object I assigned one dynamic_projector,
    when I add objects one by one, the shadows of each object, became more and more heavy.
    What’s the possible reason ?Sorry for trouble you again.

    Reply
    • 2020/10/15 at 7:54 PM
      Permalink

      If you have many projectors, the performance can be very slow. This is because receiver objects (the transparent plane in your case) are rendered once for each projector to draw shadows. If the receiver objects occupy most of pixels on the screen (regardless of the actual shadow size), the performance will be incredibly slow. The cost of projector is proportional to the number of such pixels times the number of projectors. To reduce the cost, we need to minimize the number of receiver pixels on the screen. Our paid asset “Fast Shadow Receiver” can help to solve this problem.

      Reply
  • 2020/11/17 at 4:58 PM
    Permalink

    Hi,
    I create a plane for each object. Shadow gets darker when objects are placed more. Could you know any method to let the projector only render shadow on the certain plane while other planes do not render shadows.
    Thank you!

    Reply
    • 2020/11/18 at 12:12 PM
      Permalink

      Hi, you can use ignore layers property in the projector. Let’s say, there are three projectors projector1, projector2, projector3, and associated planes, plane1, plane2, plane3. Each plane has a unique layer as follows.

      plane1: layer1
      plane2: layer2
      plane3: layer3

      In this case, ignore layers of the projectors will be like this:
      projector1: layer2 | layer3
      projector2: layer3 | layer1
      projector3: layer1 | layer2

      Reply
      • 2020/11/18 at 12:19 PM
        Permalink

        Also, the planes should have minimal size to receive projector shadows. Our paid asset Fast Shadow Receiver can help to create such planes and manage layers.

        Reply
  • 2020/12/23 at 8:09 PM
    Permalink

    Hi! Thank you for making this great asset and especially for making it compatible with URP. Many other solutions doesn’t work with URP anymore.

    In my project I needed to make fake shadows at a different angle from the ones made my lights. Your asset is great in that purpose and make it almost perfect for me. I still have a little issue though.

    Is that possible with projectors to make it so that when an object is blocking a shadow, the object behind it doesn’t receive the shadow? Or at least only the part of the shadow that it’s supposed to receive?

    I’m using your dynamic shadow projector and projector for LWRP to make my fake shadows.
    Here is an image of my issue : https://i.imgur.com/5KvlJ5X.png
    It would be great in my case if the shadow that I circled didn’t appear because an object is blocking it.

    Would your shadow receiver asset help in that purpose? Is that even possible using projectors?

    Thanks a lot!

    Reply
    • 2020/12/25 at 1:31 PM
      Permalink

      Hi, thank you for using Dynamic Shadow Projector.

      Basically, it is not possible to block projector shadows by an object because projector shadows cannot use depth information. We need to adjust ‘Far Clip Plane’ of the projector.

      If the blocking objects and receiver objects are static, and you baked lightmaps for them, you can use lightmaps to detect the blocking objects.
      For example, Fast Shadow Receiver use lightmaps to solve this problem. For more details please refer to Mixed Lighting Blob Shadow Projector section in the document.
      https://nyahoon.com/products/fast-shadow-receiver/mixed-lighting-blob-shadow-projector

      In URP project, projector shader can access lightmaps without Fast Shadow Receiver if ‘PerObjectData’ property of the projector has ‘Lightmaps’, but you might need to write a new projector shader. Dynamic Shadow Projector provides only the following shaders that use lightmap information:
      DynamicShadowProjector/FastShadowReceiver/Dynamic/Mipmapped Shadow For Lightmap Subtractive
      DynamicShadowProjector/FastShadowReceiver/Dynamic/Mipmapped Shadow For Lightmap Shadowmask

      If you purchase Fast Shadow Receiver, you can use the shaders in Fast Shadow Receiver.

      Reply
  • 2021/04/12 at 8:07 AM
    Permalink

    Hey great asset. It works super for me in game view, I just have a little problem with HDR and MSAA seems to always be off when using the scene camera (in the editor and scene mode). Setting the HDR and MSAA to use Graphiccal settings work in game mode but not in the other two mentioned. Any advise? Thx in advance!

    Reply
    • 2021/04/12 at 5:55 PM
      Permalink

      Thank you for writing a comment.

      I’m using Unity 2020.3.0f1 on Mac OS Big Sur, and HDR worked in the Scene view. I couldn’t see whether MSAA worked or not because there might be only a subtle difference on retina display.
      However, Dynamic Shadow Projector object has a camera component, and it might affect the scene view camera settings. I don’t know how the scene view choose a camera to copy the settings from, but I found a post that might be helpful for you:
      https://answers.unity.com/questions/1707909/hdr-visible-in-gameview-but-not-sceneview.html

      Reply
      • 2021/04/13 at 8:30 AM
        Permalink

        Oh, thank you! What I did to get it to work was to add the tag MainCamera to the game camera. A comment on that post said something about a camera becoming the main by taging it as such and then its properties being copied to the scene camera. 🙂 Left a review

        Reply
  • 2022/09/22 at 10:15 PM
    Permalink

    Halo,My projector import this plug-in unit,it work is good in unity,but in the mobile terminal it doesn’t show shadow.

    Reply
    • 2022/09/23 at 9:49 AM
      Permalink

      Hi, if you are using Projector For LWRP, please make sure that the render pipeline asset used by the mobile device quality settings has ‘Projector Renderer Feature’.

      Reply
  • 2022/09/28 at 8:56 PM
    Permalink

    Hello,my project work is normal operation when editor mode,but in my phone,its shadow is null.I check both of them,the diff is keyword is not equal

    Reply
    • 2022/10/03 at 10:48 AM
      Permalink

      Hi, can you elaborate a bit more? Are you talking about FSR_PROJECTOR_FOR_LWRP shader keyword? Maybe Build for Universal RP check is missing in the projector material. Also, please check if there any error messages in the console window or not.

      Reply
      • 2022/10/08 at 8:23 PM
        Permalink

        Emm,I try to add

        #pragma multi_compile_local _ _ADDITIONAL_LIGHT_SHADOWS
        #pragma multi_compile_local _ _MAIN_LIGHT_SHADOWS

        into ShadowWithoutFalloff.shader,now soft shadow is ok,but other are not right.
        I check my project,it is none error in console.

        Reply
        • 2022/10/10 at 9:27 PM
          Permalink

          Those shader keywords have nothing to do with ShadowWithoutFalloff.shader.

          Have you checked FrameDebugger? You might be able to find the cause of your issue.

          Reply
  • 2023/02/22 at 4:23 PM
    Permalink

    Terrain holes supported?

    Reply
  • 2023/06/27 at 11:55 AM
    Permalink

    Hello! I have encountered an issue where the shadows stop updating when I cannot see the Decals Projector in the Scene window. It seems to be due to the camera no longer working properly. Do you know of any solutions to this? Thank you very much!

    Reply
    • 2023/07/02 at 4:30 PM
      Permalink

      Hi,
      Probably, this issue is caused by ‘Don’t update while out of view’ option in Shadow Texture Renderer component. The camera of Scene window is different from the main camera. If a projector is visible in Scene window, but invisible in Game window, you can observe that the shadow of the projector stop updating.

      Reply

Leave a Reply to Carl Cancel reply

Your email address will not be published. Required fields are marked *

Anti Spam Code *