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 /
This question was closed Jul 03, 2013 at 08:08 PM by Em3rgency for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Em3rgency · Jul 03, 2013 at 08:08 AM · texturescaleruntime

Is it possible to texture objects like this in unity? (Video inside) [Solved. Wanted screen space texture]

Right, so I have a lot of differently shaped and sized objects with the same texture, and I wan't them all to match up when they're next to each other. Since they scale in all 3 dimensions during runtime, I can't(or at least don't know how to) scale the texture in different values on different sides of the object.

But then I saw my kid watching this cartoon. http://www.youtube.com/watch?v=Uoowh63Mckg Notice how the purple (and later the blue) clothes are "textured". The clothes move, but the texture always stays in place. Like it has a global position independent of the textured object. If my texture was set up like this, I could place objects anywhere and whatever shape I wanted, they would always match up. So is this possible?

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

  • Sort: 
avatar image
2
Best Answer

Answer by Philipp · Jul 03, 2013 at 10:37 AM

I believe what you want is a shader that does texturing in screen space. There is one that you might be able to modify, in Unity's surface shader examples here: http://docs.unity3d.com/Documentation/Components/SL-SurfaceShaderExamples.html - search that page for "Detail Texture in Screen Space". You'll want to rewrite this part:

 o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
 float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
 screenUV *= float2(8,6);
 o.Albedo *= tex2D (_Detail, screenUV).rgb * 2;
 

to say

 float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
 o.Albedo = tex2D (_Detail, screenUV).rgb;
 

Which makes it use only the Detail texture and ignore the Main texture. If you want to be thorough, remove the lines "_MainTex ("Texture", 2D) = "white" {}" and "float2 uv_MainTex;" and "sampler2D _MainTex;" as well.

Comment
Add comment · Show 1 · 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 Em3rgency · Jul 03, 2013 at 01:44 PM 1
Share

Ok, this is embarrassing. This is exactly what I asked for. Problem is this is not what I wanted. All the textures do line up perfectly now, regardless of what shape the object is and where I place it, HOWEVER, when the camera moves, so do the textures.

I did a bit more digging, and I found this http://wiki.unity3d.com/index.php?title=WorldUVs

I think this is what I'm looking for, but I can't get it to work... For one, its says to select "my parent world object in the inspector". Uhh.. what? $$anonymous$$y scene is empty but for the camera and plane where I build everything on. The objects I want textured properly are prefabs and only get scaled properly and instantiated during runtime. Help?

EDIT: Found something that works and does EXACTLY what I was looking for all along. http://www.blog.radiator.debacle.us/2012/01/joys-of-using-world-space-procedural.html

@Philipp I'm tagging your answer as correct, as well... it is. Its my fault I didn't know what to ask for. And in the end, its your answer that got me on the right track, so thank you very much!

Follow this Question

Answers Answers and Comments

16 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

Related Questions

Keeping textures unstretched even as a gameobject scale is changed 1 Answer

How expensive is scaling in 2D unity? Is it better to pre-scale? 1 Answer

Save an image to PersistentDataPath then access it again 1 Answer

A way to move Texture's offset in runtime? 2 Answers

determine neighboring cells on a hex grid. 2 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