blob: 380124f72938eff13e2b3b81bbe3dcc22b4a2488 [file] [log] [blame]
uniform half grayscale;uniform half invertStyle;uniform half contrast;half3 a(half3 b){half c=(1.-abs(2.*b.z-1.))*b.y;half3 d=b.xxx+half3(0.,.6666667,.333333343);half3 e=saturate(abs(fract(d)*6.-3.)-1.);return(e-.5)*c+b.z;}half3 b(half3 e){half f=max(max(e.x,e.y),e.z);half g=min(min(e.x,e.y),e.z);half i=f-g;half j=1./i;half k=half(e.y<e.z?6.:0.);half m=.166666672*(f==g?0.:(e.x>=e.y&&e.x>=e.z?j*(e.y-e.z)+k:(e.y>=e.z?j*(e.z-e.x)+2.:j*(e.x-e.y)+4.)));half n=f+g;half o=n*.5;half p=f==g?0.:i/(o>.5?2.-n:n);return half3(m,p,o);}half4 main(half4 d){half3 e=d.xyz;if(grayscale==1.)e=half3(dot(half3(.2126,.7152,.0722),e));if(invertStyle==1.)e=1.-e;else if(invertStyle==2.){e=b(e);e.z=1.-e.z;e=a(e);}e=mix(half3(.5),e,contrast);return half4(saturate(e),d.w);}