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
1
Question by ChristianLeyva · Dec 04, 2012 at 10:31 PM · shadertexturealphaavatar

Avatar T-Shirt Color With Print

Hi i'm working in a T-shirt with a print, and I need that the main color don't affect the the print Like This without multiplying or change the color of the print. How do I can make change the color of the shirt without affect the print.

I'm using a png(Alpha) only with the print, but when i add to a shader it changes the color.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by sirival · Dec 04, 2012 at 11:55 PM

You need to write a custom shader for this that would use a mask like the texture's alpha channel, to decide which parts of the model to tint. For example when the alpha is 1 you will use the texture color multiplied with the tint and when the alpha is 0 you will only use the texture color without multiplying it with a tint.

Let me know if you need more info on this.

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 ChristianLeyva · Dec 05, 2012 at 08:15 PM 1
Share

hi, i read your answer and i didn´t understand very well so i did this shader, i noticed that the second texture it is not required because i'm only modifing the main color and when i do that the main texture also change its color. How can i do to print one texture which is going to be modify and then print the main texture whitout being affected by the color that i'm modifing?


 Shader "ShaderAvatar/TShirt" {
     Properties {
         _Print ("Print", 2D) = "white" {}
         _Color ("$$anonymous$$ain Color", Color) = (1,1,1,1)
         _BaseColor ("Base", 2D) = "white" {}
         
     }
     SubShader {
         Tags { "RenderType"="Transparent" }
         Blend SrcAlpha One$$anonymous$$inusSrcAlpha
 
         CGPROGRA$$anonymous$$
         #pragma surface surf Lambert
 
         sampler2D _Print;
         sampler2D _BaseColor;
         fixed4 _Color;
         
         
         struct Input {
             float2 uv_Print;
             float2 uv_BaseColor;
         };
 
            
         void surf (Input IN, inout SurfaceOutput o) {
             half4 d = tex2D (_Print, IN.uv_Print); 
             fixed4 c = tex2D(_BaseColor, IN.uv_BaseColor) * _Color;          
             o.Albedo = c.rgb; 
             o.Albedo *= d.rgb;
             o.Alpha = c.a; 
       }
 
         ENDCG
     } 
 }  
 
avatar image
0

Answer by ChristianLeyva · Dec 05, 2012 at 08:15 PM

I DID IT :D


 using UnityEngine;
 using System.Collections;
 
 public class example : MonoBehaviour {
     
     public float r=0,g=0,b=0;
     
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
         GameObject.Find("polySurface1").renderer.material.SetColor("_Color",new Color(r,g,b,1));
     }
 }



 Shader "ShaderAvatar/TShirt" {
     Properties {
         _MainTex ("Base (RGB)", 2D) = "white" {}
         _BlendTex ("Alpha Blended (RGBA) ", 2D) = "white" {}
         _Color ("Main Color", Color) = (1,1,1,1)
     }
     SubShader {
     
 
         
         Pass {
             // Apply base texture
             SetTexture [_MainTex] { 
                 constantColor[_Color]
                 combine constant lerp(texture) previous
             }
             // Blend in the alpha texture using the lerp operator
             SetTexture [_BlendTex] {
                 combine texture lerp (texture) previous
             }
         }
     }
 } 
 
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 sirival · Dec 05, 2012 at 09:13 PM 0
Share

cool :) - I hope it works like you want

avatar image ChristianLeyva · Dec 06, 2012 at 07:58 PM 0
Share

Hi, ¿How do I enable the scene light in the Shader?

avatar image
0

Answer by sirival · Dec 05, 2012 at 09:39 PM

To make more clear what I was telling you in my first response, what I meant was that you can use only 1 texture for the whole thing.

The RGB of the texture will contain the print for your t-shirt. Now in the alpha channel of that texture you can set a pixel to 1 when you want it to be modified with a Color or set it to 0 when you do not want it to be modified ( so your print will be copied to the alpha channel of the texture as a black area ).

In your shader code you would do something like this:

half4 texColor = tex2D( _MainTex, IN.uv ); o.Albedo = lerp( 1, _Color, texColor.a ) * texColor.rgb;

That way you save memory and it will probably be more efficient as you do not have two texture accesses but only one.

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

10 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

Related Questions

Translate or Rotate a texture of a cube 2 Answers

Do alpha cut off with seperate texture? 1 Answer

Add transparency to this shader? 0 Answers

Toon and fun Shader or texture 1 Answer

Shader: separate alpha texture, independent offset 1 Answer


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