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 /
This question was closed Dec 02, 2015 at 06:11 AM by MewEight for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by MewEight · Oct 24, 2015 at 10:17 AM · shadershaderlabprogress-bar

[Shader] Progress shader acts differently on certain devices

Apology, if this has been posted before.

I have this shader which does something like a progress bar.

Weirdly on some devices it gives the opposite effect of what i wanted. Below is a screenshot on how its expected to behave and how it looks like on a HTC m7 alt text alt text

THANKS!

 Shader "Custom/ProgressBar"
 {
     Properties
     {
         _MainTex ("Empty (RGB)", 2D) = "white" {}
         _FullTex ("Full (RGB)", 2D) = "white" {}
         _GradientTex ("Gradient (RGB)", 2D) = "white" {}
         _progress ("Progress", Range(-0.1, 1.0)) = 0.5
     }
     SubShader
     {
         Tags { "Queue" = "Transparent" }
         Pass
         {
             Blend SrcAlpha OneMinusSrcAlpha
 
             CGPROGRAM
             #pragma vertex vert_img
             #pragma fragment frag
 
             #include "UnityCG.cginc"
 
             uniform sampler2D _MainTex;
             uniform sampler2D _FullTex;
             uniform sampler2D _GradientTex;
             uniform float _progress;
 
             float4 frag(v2f_img i) : COLOR
             {
                 half4 empty = tex2D(_MainTex, i.uv);
                 half4 full = tex2D(_FullTex, i.uv);
                 half4 gradient = tex2D(_GradientTex, i.uv);
                 return lerp(empty, full, step(gradient.x, _progress));
             }
             ENDCG
         }
     }
     FallBack "Diffuse"
 }


temp.png (11.8 kB)
gg.jpg (67.6 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 DmitryNovikov · Oct 25, 2015 at 04:11 PM 0
Share

Try to replace step(gradient.x, _progress) with something like saturate((_progress - gradient.x)*9999)

avatar image MewEight · Dec 02, 2015 at 06:10 AM 0
Share

That did the trick. Thanks alot

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

31 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

Related Questions

calculating 1 Answer

How to access another sprite's texture from a 2D shader 0 Answers

Pass ShaderLab properties to Standard cginc 2 Answers

[Unity Free]Add textures to existing Unity DOF Shader 0 Answers

Would learning some GLSL help with Unity Shading? 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