Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SteenPetersen · Mar 28, 2018 at 10:08 AM · lightingspritesbatchingdiffuse

(Solved) Batching sprites in a randomly generated dungeon with Diffuse sprites

Hello,

I am making a 2d rpg dungeon crawler. I have made the content the way I like it and am happy with the way it it is generating the dungeons, applying lighting, placing object and all that jazz. However I am trying to make it run smoothly for webgl. Inside the dungeons in my game fps, according to the stats window, falls from 600 outside the dungeon to +-70 inside the dungeon.

The stats window also shows that I have 10000 batches and I am only saving about 1300 by batching. And so I am getting a ton of drawcalls which I believe is causing the issue. I have done the following to try and reduce this (numbers in brackets at the end indicate the reference where I got the information):

  • Given all my sprites the same Packing tag (1)

  • Given all my sprites the same Material (1)

  • Given all my sprites the same Compression format in the Import settings (1)

  • Labelled all of my Static objects as Static in the inspector (5)



Here is a picture of my stats window, however sometimes the batches can even reach 12k+

alt text

The Script that generates the dungeon creates a grid of sprites and then runs through using an algorithm and replaces the sprites with the correct sprite for floor etc, and places 3d objects for walls these are cubes with textures that make them look pixelated. Giving the dungeon a cool mixture of 2d and 3d elements. It should be noted that I have tried to alter the code so as not spawn walls, or not spawn floors, etc.

Im wondering if anyone can Point out some other things that I can try or places that I can look for information on this topic. Sadly I dont have unity Plus to use the profiler. May be getting it later today if I cannot solve this issue without the profiler.

references:
1. https://answers.unity.com/questions/847622/getting-dynamic-batching-to-work-with-2d-sprites.html
2. https://blogs.unity3d.com/2017/04/03/how-to-see-why-your-draw-calls-are-not-batched-in-5-6/
3. https://answers.unity.com/questions/898619/lower-draw-calls-for-sprites.html
4. https://docs.unity3d.com/Manual/DrawCallBatching.html
5. https://forum.unity.com/threads/draw-calls-for-sprites.249207/

stats.png (34.6 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by SteenPetersen · Mar 28, 2018 at 10:11 AM

I managed to figure out what the problem was finally while make sure I wrote the question thoroughly. Turns out it was the fact that all my sprites where labelled as diffuse which is fine for batching but when lights are added to the mix every sprites gets a seperate draw call because the lighting influences the sprite and makes it unique.

So the solution is to get creative with how I manage lighting in the game and try to find another way of doing it. Any suggestions to that are appreciated.

References:
https://forum.unity.com/threads/using-sprites-diffuse-material-breaks-batching.254083/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

101 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Trying to have sprites affected by fog without having to use default/diffuse shader. 3 Answers

Sprite Diffuse shader not affected by point lights 1 Answer

Sprites/Diffuse shader overlap problem 0 Answers

Making shader's first pass light sensitive (2D) 0 Answers

Limit Amount of Light Applied to Sprite 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges