Skip to content

Commit 0cd998e

Browse files
Fix blackbody node clamping.
1 parent bedc293 commit 0cd998e

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

libraries/pbrlib/genglsl/mx_blackbody.glsl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ void mx_blackbody(float temperatureKelvin, out vec3 colorValue)
88
float xc, yc;
99
float t, t2, t3, xc2, xc3;
1010

11+
// if value outside valid range of approximation clamp to accepted temperature range
12+
temperatureKelvin = clamp(temperatureKelvin, 1667.0, 25000.0);
13+
1114
t = 1000.0 / temperatureKelvin;
1215
t2 = t * t;
1316
t3 = t * t * t;
1417

15-
// if value outside valid range of approximation clamp to accepted temperature range
16-
clamp(temperatureKelvin, 1667.0, 25000.0);
17-
18-
1918
// Cubic spline approximation for Kelvin temperature to sRGB conversion
2019
// (https://en.wikipedia.org/wiki/Planckian_locus#Approximation)
2120
if (temperatureKelvin < 4000.0) { // 1667K <= temperatureKelvin < 4000K

libraries/pbrlib/genosl/mx_blackbody.osl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ void mx_blackbody(float temperature, output color color_value)
33
float xc, yc;
44
float t, t2, t3, xc2, xc3;
55

6+
// if value outside valid range of approximation clamp to accepted temperature range
7+
temperature = clamp(temperature, 1667.0, 25000.0);
8+
69
t = 1000.0 / temperature;
710
t2 = t * t;
811
t3 = t * t * t;
912

10-
// if value outside valid range of approximation clamp to accepted temperature range
11-
clamp(temperature, 1667.0, 25000.0);
12-
13-
1413
// Cubic spline approximation for Kelvin temperature to sRGB conversion
1514
// (https://en.wikipedia.org/wiki/Planckian_locus#Approximation)
1615
if (temperature < 4000.0) { // 1667K <= temperature < 4000K

0 commit comments

Comments
 (0)