- 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
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
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"
}
Comment
Try to replace step(gradient.x, _progress) with something like saturate((_progress - gradient.x)*9999)