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 Lomardii · Feb 19, 2014 at 01:17 PM · texturemeshspritescrollatlas

How to scroll a region of texture (which is an atlas) on a mesh (which is a sprite)

Hi! I can't find any answer for this particularly problem. All answers ignore the fact that texture can be used as an atlas. So here we go:

I have an atlas of sprites imported as a texture in a wrapped mode. Now basing on meta info of that atlas I generated prefabs with meshes (2 polygons for each mesh of a sprite with proper dimension + transparent shader - it does the job well) with properly set texture on them (done through TexturePackerImporter).

Now the question is how to scroll that texture, so I can get the moving background (hills) or foreground (grass). Right now when doing SetTextureOffset on a material the whole texture is moving - so on that mesh I can see other paintings from atlas.

What I want achieve is to have wrapping around particular clipped region of a 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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Lomardii · Feb 19, 2014 at 03:40 PM

Ok, I have an idea. I won't scroll texture. I will just create two more meshes (or more if needed) beside original one and move all of them. Of course after reaching some position, they will be spawned "at the begin". This way I will create infinity looking plane. Moreover I can zoom out/zoom in them.

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
avatar image
0

Answer by Owen-Reynolds · Feb 19, 2014 at 03:57 PM

I think it's impossible using what you are trying now. Think you'd need to put the code in a custom shader. My logic:

A scrolling texture works based on the way Wrapping works. The graphics card thinks the right side of the entire texture is touching the left, and that past the right really, really is starting on the left. Now, say an atlas has your texture from x=0.2 to x=0.3 (out of 0 to 1.) The sprite UV coords, which would normally be 0-1, are now hand-crafted to map 0.2 to 0.3 over the sprite. So far, so good.

Now, you can shift those to: 0.21 to 0.31. That will shift the image 10%. But, Wrapping doesn't understand that 0.31 is 0.01 past your right side, or that it should wrap the extra 0.01 starting from your left side of 0.2. There's no switch or setting to alter wrapping rules. It would take a custom shader, with these numbers sent, to do the math.

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

19 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

Related Questions

Parsing a TexturePacker JSON file 2 Answers

Automatic mesh combine and texture atlasing 4 Answers

Tool to make ONE flat sized mesh from a png/texture? 5 Answers

Splatmapping / blending between two textures in an atlas? 0 Answers

Repeating Images From an Atlas 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