You can use a CASE-statement for each possible filter and apply it only if the filter value(s) are non-trivial.
-- Parameter :filter
--
AND CASE WHEN :filter IS NOT NULL THEN
table.column = :filter
ELSE TRUE END
This has zero cost in the case where :filter is unset.