bool somewhatEqual(float left, float right) { return distance(left, right) < 1.0; } float median(float r, float g, float b) { return max(min(r, g), min(max(r, g), b)); } float contour(float dist, float edge, float width) { return clamp(smoothstep(edge - width, edge + width, dist), 0.0, 1.0); } float getSample( Texture2D SampleTexture, SamplerState Sampler, float2 texCoord, float edge, float width ) { return contour( SampleTexture.Sample(Sampler, texCoord).r, edge, width); } bool scissor(float2 position, float2 topleft, float2 size) { if((position.x >= topleft.x) && (position.x <= (topleft.x + size.x)) && (position.y >= topleft.y) && (position.y <= topleft.y + size.y)) { return true; } return false; } bool rect(float2 position, float2 topleft, float2 size) { if(position.x >= topleft.x && position.x <= topleft.x + size.x && position.y >= topleft.y && position.y <= topleft.y + size.y ) { return true; } return false; }