Create a rectangular using a custom node in Unreal Engine


Create a rectangular using a custom node in Unreal Engine








Code -

float2 uv = UV;
float3 resultColor = float3(0, 0, 0);
float paddingX = PaddingX;
float paddingY = PaddingY;
uv.x = (uv.x - paddingX) / (1.0 - 2.0 * paddingX);
uv.y = (uv.y - paddingY) / (1.0 - 2.0 * paddingY);
float2 topLeft = TopLeft;
float2 bottomRight = BottomRight;
if (uv.x >= topLeft.x && uv.x <= bottomRight.x && uv.y >= topLeft.y && uv.y <= bottomRight.y)
{
resultColor = float3(1, 1, 1);
}
return resultColor;

 


Input -

UV
TopLeft
BottomRight
PaddingX
PaddingY

 



Comments