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 MountDoomTeam · Sep 04, 2012 at 08:16 AM · texture atlasbatchsharedmaterial

Can you use a texture atlas as a colorpicker?

I would like to use a multicolor texture like a colorpicker to set each object to a different color, by zooming and offsetting the texture to use a pixel of a different color for each object texture.

When i write:

cube.renderer.sharedMaterial.SetTextureScale ("_MainTex", Vector2(.001,.001)); cube.renderer.sharedMaterial.SetTextureOffset ("_MainTex", Vector2(seed*.43243,seed*.87547));

the set scale op batches ok and the set offset op breaks the batch process.

Comment
Add comment · Show 4
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 save · Sep 04, 2012 at 08:35 AM 0
Share

Are your cubes always of just one color?

avatar image MadDave · Sep 04, 2012 at 09:01 AM 0
Share

What do you mean with "breaks the batch process"? I probably would not do it with a texture; you're limiting yourself to the colors you have on the texture and you will have to use point filtering. Wouldn't a shader with configurable color or vertex colors be a more obvious choice?

avatar image MountDoomTeam · Sep 04, 2012 at 09:53 AM 0
Share

Oh $$anonymous$$adDave, please Explain! i have made configurable multicolor shaders. Please explain how to use a different color for different intantiations of a mesh?

Save, Yes sorry i changed the lines alot of times, the second line makes the cubes always the same color, whereas writing it with .material. ins$$anonymous$$d of .shared$$anonymous$$aterial. its multicolors.

avatar image MountDoomTeam · Sep 07, 2012 at 12:31 AM 0
Share

$$anonymous$$adDave, by breaking the batch process, i mean that if you add a line that does SetTextureOffset, the prefabs will all call seperate materials and not be batched any more. i tried mainTextureOffset, which can be used in shared$$anonymous$$aterial but can't change the texture offset of different instances. It seems there is now way to edit colors of batched models with a diffuse shader and with direct texture commands, it may be possible to shift the model's UV's when instantiated, and perhaps there is a GetPixel way??? and perhaps a VertexLit way also! try to color sharedmaterial and diffuse = no batching works.

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by MadDave · Sep 07, 2012 at 10:15 AM

Ok, I think I got you. If you need to render all cubes in just one draw (i.e. batched) the only option I see is giving each cube different geometry. You could use different UVs and a texture or different vertex colors. Texture offset is ultimately a shader parameter and different shader parameters per cube require separate draw calls. In real life (i.e. DirectX/OpenGL programming without Unity) you would use instancing (rendering with multiple vertex streams) to achieve something like that. But AFAIK you cannot make that happen with unity.

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

9 People are following this question.

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

Related Questions

batch textures, shared materials, instantiation, sharedmaterial array 1 Answer

Creating Batch file to run unity with commands 1 Answer

How to Undo SharedMaterial set in CustomEditor? 1 Answer

Spout: shared texture breaks model UVs 0 Answers

Why would my texture split across the triangle at runtime? 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