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 Irishbruse · Apr 17, 2018 at 04:11 PM · texturematerialgraphicsmaterialsprocedural mesh

Procedural Mesh Texturing

So i have a mesh being procedurally generated by Graphics.DrawMesh() i pass it a mesh and a material. I have many textures for the mesh that i need to procedurally place on it but i cant figure out how to put more than 1 texture on the mesh id prefer to do this without a custom shader. Any ideas?

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 Eno-Khaon · Apr 18, 2018 at 12:26 AM 0
Share

Is this a $$anonymous$$esh with multiple $$anonymous$$aterials, or do you just need multiple textures to fill various segments of the uv layout?

If it's the latter, you're going to need a custom shader to mix multiple textures together.

1 Reply

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

Answer by BastianUrbach · Apr 18, 2018 at 01:14 PM

These are the ways I see:

Multiple submeshes
Both Mesh.SetTriangles and Graphics.DrawMesh have an overload where you can specify a material index. That way you can make a mesh with multiple materials and then have a different Graphics.DrawMesh call for each material, allowing you to use different materials and textures for them.

Atlas textures
Use an atlas texture (a texture that actually contains many textures side by side) and set the uv coordinates accordingly.

Texture blending
Use terrain-like texture blending. That would require a custom shader but not really a difficult one. This is the only way I see to have smooth transitions between textures in case that's a requirement. You can go through the terrain shader (available from the download section on Unity's website) and see how they did it.

Comment
Add comment · Show 3 · 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 Irishbruse · Apr 18, 2018 at 03:46 PM 0
Share

For the texture atlas is it possible to combine many textures into an atlas at runtime?

avatar image BastianUrbach Irishbruse · Apr 18, 2018 at 05:03 PM 0
Share

Certainly, here is a simple example that assumes all textures are the same size:

var atlas = new Texture2D(size * textures.Length, size);
for (int i = 0; i < textures.Length; i++) {
   atlas.SetPixels(size * i, 0, size, size, textures[i].GetPixels());
}
atlas.Apply(true, true);
Note that the textures must be readable (Read/Write enabled in the texture import settings).
avatar image Irishbruse BastianUrbach · Apr 18, 2018 at 05:17 PM 0
Share

Thanks that's perfect :)

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

124 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 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

Is it possible to make an image sequence into an animated normal map? 0 Answers

Accidentally Clicked Refresh Assets and This Happened. How Do I Fix It? 0 Answers

My material doesn't look as it should 1 Answer

use RenderTexture on a sphere correctly? 1 Answer

Is it possible to get png files out of an .sbsar file? 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