Skip to content

Commit f999167

Browse files
author
Omar Shehata
authored
Merge pull request #8128 from AnalyticalGraphicsInc/unlit
Don't apply tonemapping for unlit material
2 parents 3febbfe + 772e1ab commit f999167

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Source/Scene/processPbrMaterials.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,21 @@ define([
534534
' return vec4(linearOut, srgbIn.a);\n' +
535535
'}\n\n';
536536

537+
fragmentShader +=
538+
'vec3 applyTonemapping(vec3 linearIn) \n' +
539+
'{\n' +
540+
'#ifndef HDR \n' +
541+
' return czm_acesTonemapping(linearIn);\n' +
542+
'#else \n' +
543+
' return linearIn;\n' +
544+
'#endif \n' +
545+
'}\n\n';
546+
537547
fragmentShader +=
538548
'vec3 LINEARtoSRGB(vec3 linearIn) \n' +
539549
'{\n' +
540550
'#ifndef HDR \n' +
541-
' return pow(czm_acesTonemapping(linearIn), vec3(1.0/2.2));\n' +
551+
' return pow(linearIn, vec3(1.0/2.2));\n' +
542552
'#else \n' +
543553
' return linearIn;\n' +
544554
'#endif \n' +
@@ -845,8 +855,12 @@ define([
845855
}
846856
}
847857

848-
// Final color
858+
if (!isUnlit) {
859+
fragmentShader += ' color = applyTonemapping(color);\n';
860+
}
861+
849862
fragmentShader += ' color = LINEARtoSRGB(color);\n';
863+
850864
if (defined(alphaMode)) {
851865
if (alphaMode === 'MASK') {
852866
fragmentShader += ' if (baseColorWithAlpha.a < u_alphaCutoff) {\n';

Specs/Scene/ModelSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ defineSuite([
10261026
scene : scene,
10271027
time : JulianDate.fromDate(new Date('January 1, 2014 12:00:00 UTC'))
10281028
}).toRenderAndCall(function(rgba) {
1029-
expect(rgba).toEqualEpsilon([193, 17, 16, 255], 5); // Red
1029+
expect(rgba).toEqualEpsilon([174, 6, 5, 255], 5); // Red
10301030
});
10311031

10321032
primitives.remove(m);

0 commit comments

Comments
 (0)