Skip to content

Commit 54b67a0

Browse files
Wenzel Jakobwjakob
Wenzel Jakob
authored andcommitted
linear/sRGB conversion functions
1 parent 44dcf38 commit 54b67a0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drjit/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2647,6 +2647,22 @@ def assert_equal(
26472647
**kwargs,
26482648
)
26492649

2650+
def srgb_to_linear(x):
2651+
x = clip(x, 0, 1)
2652+
return select(
2653+
x < 0.04045,
2654+
x / 12.92,
2655+
((x + 0.055) / 1.055) ** 2.4
2656+
)
2657+
2658+
def linear_to_srgb(x):
2659+
x = clip(x, 0, 1)
2660+
return select(
2661+
x < 0.0031308,
2662+
x * 12.92,
2663+
1.055 * (x ** (1.0 / 2.4)) - 0.055
2664+
)
2665+
26502666

26512667
newaxis = None
26522668

0 commit comments

Comments
 (0)