2021-12-27 19:36:57 +00:00
local wea = worldeditadditions
2021-12-27 03:11:52 +00:00
--- Returns a smooth gaussian brush.
2021-12-27 19:36:57 +00:00
-- @param size Vector3 The target size of the brush. Note that the actual size of the brush will be different, as the gaussian function has some limitations.
2021-12-27 03:11:52 +00:00
-- @param sigma=2 number The 'smoothness' of the brush. Higher values are more smooth.
return function ( size , sigma )
local size = math.min ( size.x , size.y )
if size % 2 == 0 then size = size - 1 end
if size < 1 then
return false , " Error: Invalid brush size. "
end
local success , gaussian = worldeditadditions.conv . kernel_gaussian ( size , sigma )
2021-12-27 19:36:57 +00:00
-- Normalise values to fill the range 0 - 1
-- By default, wea.conv.kernel_gaussian values add up to 1 in total
local max = wea.max ( gaussian )
for i = 0 , size * size - 1 do
gaussian [ i ] = gaussian [ i ] / max
end
2021-12-27 03:11:52 +00:00
return success , gaussian , { x = size , y = size }
end