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 rendering for intensity range of 0 #5676

Merged
merged 7 commits into from
Aug 23, 2021
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released

### Fixed
- Fix that active segment and node id were not shown in status bar when being in a non-hybrid annotation. [#5638](https://github.com/scalableminds/webknossos/pull/5638)
- Fixed that setting an intensity range of a color layer to 0 via the histogram slider led to no data being rendered at all. [#5676](https://github.com/scalableminds/webknossos/pull/5676)
- Fix that "Compute Mesh File" button was enabled in scenarios where it should not be supported (e.g., when no segmentation layer exists). [#5648](https://github.com/scalableminds/webknossos/pull/5648)
- Fixed a bug where an authentication error was shown when viewing the meshes tab while not logged in. [#5647](https://github.com/scalableminds/webknossos/pull/5647)
- Fix that segment id 0 was always shown even when fallback data of the segmentation layer was visible and hovered with the mouse. [#5674](https://github.com/scalableminds/webknossos/pull/5674)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,15 @@ void main() {
<% } %>
// Keep the color in bounds of min and max
color_value = clamp(color_value, <%= name %>_min, <%= name %>_max);
// Scale the color value according to the histogram settings
color_value = (color_value - <%= name %>_min) / (<%= name %>_max - <%= name %>_min);
// Scale the color value according to the histogram settings.
// Note: max == min would cause a division by 0. Thus we add 1 in this case and filter out the whole value below.
float is_max_and_min_equal = float(<%= name %>_max == <%= name %>_min);
color_value = (color_value - <%= name %>_min) / (<%= name %>_max - <%= name %>_min + is_max_and_min_equal);

// Maybe invert the color using the inverting_factor
color_value = abs(color_value - <%= name %>_is_inverted);
// Catch the case where max == min would causes a NaN value and use black as a fallback color.
color_value = mix(color_value, vec3(0.0), is_max_and_min_equal);
// Multiply with color and alpha for <%= name %>
data_color += color_value * <%= name %>_alpha * <%= name %>_color;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ReloadOutlined,
ScanOutlined,
StopOutlined,
WarningOutlined,
} from "@ant-design/icons";
import type { Dispatch } from "redux";
import { connect } from "react-redux";
Expand Down Expand Up @@ -374,8 +375,10 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
isInEditMode: boolean,
layerName: string,
elementClass: string,
layerSettings: DatasetLayerConfiguration,
) => {
const { tracing } = this.props;
const { intensityRange } = layerSettings;
const isVolumeTracing = tracing.volume != null;
const isFallbackLayer = tracing.volume
? tracing.volume.fallbackLayer != null && !isColorLayer
Expand Down Expand Up @@ -428,6 +431,14 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
<InfoCircleOutlined style={{ marginLeft: 4 }} />
</Tooltip>

{intensityRange[0] === intensityRange[1] && !isDisabled ? (
<Tooltip
title={`No data is being rendered for this layer as the minimum and maximum of the range have the same values.
If you want to hide this layer, you can also disable it with the switch on the left.`}
>
<WarningOutlined style={{ color: "var(--ant-warning)" }} />
</Tooltip>
) : null}
{isColorLayer ? null : this.getOptionalDownsampleVolumeIcon()}

{hasHistogram ? this.getEditMinMaxButton(layerName, isInEditMode) : null}
Expand Down Expand Up @@ -534,6 +545,7 @@ class DatasetSettings extends React.PureComponent<DatasetSettingsProps, State> {
isInEditMode,
layerName,
elementClass,
layerConfiguration,
)}
{isDisabled ? null : (
<div style={{ marginBottom: 30, marginLeft: 10 }}>
Expand Down