No announcement yet.

Shadow catcher, possible ? Oo

  • Filter
  • Time
  • Show
Clear All
new posts

    That Clip Plane was the last thought I had yesterday before leaving. And it works, so no more hiding/unhiding the highpoly object!

    But the SceneCapture is still very expensive. Is it always rendering the highpoly object and clips afterwards?

    The Base Pass of the SceneCapture has the most impact, the shadow calculation for one directional light cost only 5ms.
    The materials on the car also doesn't impact the FPS much, I tried a simple grey one for everything and gained only 1-2 fps.

    So Tick events go through the CPU and of course vertex shader instructions through GPU. I have to edit the Material of the ShadowCatcherPlane to implement those instructions? But I can't follow your instruction about the camera direction... Do you mean the SceneCapture when you say Camera? Thats a bit confusing for me, but hiding/unhiding the ShadowCatcherPlane seems not to have an impact on the FPS, so that can be as it is. Still i'm curios about your way of hiding it

    If i cant reduce the impact of the SceneCapture Base Pass, i have to dig deeper and find another way.

    For now the FPS without SceneCapture/Shadow is by 30...
    With = 12-13 FPS...
    Here some Stats:

    Click image for larger version  Name:	stats.JPG Views:	2 Size:	118.6 KB ID:	1371902
    Last edited by SebaSopp; 10-19-2017, 08:30 AM.


      I am glad it worked, but yes using a scene capture at all in a scene with thousands of actors is going to be pretty expensive. most of that cost will show up as 'initviews' cost and actually be on the CPU. But in your case the base pass is pretty high too so the raw number of polys rendered could be an issue. When you capture for the final shadowcolor instead of the depth, it actually ends up being twice as expensive because for the view frame you are rendering the mesh plus shadows. If you switch to only depth version it will help some, and then you just have to add some nicer shadow filtering to the material itself which has a small gpu cost.

      If you do 'stat dumpframe' and search the log, you can find CaptureCommand and see the cost of the cpu side. There could be some bottlenecking going on that makes the gpu stats appear wrong.

      Sadly even if you tell the scene capture to only view 1 mesh, that cost will not change as the engine is not running an optimized path for this case, it still does all the view setup as normal then masks visibility at the end.

      I will have to think for a bit to see if there is some way to do this without the scene capture right now. Usually when we do this its on a very simple scene so the overhead is not so high.
      Last edited by RyanB; 10-19-2017, 10:25 AM.
      Ryan Brucks
      Principal Technical Artist, Epic Games


        Excuse me, but i was a bit too fast to say that the clipping of the SceneCapture is working... It works fine, as long as I don't rotate Planes and SceneCapture (roll is ok, but not pitch and yaw). I update the Clip Plane Normal to the Forward Vector of my Capture Component before the capturing. Thats working, but I don't understand the Clip Plane Base values. My first thought was, to use the ShadowCatcherPlane location, but that's not working...

        However, independent of that problem the FPS count is still problematic by using a SceneCapture, it's a pity, that the masking of the visibility comes at the end. So the clip plane is more to understand as a masking than a real clipping?

        So maybe i should take a look back to the approach of the material from the Augmented Unreality plugin?
        It aligns the UV's of the texture, so it matches with the Image Plate. Activating this, costs only 1-2 FPS:


        Click image for larger version  Name:	Ar2.JPG Views:	1 Size:	56.4 KB ID:	1372537


        Click image for larger version  Name:	ar.JPG Views:	1 Size:	261.8 KB ID:	1372540

        The problem is, that the material is a normal DefaultLit one and so it's influenced by the intensity of the Directional Light. So with the "wrong" intensity the plane is visible...:

        Click image for larger version  Name:	ar3.JPG Views:	1 Size:	55.4 KB ID:	1372538Click image for larger version  Name:	ar4.JPG Views:	1 Size:	55.3 KB ID:	1372539

        Also i have to calculate the normal of the material per Tick, so the reflection intensity keeps steady in case of rotations. I subtract the directional light forward vector from the ShadowPlane up vector and normalize it. It works, but not perfect at extrem rotations...
        It would be nice, if there would be an Unlit Shading Model (or translucent blend mode), which still receives shadows (I know, it's a contradiction)...

        So i will take a deeper look into adding a custom shading model (this is the only tutorial i found about this yet).
        Sorry, if i write too detailed about all this, but maybe it helps other users as kind of a tutorial...

        Here is the line about the CaptureCommand from the Log:
        [2017.10.20-11.51.19:896][703]LogStats: 68.182ms ( 2) - CaptureCommand - STATGROUP_RenderThreadCommands - STATCAT_Advanced
        Last edited by SebaSopp; 10-20-2017, 07:59 AM.


          A little update: The calculation of the Clip Plane Base/Normal values is now correct and the clipping is working.


            Hmm, I have a stupid way to cal shadow catcher result(shadow only). hope this helps.
            change the all shader in to grey,no texture.
            render it out 2 times , frames with shadow and frames without shadow.
            then divide these two images, and you get a shadow only that you can multiply to other images such as the background. if you will get some zero pixel and you might get error pixel after divide. please clamp it.


              Hey bluearc,
              thanks for your input. Well I get some results with that technique. But because I have to do the SceneCapture two times per tick for two RenderTargets, this will impact the performance for my highpoly model even more. And as far as i understand it, I have to change all Materials from my normal one to a grey one (and back) per tick. I think it is easier and faster to hide the model... Or to use the Cliplane.


                Hey Ryan, I just wanted to check, if there are any news about a faster shadow catcher setup. Maybe the ARKit got a material/technique to create the shadows more efficient? (Also as far as i know it uses forward rendering...)


                  Hey SebaSopp. Shadow catchers or casters are working fine with composure pipeline.


                    afaik the composure plugin only allows to create composting inside the Editor. And there you can render out videos or pics. My project has to be a stand alone application...


                      This should not be a chore


                        Originally posted by RyanB View Post
                        I highly recommend you take a look at the new Composure sample in the Epic Launcher. There is an example of a shadow catcher setup in there using proper lights. It is using the composure plugin but I also helped another person set up a shadowcatcher a few days ago without composure.

                        The gist of the more 'robust' way to do this is to instead use a white flood mesh and set that mesh to be only visible to a Scene Capture. he scene capture can be pointed down at the ground orthographically. Then you set any shadow casters to 'cast hidden shadow'. Then you can hide them and the shadow will render onto the white shadow catcher ground.

                        The trick is making the shadow catcher ground not render in the main view. Technically it should be possible via the 'owner only see' flag, but that wasn't working recently. So instead I just did something a bit hacky that checked if the camera vector was straight down (ie dot(CameraVector, 0,01) and check abs value), and collapsed the shadowcatcher in the vertex shader by adding negative worldposition.

                        Its also possible to handle that visibility problem more gracefully by manually hiding the shadow catcher every frame, then unhiding it just before the scene capture updates and then re-hiding it.
                        Can you go into detail with any of these, Ryan? I tried doing the owner only see, but then it hid the shadow too.


                          Originally posted by rasamaya View Post
                          Hey SebaSopp. Shadow catchers or casters are working fine with composure pipeline.
                          Could you tell more in detail about this, sir?


                            Hey guys, so did anyone find a simple solution to do the shadowcatcher?