• 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 MasterBLB · Jul 04, 2011 at 01:27 PM · texture2dpainting

Painting some marks on a mesh placed on scene

Hi all

I have Earth globe mesh(sphere+material),and now I'd like to draw some simple marks on it's surface,like an white X,a small circle,square and so.It's very important that those marks keep their's position (like childs of the sphere) while rotation of the globe.

How to do something like that?

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by save · Jul 04, 2011 at 03:17 PM

You could instantiate an object with an unlit shader and make the Earth a parent. Because you know the size and geometry of the object you can easily offset the object from its origin to match the surface of the Earth (as long as it's completely round with no mountains etc).

http://unity3d.com/support/documentation/ScriptReference/Object.Instantiate.html

http://unity3d.com/support/documentation/ScriptReference/Transform-parent.html

You could also use a raycast to get the position and rotation of the contact point to align the object perfectly upon the surface from its origin. To make the decal object align mesh to mesh you'll have to go a bit more advanced.

Comment
Add comment · Show 7 · 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 Waz · Jul 04, 2011 at 09:43 PM 0
Share

This is the cheapest option if you don't $$anonymous$$d the marks not hugging the surface. There are all sorts of great looking effects you can do, like "laser" lines (LineRenderer), "glowing domes" (single particles) and particle effect markers, all quite easy and cool looking. Sometimes the simple-looking things (like decals) are technically quite hard.

avatar image MasterBLB · Jul 05, 2011 at 08:01 AM 0
Share

Well,I'll decide for this solution probably,as I need such decals to be movable and respondible to mouse clicks.I'm afraid only one thing-would that cooperate if my Earth has a bump map?

avatar image Waz · Jul 05, 2011 at 08:16 AM 0
Share

$$anonymous$$ouse clicks are about colliders (via raycasting), not visual objects. You can use colliders regardless of the visual solution you use. As for the bump map, "sort of". A projector or simple marker object will not be affactedt by a bumpmap. A good decal system uses the bump map of the underlying geometry - none of the alternatives described here except texture-painting will give you that.

avatar image MasterBLB · Jul 05, 2011 at 09:12 AM 0
Share

Well,let's summarize what I have to do to get a visual decal-blue square painted on surface of the Eartn (mouse clicks later)

1.Create a Plane? as a child of Earth

2.Using Ray(Earth.position,desiredSquarePosition) and knowing radius of my Earth i can calculate position for square using Ray.GetPoint(EarthRadius)

3.$$anonymous$$ake the square rotation to be parallel to the Earth's surface

4.Paint the square blue using hmmm texture?Or is there a simple way to tell Unity i want the square blue?

5.Set shader of the square to unlit

Did I understand your hints correctly?

avatar image Waz · Jul 05, 2011 at 09:33 AM 0
Share

Sounds right. For 4, use a white texture with alpha producing your mark shape (cross, etc.), then set the material color to blue.

Show more comments
avatar image
1

Answer by BerggreenDK · Jul 04, 2011 at 03:28 PM

If you wrap your own texture onto the objects, then you just need to calculate which part of the texture you hit.

This function allows you to place pixels on a texture of your own. http://unity3d.com/support/documentation/ScriptReference/Texture2D.SetPixel.html

You should be able to update/set this onto your object afterwards.

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 save · Jul 04, 2011 at 04:22 PM 0
Share
  • As long as the object itself isn't supposed to move this is a great solution.

avatar image
1

Answer by Waz · Jul 04, 2011 at 09:35 PM

If the number of marks is quite small, you could use a Projector to draw each one. Too many and this is expensive though.

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 Waz · Jul 04, 2011 at 01:35 PM

The concept you're after is "decals". There are many questions and answers here once you use that keyword.

Comment
Add comment · Show 2 · 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 MasterBLB · Jul 04, 2011 at 01:44 PM 0
Share

Thanks for the hint,I'll look after it

avatar image MasterBLB · Jul 04, 2011 at 02:03 PM 0
Share

Errr...do you know Warwick some tutorial about basics of decals?What I can find the in answers is hmmm too advanced for me :/

Also I found some decal framework,but I think I don't need so powerfull tool

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I paint a picture and then compare it to another? 1 Answer

The non-trivial problem with image processing. 1 Answer

painting program not drawing at cursor point on texture 0 Answers

DrawPixel with smooth edges 2 Answers

RaycastHit2D hit to texture coordinate 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