Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 game4444 · Oct 20, 2017 at 07:17 AM · shadermeshmodelpaintart

How can i paint texture on Mesh Runtime?

Hi! I want to paint texture on Mesh like I am making game in which i have to use nail Polish. I want to make realistic Nail Polish effect. I which i have to paint mesh on small small portions of nail. User can put different type of nail art/polish on one nail. It might b done with shaders bit I dont have any idea, which and how it could be done. Any package or shader anyone could recommend? I would be very thankful. I have attached image for refrence. alt text

hqdefault.jpg (21.9 kB)
Comment
Add comment · Show 2
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 toddisarockstar · Oct 21, 2017 at 12:04 AM 1
Share

you wouldn't paint the mesh, you would paint the texture. if i had this task i would use a UI image for the hand. and paint/adjust an overlaying texture based on mouse position. this happens with lining up mouse position with texture coodinates.
here is a script example that uses the pixels from one image to draw another. it only paints where the hand image is not transparent but you could also check other colors or get the check from another textrue map for borders. any ways i hope this points you in the right direction!

     Color c;
 
     // import settings of Textures must me marked = read/write enabled!!
     public Texture2D paint;//<image to take color from
     public Texture2D hand;// <image of your hand. 
     public float mx,my;
     int x,y,i,i2;
     void Start () {
     
                 if (paint == null) {
                         hand = new Texture2D (400, 300);
                         //just making some randome noise for background im
                         // for example
                         x=hand.width;y=hand.height;
                         paint = new Texture2D (x, y);
                         while(x>0){x--;
                         y=hand.height;while(y>0){y--;
                         hand.SetPixel(x,y,Color.white);
                        if(i>20){i=0;}
                         i++;if(i>10){
                         paint.SetPixel(x,y,new Color(1,0,1));}
                    else{paint.SetPixel(x,y,new Color(.2f,0,0));}
             
                                             }}}
         paint.Apply ();
         hand.Apply ();
     }
 
 void Update () {
         mx = Input.mousePosition.x;
         my = Input.mousePosition.y;
         if (Input.Get$$anonymous$$ouseButton (0)) {
             mx=(mx/Screen.width)*paint.width;
             my=(my/Screen.height)*paint.height;
 
             x=10;
             while(x>0){x--;
                 y=10;
                 while(y>0){y--;
                     c = paint.GetPixel((int)mx+x,(int)my+y);
                     //transparent pixesl in hand do not get painted!!!
                     //or set any color requirement here!
                     if(hand.GetPixel((int)mx+x,(int)my+y).a>.5f){
                         hand.SetPixel ((int)mx+x,(int)my+y,c);}} }
             hand.Apply();}}
     
     void OnGUI(){
         GUI.DrawTexture (new Rect(0, 0, Screen.width, Screen.height),hand);}
         
 
 
 }
avatar image game4444 · Oct 23, 2017 at 06:20 AM 0
Share

thank you so much for your reply and really sorry for late reply didn't check on weekend. Just trying your method.

0 Replies

· Add your reply
  • Sort: 

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

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

Related Questions

How to get a sphere surface with a solid angle through script? 1 Answer

Separating Procedurally Generated Mesh, Based On Triangle Height 1 Answer

Have part of mesh change color 0 Answers

Dymanic Mesh Hiding 2 Answers

2D Sprite Shader Acting like Light 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