Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Shader with Dynamical Batching and shadow receive enabled

Discussion in 'Shaders' started by Rustamovich, Feb 13, 2016.

  1. Rustamovich

    Rustamovich

    Joined:
    Sep 5, 2014
    Posts:
    36
    Hello guys!

    I am tried to find an answer for my question, but its like nothing at all here.
    I understand that if I want my materials receive dynamic shadows I cant use batching, and counterwise.

    Is there any possible workaround here? I use Unity standard shader, nothing more.

    Thanks in advance!
     
  2. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    Dynamic shadows with batching do work actually. At least in my realtime shadows environment, I do see batching in editor stats window. Where is problem? If your meshes aren't dynamically batched, you should first see requirements for dynamic batching (same material, less than certain amount of vertices, etc).
     
  3. Rustamovich

    Rustamovich

    Joined:
    Sep 5, 2014
    Posts:
    36
  4. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    Strange, I'm using Standard shader and Unity profiler sais that objects get batched. Shadows are on, using realtime forward rendering pass light.

    Simple test:
    Creating a new scene.
    Adding 15 cubes on scene. Profiler sais "Total batches 8, (Dynamic Batching) Batched Draw Calls: 74 Batches: 5"
    Setting all to same material with Standard shader (I know it's redundant) - still same.
    And with each new cube I still get same total 8 batches (+more batched draw calls) even though they cast shadows on each other. Until there are too many vertices of course, then there are a bit more batches.

    If that's true, then what did I do wrong in this setup that batching is still working?
     
  5. Rustamovich

    Rustamovich

    Joined:
    Sep 5, 2014
    Posts:
    36
    Wow, thats pretty interesting, what version of unity you're using?
    I use standard shader on my quads toon , no texture on them, nothing specific at all except color
     
  6. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    5.3.1f1
    Adding a point light increases amount of batches a lot, yet amount of batched drawcalls remains approximately same. I assume shadows on each object don't get batched when using point light instead of directional. But that I don't know for sure.

    In case of 20 quads:
    What I'm seeing with point light
    What I'm seeing without point light
     
    Last edited: Feb 17, 2016