Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Math/BiasShader"
- {
- Properties
- {
- _MainTex ("Texture", 2D) = "white" {}
- }
- SubShader
- {
- // No culling or depth
- Cull Off ZWrite Off ZTest Always
- Pass
- {
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma target 5.0
- #include "UnityCG.cginc"
- struct appdata
- {
- float4 vertex : POSITION;
- float2 uv : TEXCOORD0;
- };
- struct v2f
- {
- float2 uv : TEXCOORD0;
- float4 vertex : SV_POSITION;
- };
- v2f vert (appdata v)
- {
- v2f o;
- o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
- o.uv = v.uv;
- return o;
- }
- sampler2D _MainTex;
- float4 _MainTex_TexelSize;
- float toFloat(float4 color)
- {
- int red = color.r * 255.0;
- int green = color.g * 255.0;
- int blue = color.b * 255.0;
- int alpha = color.a * 255.0;
- int intVal = (red << 0) | (green << 8) | (blue << 16) | (alpha << 24);
- return asfloat(intVal) ;
- }
- float4 toColor(float value)
- {
- int intVal = asint(value);
- int red = (intVal >> 0) & 0xff;
- int green = (intVal >> 8) & 0xff;
- int blue = (intVal >> 16) & 0xff;
- int alpha = (intVal >> 24) & 0xff;
- return float4(red / 255.0, green / 255.0, blue / 255.0, alpha / 255.0);
- }
- float4 frag(v2f i) : SV_Target
- {
- return tex2D(_MainTex, i.uv);
- float2 pixelUV = i.uv*_MainTex_TexelSize.zw;
- if (pixelUV.x < _MainTex_TexelSize.z - 1)
- {
- return tex2D(_MainTex, i.uv);
- }
- else
- {
- return toColor(1.0);
- }
- }
- ENDCG
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement