Skip to content

Commit 3898800

Browse files
committed
remove gamma "correction" on non-texture shader parameters per discussion here: mrdoob#5838 examples are not yet updated.
1 parent 1b940ff commit 3898800

File tree

1 file changed

+15
-106
lines changed

1 file changed

+15
-106
lines changed

src/renderers/WebGLRenderer.js

+15-106
Original file line numberDiff line numberDiff line change
@@ -4523,15 +4523,7 @@ THREE.WebGLRenderer = function ( parameters ) {
45234523

45244524
uniforms.opacity.value = material.opacity;
45254525

4526-
if ( _this.gammaInput ) {
4527-
4528-
uniforms.diffuse.value.copyGammaToLinear( material.color, _this.gammaFactor );
4529-
4530-
} else {
4531-
4532-
uniforms.diffuse.value = material.color;
4533-
4534-
}
4526+
uniforms.diffuse.value = material.color;
45354527

45364528
uniforms.map.value = material.map;
45374529
uniforms.lightMap.value = material.lightMap;
@@ -4595,17 +4587,7 @@ THREE.WebGLRenderer = function ( parameters ) {
45954587
uniforms.envMap.value = material.envMap;
45964588
uniforms.flipEnvMap.value = ( material.envMap instanceof THREE.WebGLRenderTargetCube ) ? 1 : - 1;
45974589

4598-
if ( _this.gammaInput ) {
4599-
4600-
//uniforms.reflectivity.value = material.reflectivity * material.reflectivity;
4601-
uniforms.reflectivity.value = material.reflectivity;
4602-
4603-
} else {
4604-
4605-
uniforms.reflectivity.value = material.reflectivity;
4606-
4607-
}
4608-
4590+
uniforms.reflectivity.value = material.reflectivity;
46094591
uniforms.refractionRatio.value = material.refractionRatio;
46104592

46114593
}
@@ -4657,20 +4639,9 @@ THREE.WebGLRenderer = function ( parameters ) {
46574639

46584640
uniforms.shininess.value = material.shininess;
46594641

4660-
if ( _this.gammaInput ) {
4661-
4662-
uniforms.ambient.value.copyGammaToLinear( material.ambient, _this.gammaFactor );
4663-
uniforms.emissive.value.copyGammaToLinear( material.emissive, _this.gammaFactor );
4664-
uniforms.specular.value.copyGammaToLinear( material.specular, _this.gammaFactor );
4665-
4666-
4667-
} else {
4668-
4669-
uniforms.ambient.value = material.ambient;
4670-
uniforms.emissive.value = material.emissive;
4671-
uniforms.specular.value = material.specular;
4672-
4673-
}
4642+
uniforms.ambient.value = material.ambient;
4643+
uniforms.emissive.value = material.emissive;
4644+
uniforms.specular.value = material.specular;
46744645

46754646
if ( material.wrapAround ) {
46764647

@@ -4682,17 +4653,8 @@ THREE.WebGLRenderer = function ( parameters ) {
46824653

46834654
function refreshUniformsLambert ( uniforms, material ) {
46844655

4685-
if ( _this.gammaInput ) {
4686-
4687-
uniforms.ambient.value.copyGammaToLinear( material.ambient, _this.gammaFactor );
4688-
uniforms.emissive.value.copyGammaToLinear( material.emissive, _this.gammaFactor );
4689-
4690-
} else {
4691-
4692-
uniforms.ambient.value = material.ambient;
4693-
uniforms.emissive.value = material.emissive;
4694-
4695-
}
4656+
uniforms.ambient.value = material.ambient;
4657+
uniforms.emissive.value = material.emissive;
46964658

46974659
if ( material.wrapAround ) {
46984660

@@ -5157,16 +5119,6 @@ THREE.WebGLRenderer = function ( parameters ) {
51575119

51585120
}
51595121

5160-
//
5161-
5162-
function setColorGamma( array, offset, color, intensity, gammaFactor ) {
5163-
5164-
array[ offset ] = Math.pow( color.r * intensity, gammaFactor );
5165-
array[ offset + 1 ] = Math.pow( color.g * intensity, gammaFactor );
5166-
array[ offset + 2 ] = Math.pow( color.b * intensity, gammaFactor );
5167-
5168-
}
5169-
51705122
function setColorLinear( array, offset, color, intensity ) {
51715123

51725124
array[ offset ] = color.r * intensity;
@@ -5233,19 +5185,9 @@ THREE.WebGLRenderer = function ( parameters ) {
52335185

52345186
if ( ! light.visible ) continue;
52355187

5236-
if ( _this.gammaInput ) {
5237-
5238-
r += Math.pow( color.r, _this.gammaFactor );
5239-
g += Math.pow( color.g, _this.gammaFactor );
5240-
b += Math.pow( color.b, _this.gammaFactor );
5241-
5242-
} else {
5243-
5244-
r += color.r;
5245-
g += color.g;
5246-
b += color.b;
5247-
5248-
}
5188+
r += color.r;
5189+
g += color.g;
5190+
b += color.b;
52495191

52505192
} else if ( light instanceof THREE.DirectionalLight ) {
52515193

@@ -5264,15 +5206,7 @@ THREE.WebGLRenderer = function ( parameters ) {
52645206
dirPositions[ dirOffset + 1 ] = _direction.y;
52655207
dirPositions[ dirOffset + 2 ] = _direction.z;
52665208

5267-
if ( _this.gammaInput ) {
5268-
5269-
setColorGamma( dirColors, dirOffset, color, intensity, _this.gammaFactor );
5270-
5271-
} else {
5272-
5273-
setColorLinear( dirColors, dirOffset, color, intensity );
5274-
5275-
}
5209+
setColorLinear( dirColors, dirOffset, color, intensity );
52765210

52775211
dirLength += 1;
52785212

@@ -5284,15 +5218,7 @@ THREE.WebGLRenderer = function ( parameters ) {
52845218

52855219
pointOffset = pointLength * 3;
52865220

5287-
if ( _this.gammaInput ) {
5288-
5289-
setColorGamma( pointColors, pointOffset, color, intensity, _this.gammaFactor );
5290-
5291-
} else {
5292-
5293-
setColorLinear( pointColors, pointOffset, color, intensity );
5294-
5295-
}
5221+
setColorLinear( pointColors, pointOffset, color, intensity );
52965222

52975223
_vector3.setFromMatrixPosition( light.matrixWorld );
52985224

@@ -5312,15 +5238,7 @@ THREE.WebGLRenderer = function ( parameters ) {
53125238

53135239
spotOffset = spotLength * 3;
53145240

5315-
if ( _this.gammaInput ) {
5316-
5317-
setColorGamma( spotColors, spotOffset, color, intensity, _this.gammaFactor );
5318-
5319-
} else {
5320-
5321-
setColorLinear( spotColors, spotOffset, color, intensity );
5322-
5323-
}
5241+
setColorLinear( spotColors, spotOffset, color, intensity );
53245242

53255243
_direction.setFromMatrixPosition( light.matrixWorld );
53265244

@@ -5361,17 +5279,8 @@ THREE.WebGLRenderer = function ( parameters ) {
53615279
skyColor = light.color;
53625280
groundColor = light.groundColor;
53635281

5364-
if ( _this.gammaInput ) {
5365-
5366-
setColorGamma( hemiSkyColors, hemiOffset, skyColor, intensity, _this.gammaFactor );
5367-
setColorGamma( hemiGroundColors, hemiOffset, groundColor, intensity, _this.gammaFactor );
5368-
5369-
} else {
5370-
5371-
setColorLinear( hemiSkyColors, hemiOffset, skyColor, intensity );
5372-
setColorLinear( hemiGroundColors, hemiOffset, groundColor, intensity );
5373-
5374-
}
5282+
setColorLinear( hemiSkyColors, hemiOffset, skyColor, intensity );
5283+
setColorLinear( hemiGroundColors, hemiOffset, groundColor, intensity );
53755284

53765285
hemiLength += 1;
53775286

0 commit comments

Comments
 (0)