2020-11-27 22:47:33 +00:00
|
|
|
#ifndef __DITHER_FUNCTIONS__
|
|
|
|
|
#define __DITHER_FUNCTIONS__
|
|
|
|
|
#include "UnityCG.cginc"
|
|
|
|
|
|
|
|
|
|
sampler2D _DitheringTex;
|
|
|
|
|
float4 _DitheringCoords;
|
2021-04-12 14:36:32 +01:00
|
|
|
uniform int _FrameNumber;
|
2020-11-27 22:47:33 +00:00
|
|
|
|
|
|
|
|
float isDithered(float2 pos, float alpha) {
|
2021-04-12 14:36:32 +01:00
|
|
|
half dither = frac(tex2D(_DitheringTex, pos * _DitheringCoords.xy).r + _FrameNumber * 1.61803398875);
|
|
|
|
|
//float dither = tex2D(_DitheringTex, pos * _DitheringCoords.xy + _DitheringCoords.zw).r;
|
2022-08-08 22:43:55 +01:00
|
|
|
return alpha - dither - 0.001 * (1 - ceil(alpha));
|
2020-11-27 22:47:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ditherClip(float2 pos, float alpha) {
|
|
|
|
|
clip(isDithered(pos, alpha));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|