Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Hamesh81 · Jun 29, 2013 at 06:25 AM · texturematerialdrawcallsdecaltexture-atlas

How can I lower Decal draw calls at runtime?

I think this is a quite common issue with decals, so I'd appreciate some optimization tips.

Decals are great for things like bullet holes or for adding that sense of variety into textures and models, but the problem is of course if not handled correctly each new decal can mean an extra draw call.

In my case I am using decals for bullet holes. I'm using a texture atlas which has all of the different bullet holes packed together into a single texture. When I fire and the bullet holes appear at runtime, if I only use 1 material all of the bullet holes get batched. This is perfect, but of course it makes all the bullet holes look exactly the same. If I create one material for each bullet hole (still using the one texture atlas) and simply adjust the tiling and offset; then all the bullet holes now look nice and different, but it creates a lot of draw calls (one for each material obviously). So I'm wondering how can I get the best of both worlds, have a variety of different looking bullet holes but be able to batch them all as well.

I've looked at Bootcamp and the free Decal System and both seem to be creating meshes at runtime, which is a bit beyond my programming expertise since I'm simply using a plane which is positioned and rotated to where the bullet hit. I also can't combine the decal planes since they are obviously dynamic objects. Any suggestions?

Comment
Add comment · Show 3
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
avatar image Hamesh81 · Jun 29, 2013 at 07:02 AM 0
Share

Interesting, I've never used mesh.uv before so I'll try this. I will need to change the uvs each time a bullet hits a surface though, since there's no way to know what bullet hole in the atlas should render until the surface hit is actually detected. Would I be able to change it this way at runtime many times?

And btw, yes the planes I'm using are two triangle meshes.

avatar image robertbu · Jun 29, 2013 at 07:54 AM 0
Share

Yes, you can easily make the change at runtime.

avatar image Hamesh81 · Jun 29, 2013 at 08:43 AM 0
Share

Thanks a lot, I've done some testing and it seems this will work for what I need. If you'd like to convert your comment to an answer I'll mark it as accepted ;)

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by robertbu · Jun 29, 2013 at 06:47 AM

I can suggest a direction for you. You'll have to get your hands a bit dirty with meshes, but not to the extent of creating/expanding meshes. What you need to do is to set the UV coordinates for your atlas directly in the mesh, not use the tiling and offset. If you set the UV directly in the mesh of each plane, all the bullets will batch. Note this will be easier if you use two triangle planes. The CreatePlane script can be used to create two triange planes if you don't have access a 3D modeling package.

http://docs.unity3d.com/Documentation/ScriptReference/Mesh-uv.html

Note creating meshes at runtime is the best way to solve this problem. @alucardj did a great answer on how to render footsteps that you might examine to get the basic concepts:

http://answers.unity3d.com/questions/475795/rendering-permanent-trails-such-as-footsteps.html

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

15 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

Related Questions

Can't figure out why 5 objects with the same material/texture are not batching.. 2 Answers

Simplest way to have a damage decal or texture on cubes. 0 Answers

Decal render only one object at time 0 Answers

Checking material on raycast 1 Answer

Drawcalls reduction 1 Answer


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