We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2298cb5 commit 198b9bbCopy full SHA for 198b9bb
examples/shader_computations/histogram.py
@@ -0,0 +1,27 @@
1
+def transform_input(x):
2
+ if x == 0:
3
+ return 1.0 / 256.0 - 1.0
4
+ if x < 0:
5
+ x = 0.0
6
+ elif x > 1.0:
7
+ x = 1.0
8
+ else:
9
+ x = (1.0 + x * 253.0) / 255.0
10
+ return 2.0 * (x * 255.0 + 0.5) / 256.0 - 1.0
11
+
12
13
+def main():
14
+ input_values = [
15
+ 0.0,
16
+ 0.5,
17
+ 1.0,
18
+ 1.5,
19
+ -1.5,
20
+ ]
21
22
+ for x in input_values:
23
+ print(f"transform_input({x}) = {transform_input(x)}")
24
25
26
+if __name__ == "__main__":
27
+ main()
0 commit comments