Skip to content

Commit 5320073

Browse files
committed
testing: add shader test
1 parent 75e98ce commit 5320073

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/tests/test_shaders.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from cryo_et_neuroglancer.shaders import get_default_image_shader
2+
3+
4+
def test_get_default_image_shader():
5+
contrast_limits = (0.0, 1.0)
6+
window_limits = (0.0, 1.0)
7+
expected_shader = """
8+
#uicontrol invlerp contrast(range=[0.0, 1.0], window=[0.0, 1.0], clamp=true)
9+
#uicontrol invlerp contrast3D(range=[0.0, 1.0], window=[0.0, 1.0], clamp=true)
10+
#uicontrol bool invert_contrast checkbox(default=false)
11+
float contrast_get() { return invert_contrast ? 1.0 - contrast() : contrast(); }
12+
#uicontrol bool invert_contrast3D checkbox(default=false)
13+
float contrast3D_get() { return invert_contrast3D ? 1.0 - contrast3D() : contrast3D(); }
14+
15+
void main() {
16+
float outputValue;
17+
if (VOLUME_RENDERING) {
18+
outputValue = contrast3D_get();
19+
} else {
20+
outputValue = contrast_get();
21+
}
22+
emitGrayscale(outputValue);
23+
emitIntensity(outputValue);
24+
}
25+
"""
26+
actual_shader = get_default_image_shader(contrast_limits, window_limits)
27+
assert actual_shader.strip() == expected_shader.strip()

0 commit comments

Comments
 (0)