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 bpears · Jul 15, 2013 at 07:40 AM · randombatchingdiffusestatic batching

Batching object with script that chooses random diffuse texture?

Would this work? Assigning a few diffuse textures, and then have a script attached that tells it to randomly choose between them for diffuse. Just trying to think of a way to give variety to batched meshes of the same geometry.

Comment
Add comment · Show 1
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 bpears · Jul 15, 2013 at 06:57 PM 0
Share

bumppppppp

1 Reply

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

Answer by Kiloblargh · Jul 15, 2013 at 07:09 PM

changing the texture of the material creates a duplicate material. If you need copies of an object with different textures to batch then you need to put all the textures on a texture atlas , create multiple meshes with different uv coordinates, give them all the same sharedMaterial but randomly pick a different mesh.

Comment
Add comment · Show 5 · 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
avatar image bpears · Jul 15, 2013 at 07:21 PM 0
Share

different UV coordinates wouldn't cause a separate draw call for the duplicate mesh?

avatar image bpears · Jul 15, 2013 at 07:25 PM 0
Share

$$anonymous$$y models are broken up into modular pieces though, I wouldn't want some parts to choose one set of UV coordinates and some to choose another, within the the complete object. Want them to choose uniformly for that complete object, but randomly for copies of that complete object.

avatar image bpears · Jul 15, 2013 at 07:54 PM 0
Share

I guess I could randomly choose the complete object. So as long as it has same geometry, the geometry is batched together then eh?

avatar image Kiloblargh · Jul 15, 2013 at 08:12 PM 1
Share

Not as long as it has the same geometry- as long as it has the same material. You can in theory have every mesh in the game use the same material. But you have all their textures in one big texturemap like a patchwork quilt and map their UV's to their little corner of it ins$$anonymous$$d of the whole thing. To change sets of meshes at once, you just need to create arrays or lists, like this:

 var myHead$$anonymous$$F : $$anonymous$$eshFilter; //assign each part in the inspector
 var myTorso$$anonymous$$F : $$anonymous$$eshFilter;
 var myLegs$$anonymous$$F : $$anonymous$$eshFilter;
 var head$$anonymous$$eshes : List.<$$anonymous$$esh>; // drag on your different meshes in the inspector
 var torso$$anonymous$$eshes : List.<$$anonymous$$esh>; // in the same order for each list
 var leg$$anonymous$$eshes : List.<$$anonymous$$esh>; // so all the same index will give a matching set
 
 var r : int = Random.Range (0, head$$anonymous$$eshes.Count);
 myHead$$anonymous$$F.mesh = head$$anonymous$$eshes [r];
 myTorso$$anonymous$$F.mesh = torso$$anonymous$$eshes [r];
 myLegs$$anonymous$$F.mesh = leg$$anonymous$$eshes [r];

avatar image bpears · Jul 15, 2013 at 08:28 PM 0
Share

thank you :)

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

Problems with Batching (diffuse shader) 1 Answer

Static batching not reducing draw calls but is creating batches 0 Answers

How do you get proper static batching? 1 Answer

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

Static batching not working (HDRP) 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