Skip to content

Commit efe816d

Browse files
committed
Use sRGBTransferEOTF
1 parent 566db17 commit efe816d

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

src/shader-chunks/shaders/colorspace-conversion-pars.frag

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
vec4 sRGBToLinear(const in vec4 value) {
2-
3-
return vec4(mix(
4-
pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)),
5-
value.rgb * 0.0773993808,
6-
vec3(lessThanEqual(value.rgb, vec3(0.04045)))
7-
), value.a);
8-
9-
}
10-
11-
// Based on work by Sam Hocevar, Emil Persson and Ian Taylor.
12-
// https://www.chilliant.com/rgb2hsv.html
1+
/**
2+
* Color space conversion functions, based on work by Sam Hocevar, Emil Persson and Ian Taylor.
3+
*
4+
* @see https://www.chilliant.com/rgb2hsv.html
5+
*/
136

147
vec3 RGBToHCV(const in vec3 RGB) {
158

src/utils/EffectMaterialManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export class EffectMaterialManager implements Disposable {
290290

291291
// Convert back to linear.
292292
const fragmentMainImage = data.shaderParts.get(Section.FRAGMENT_MAIN_IMAGE)!;
293-
data.shaderParts.set(Section.FRAGMENT_MAIN_IMAGE, fragmentMainImage + "color0 = sRGBToLinear(color0);\n\t");
293+
data.shaderParts.set(Section.FRAGMENT_MAIN_IMAGE, fragmentMainImage + "color0 = sRGBTransferEOTF(color0);\n\t");
294294

295295
}
296296

src/utils/EffectShaderData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export class EffectShaderData implements ShaderData {
271271
// Convert the input color to the required color space.
272272
fragmentMainImage += (effect.inputColorSpace === SRGBColorSpace) ?
273273
"color0 = sRGBTransferOETF(color0);\n\t" :
274-
"color0 = sRGBToLinear(color0);\n\t";
274+
"color0 = sRGBTransferEOTF(color0);\n\t";
275275

276276
}
277277

0 commit comments

Comments
 (0)