playMaker

Author Topic: Create Object (from Prefab) increases draw calls?  (Read 1595 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
Create Object (from Prefab) increases draw calls?
« on: August 28, 2017, 05:00:02 PM »
Hello! In my game you can tunnel through the world by clicking on stone walls. Each wall block is a prefab, and when you click it, it destroys itself, creates a floor in its place, and creates new wall prefabs around that new floor tile.

using the Create Object action in playmaker, adds draw calls every time I do this, so i can't mine very much until there are hundreds or thousands of draw calls.

But all the walls use the same material and should not be adding draw calls.

Their geometry is simple squares, and they use the same material.

I wonder if it's because the Creat Object action uses the wrong terminology inside it?

from the unity help: Material Access: Be careful when accessing Renderer.material. This will duplicate the material and give you back the copy, which will opt that object out of batching consideration (as its material pointer is now unique). Use Renderer.sharedMaterial.

Could all these new draw calls be due to the action accessing Renderer.material instead of using Renderer.sharedMaterial?

If this turns out to be the case, I'll request a version of the action that uses the one that doesn't increase draw calls.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Create Object (from Prefab) increases draw calls?
« Reply #1 on: August 29, 2017, 03:26:43 AM »
Hi,

The action is fine, it's likely the prefab itself and the material that is problematic, I tried and I don't get drawcall increase.



what material does it use?

Bye,

 Jean

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
Re: Create Object (from Prefab) increases draw calls?
« Reply #2 on: August 29, 2017, 07:27:17 AM »
hello. it uses a unity standard shader with a texture, normal, secondary texture, secondary normal, and emissive map. if I understand it correctly, the first one created should add like 6 draw calls, but after that they should all batch and create no more. is that right?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Create Object (from Prefab) increases draw calls?
« Reply #3 on: September 01, 2017, 06:08:44 AM »
Hi,

 I am not sure actually.. Could you share your prefab ( pm me)? I'll see how it behaves and I would actually also ask this on the Unity Forum, just to increase your chances to get a solution on this.

 Bye,

 Jean