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
1
Question by JoeMajewski · Sep 03, 2012 at 06:05 AM · materialstexturestilestheory

How to Best Implement a Tileset

Lately I've been re-thinking the way that I create terrain/scenery in a little game that I've been working on, and since I've never been good when it comes to the artsy side of development, I decided that using a full tile set would be a lot easier for me to work with. On the plus side, the assets in my game would feel more connected to each other, as they were all created by the same person, and not random textures found on Google from various sources.

In order to best optimize my game, I'd like to know some theory on what might be a good way to implement something like this.

I currently have an 8192x8192 PNG image that contains smaller images with dimensions of 256x256 laid out in a "grid" within. Thus, there are 16 rows and 16 columns in my large texture image. That's what I'm working with.

The game world that I'm building is going to consist of 1x1x1 cubes, which should make things simple. I'd like to be able to create cubes at run-time as well, so I need to keep that in mind when determining the way to do this.

Since the smaller images are evenly placed out within the larger one, I am thinking that the way to do this would be to use just a single material with the Tiling/Offset properties set to only cover the region for the tile that I'm selecting.

For example, if my rock texture is at position [x,y] within my large image, then the tiling would grab [.0625 x, .0625 y], since .0625 is (1/16).

Is it possible to a single material that is in use on multiple objects with different Tiling/Offsets? It seems that within the Unity Editor I am unable to figure out a way to do this without using a separate material for each tile in the grid.

If this is possible, does that mean that just a single draw call would be able to display all of the objects in my game world even if they are displaying different tiles within the texture?

I know I asked a lot of things. I'm just looking to learn all I can from anyone willing to share their knowledge. Anything you can contribute to this topic would be appreciated, but if I had to limit it, I would mainly be interested in learning about the asset structure for this type of thing (i.e. one material, many materials, etc) as well as the number of draw calls for this type of things despite all of the tiles being within the same texture.

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
1
Best Answer

Answer by Eric5h5 · Sep 03, 2012 at 06:14 AM

There are several packages in the asset store which do this. You should probably just get one of them and save yourself the time and bother of doing it manually, unless you're particularly interested in the nuts and bolts of coding it yourself. The general concept is known as a texture atlas. You wouldn't use 1x1x1 cubes (as you note, you'd end up with zillions of materials); instead you'd use the Mesh class to construct everything, where each section is UV mapped appropriately so it uses the correct part of the texture. Speaking of which, just so you know, not all hardware supports such large images; in fact Unity won't import anything over 4096x4096. Or rather, it will, but it will be scaled down. If you want to be really safe, try not to go over 2048x2048 for any given texture.

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 JoeMajewski · Sep 08, 2012 at 10:55 PM 0
Share

+1

Thanks for the response. Actually, I was trying to implement something along the lines of a texture atlas. It looked as if it was working properly after a slight workaround (i.e. I was able to render textures using different coordinates from the atlas on separate cubes), but the problem I was having was that I wasn't able to find a way in Unity to have the same material object with variable scale and offset. Thus, if I made two prefab cubes and assigned both of them my texture atlas material, switching the scale and offset on one of them would change the other.

Since the only workaround that I could think of was to make a separate material for each UV mapping, it [seemed to have] defeated the purpose of having the atlas in the first place, as each of these materials would need their own draw call.

Can anyone shine some light on the topic? I'd like to learn how this is meant to be done semantically.

avatar image JoeMajewski · Sep 08, 2012 at 10:56 PM 0
Share

Also, I apologize for the time lapse, I had a busy work week so now that it's Saturday I can pickup where I left off.

avatar image Eric5h5 · Sep 08, 2012 at 10:58 PM 0
Share

You would use the $$anonymous$$esh class to change the UV coordinates.

avatar image JoeMajewski · Sep 08, 2012 at 11:10 PM 0
Share

So rather than changing the scale and offset of the material to align the texture portion that I need, I would be doing this by changing the mesh UVs?

If that sounds right, then I will need to read up on how UVs work as I haven't done any real work with them yet through scripting. Thanks for your help, Eric.

Edit: On second thought, I think I might just go with your original suggestion and invest in something from the Asset store which will likely be more fleshed out anyways than what I was going to do.

avatar image Eric5h5 · Sep 08, 2012 at 11:11 PM 0
Share

Yep.      

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

8 People are following this question.

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

Related Questions

Random Tiling Textures 0 Answers

Image Projector 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How to texture huge tile grids? 1 Answer

Split BMP into smaller Textures using Unity 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