gl_fwidth UV |
- Where to find it:
- NodeGraph / Right Mouse Click / Add Nodes / Math / Extension Pack / F /
fwidth (uv) returns the sum of the absolute derivatives in x and, transformed into UV Space.
Other than the fwidth (screenspace) node which uses the classic opengl fwidth function call, this node transforms the derivatives into UV Space
vec4 Gate = vec4(float($R),float($G),float($B),float($A));
vec2 uv = State.UV;
vec2 uxvx = dFdx(uv);
vec2 uyvy = dFdy(uv);
mat2 T = mat2(uxvx.s,uyvy.s,uxvx.t,uyvy.t);
T = (determinant(T) == 0) ? mat2(0) : inverse(T);
vec4 input = #F*Gate;
vec4 dfdx = dFdx(input);
vec4 dfdy = dFdy(input);
vec2 tdfdx = T*vec2(dfdx.x,dfdy.x);
vec2 tdfdy = T*vec2(dfdx.y,dfdy.y);
vec2 tdfdz = T*vec2(dfdx.z,dfdy.z);
vec2 tdfdw = T*vec2(dfdx.w,dfdy.w);
UDeriv = vec4(tdfdx.x, tdfdy.x, tdfdz.x, tdfdw.x);
VDeriv = vec4(tdfdx.y, tdfdy.y, tdfdz.y, tdfdw.y);
UDeriv.a = $A ? UDeriv.a : 1.0;
VDeriv.a = $A ? VDeriv.a : 1.0;
FWidth = abs(UDeriv) + abs(VDeriv);
https://registry.khronos.org/OpenGL-Refpages/gl4/html/fwidth.xhtml
- F
Specifies the expression of which to take the partial derivative.
- FWidth
Return the sum of the absolute value of derivatives in x and y, transformed into UV Space
- U Derivative
Return x derivative transformed into UV Space
- V Derivative
Return y derivative transformed into UV Space