Aetheria/Assets/Shaders/Dither Functions.cginc
Reinier Vens ec1f8f56d4 Golden Ratio Blue Noise Sampling
Improved fog sampling and stochastic transparency by generating low discrepancy temporal sequences using the golden ratio on blue noise samples
2021-04-12 14:36:32 +01:00

19 lines
No EOL
550 B
HLSL

#ifndef __DITHER_FUNCTIONS__
#define __DITHER_FUNCTIONS__
#include "UnityCG.cginc"
sampler2D _DitheringTex;
float4 _DitheringCoords;
uniform int _FrameNumber;
float isDithered(float2 pos, float alpha) {
half dither = frac(tex2D(_DitheringTex, pos * _DitheringCoords.xy).r + _FrameNumber * 1.61803398875);
//float dither = tex2D(_DitheringTex, pos * _DitheringCoords.xy + _DitheringCoords.zw).r;
return alpha - dither - 0.0001 * (1 - ceil(alpha));
}
void ditherClip(float2 pos, float alpha) {
clip(isDithered(pos, alpha));
}
#endif