Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(extensions): DataFilterExtension handling of filterSoftRange #8800

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions modules/extensions/src/data-filter/shader-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,22 @@ float dataFilter_reduceValue(vec4 value) {
return min(min(value.x, value.y), min(value.z, value.w));
}

#ifdef DATAFILTER_ATTRIB
#ifdef DATAFILTER_TYPE
void dataFilter_setValue(DATAFILTER_TYPE valueFromMin, DATAFILTER_TYPE valueFromMax) {
if (filter_useSoftMargin) {
dataFilter_value = dataFilter_reduceValue(
smoothstep(filter_min, filter_softMin, valueFromMin) *
(1.0 - smoothstep(filter_softMax, filter_max, valueFromMax))
// smoothstep results are undefined if edge0 ≥ edge1
// Fallback to ignore filterSoftRange if it is truncated by filterRange
DATAFILTER_TYPE leftInRange = mix(
smoothstep(filter_min, filter_softMin, valueFromMin),
step(filter_min, valueFromMin),
step(filter_softMin, filter_min)
);
DATAFILTER_TYPE rightInRange = mix(
1.0 - smoothstep(filter_softMax, filter_max, valueFromMax),
step(valueFromMax, filter_max),
step(filter_max, filter_softMax)
);
dataFilter_value = dataFilter_reduceValue(leftInRange * rightInRange);
} else {
dataFilter_value = dataFilter_reduceValue(
step(filter_min, valueFromMin) * step(valueFromMax, filter_max)
Expand Down
Loading