22 lines
572 B
HLSL
22 lines
572 B
HLSL
/*
|
|
contributors: Patricio Gonzalez Vivo
|
|
description: Returns a triangle-shaped sdf
|
|
use: triSDF(<float2> st)
|
|
license:
|
|
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
|
|
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
|
|
*/
|
|
|
|
#ifndef FNC_TRISDF
|
|
#define FNC_TRISDF
|
|
float triSDF(in float2 st) {
|
|
#ifdef CENTER_2D
|
|
st -= CENTER_2D;
|
|
st *= 5.0;
|
|
#else
|
|
st -= 0.5;
|
|
st *= 5.0;
|
|
#endif
|
|
return max(abs(st.x) * .866025 + st.y * .5, -st.y * 0.5);
|
|
}
|
|
#endif
|