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 1337GameDev · Feb 19, 2013 at 04:41 AM · shadercolorinvertrgbastrumpy

Create color changer in strumpy shader editor

I am curious on how to make a shader that changes my font color from black to white and vice versa. I have played around with this a bit, and am unsure how to do this. I basically want to emulate this:

Example of text that changes color based on progress bar before it

(The font changes from white, to black per pixel, as the progress bar overlaps it. This also seems to take into account the bar color, as if the bar is very light the text is black, and if it is dark, the text is white.)

I am curious how to do this. I wanted to compare the rgba values to all zero, or to all black, but i am unsure how to do this. I would guess you would use step, or any or the all nodes, but am unsure. How would i split the rgba values to their respective components? Similar to Vector2 split node.

I tried using the Assemble node and fed in 4 float values, and then wired the result to diffuse, but to no avail. It only stays white (assuming from wrong input type and defaulting to all zero).

And will strumpy shaders work for guiTexture fonts and for when they are overlapped and blocked, to be rendered still?

How would i accomplish this? I am unsure how to start on this....

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

· Add your reply
  • Sort: 
avatar image
0

Answer by Sanky · Feb 19, 2013 at 05:54 AM

following script will help you to blend your font texture or material

Shader "Myshaders/ChangeMaterial" {

 Properties {

     _Tint ("Main Color", Color) = (.9, .9, .9, 1.0)

     _TexMat1 ("Base (RGB)", 2D) = "white" {}

     _TexMat2 ("Base (RGB)", 2D) = "white" {}
     
     _TexMat3 ("Base (RGB)", 2D) = "white" {}


     _Blend ("Blend", Range(0.0,1.0)) = 0.0
   
     

 }

 

 Category {

     ZWrite On

     Alphatest Greater 0

     Tags {Queue=Transparent}

     Blend SrcAlpha OneMinusSrcAlpha

     ColorMask RGB

 SubShader {

     Pass {

         

         Material {

             Diffuse [_Tint]

             Ambient [_Tint]

         }

         Lighting On

     
         SetTexture [_TexMat1] { combine texture }

         SetTexture [_TexMat2] { constantColor (0,0,0,[_Blend]) combine texture lerp(constant) previous }

         SetTexture [_TexMat2] { combine previous +- primary, previous * primary }



     }

 } 

 FallBack " Diffuse", 1

}

}

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 1337GameDev · Feb 19, 2013 at 04:35 PM 0
Share

Thanks for the script, but I am curious how this works. I like to have scripts made when I don't know how to implement something, but I want to learn cg. Can you explain this script to me?

Can you also post the strumpy graph of this and explain it? Also how do you do condionals in cg / strumpy?

avatar image 1337GameDev · Apr 14, 2013 at 11:40 PM 0
Share

Please explain this shader. I tried it and it doesnt work. I believe I have to get the color of the pixel befor rendering the font (i'll have the status bar behind my text so its rendered first).

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

Invert Color Shader (without see-through) 0 Answers

How do I invert the color of ui text to make it more readable, on a messy background? 4 Answers

Use cg shader to change text color based on previous color rendered 0 Answers

Material doesn't have a color property '_Color' 4 Answers

Font Color changing shader [color changes based on what background color is] 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