diff --git a/src/cryo_et_neuroglancer/shaders.py b/src/cryo_et_neuroglancer/shaders.py index d8e50cb..89998c9 100644 --- a/src/cryo_et_neuroglancer/shaders.py +++ b/src/cryo_et_neuroglancer/shaders.py @@ -9,7 +9,7 @@ def build_shader(shader_parts: list[str]) -> str: def _build_invlerp( name: str, contrast_limits: tuple[float, float], window_limits: tuple[float, float] ) -> str: - return f"#uicontrol invlerp {name}(range=[{contrast_limits[0]}, {contrast_limits[1]}], window=[{window_limits[0]}, {window_limits[1]}], clamp=true)" + return f"#uicontrol invlerp {name}(range=[{contrast_limits[0]}, {contrast_limits[1]}], window=[{window_limits[0]}, {window_limits[1]}])" def _build_invertable_invlerp_getter(name: str): @@ -40,18 +40,22 @@ def get_default_image_shader( threed_contrast_name = "contrast3D" shader_parts = [ _build_invlerp(contrast_name, contrast_limits, window_limits), - _build_invlerp(threed_contrast_name, contrast_limits, window_limits), *_build_invertable_invlerp_getter(contrast_name), + _build_invlerp(threed_contrast_name, contrast_limits, window_limits), *_build_invertable_invlerp_getter(threed_contrast_name), "", "void main() {", " float outputValue;", *_build_volume_rendering_switch( - [f"outputValue = {threed_contrast_name}_get();"], - [f"outputValue = {contrast_name}_get();"], + [ + f"outputValue = {threed_contrast_name}_get();", + "emitIntensity(outputValue);", + ], + [ + f"outputValue = {contrast_name}_get();", + ], ), " emitGrayscale(outputValue);", - " emitIntensity(outputValue);", "}", ] return build_shader(shader_parts) diff --git a/src/tests/test_shaders.py b/src/tests/test_shaders.py index 8ba9511..dbb7af1 100644 --- a/src/tests/test_shaders.py +++ b/src/tests/test_shaders.py @@ -5,10 +5,10 @@ def test_get_default_image_shader(): contrast_limits = (0.0, 1.0) window_limits = (0.0, 1.0) expected_shader = """ -#uicontrol invlerp contrast(range=[0.0, 1.0], window=[0.0, 1.0], clamp=true) -#uicontrol invlerp contrast3D(range=[0.0, 1.0], window=[0.0, 1.0], clamp=true) +#uicontrol invlerp contrast(range=[0.0, 1.0], window=[0.0, 1.0]) #uicontrol bool invert_contrast checkbox(default=false) float contrast_get() { return invert_contrast ? 1.0 - contrast() : contrast(); } +#uicontrol invlerp contrast3D(range=[0.0, 1.0], window=[0.0, 1.0]) #uicontrol bool invert_contrast3D checkbox(default=false) float contrast3D_get() { return invert_contrast3D ? 1.0 - contrast3D() : contrast3D(); } @@ -16,11 +16,11 @@ def test_get_default_image_shader(): float outputValue; if (VOLUME_RENDERING) { outputValue = contrast3D_get(); + emitIntensity(outputValue); } else { outputValue = contrast_get(); } emitGrayscale(outputValue); - emitIntensity(outputValue); } """ actual_shader = get_default_image_shader(contrast_limits, window_limits)