Skip to content

Commit

Permalink
LightShadow: Renamed shadowOffset to shadowBias.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Jun 22, 2020
1 parent 08d8d14 commit 5411988
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion docs/api/en/lights/shadows/LightShadow.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ <h3>[property:Float bias]</h3>
The default is 0. Very tiny adjustments here (in the order of 0.0001) may help reduce artefacts in shadows
</p>

<h3>[property:Float normalOffset]</h3>
<h3>[property:Float normalBias]</h3>
<p>Defines how much the position used to query the shadow map is offset along the object normal.</p>
<p>The default is 0. Increasing this value can be used to reduce shadow acne especially in large scenes where light shines onto geometry at a shallow angle. The cost is that shadows may appear distorted.</p>

Expand Down
2 changes: 1 addition & 1 deletion docs/api/zh/lights/shadows/LightShadow.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h3>[property:Float bias]</h3>
默认值为0.此处非常小的调整(大约0.0001)可能有助于减少阴影中的伪影
</p>

<h3>[property:Float normalOffset]</h3>
<h3>[property:Float normalBias]</h3>
<p>Defines how much the position used to query the shadow map is offset along the object normal.</p>
<p>The default is 0. Increasing this value can be used to reduce shadow acne especially in large scenes where light shines onto geometry at a shallow angle. The cost is that shadows may appear distorted.</p>

Expand Down
18 changes: 9 additions & 9 deletions editor/js/Sidebar.Object.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,14 @@ function SidebarObject( editor ) {

// shadow normal offset

var objectShadowNormalOffsetRow = new UIRow();
var objectShadowNormalBiasRow = new UIRow();

objectShadowNormalOffsetRow.add( new UIText( strings.getKey( 'sidebar/object/shadowNormalOffset' ) ).setWidth( '90px' ) );
objectShadowNormalBiasRow.add( new UIText( strings.getKey( 'sidebar/object/shadowNormalBias' ) ).setWidth( '90px' ) );

var objectShadowNormalOffset = new UINumber( 0 ).onChange( update );
objectShadowNormalOffsetRow.add( objectShadowNormalOffset );
var objectShadowNormalBias = new UINumber( 0 ).onChange( update );
objectShadowNormalBiasRow.add( objectShadowNormalBias );

container.add( objectShadowNormalOffsetRow );
container.add( objectShadowNormalBiasRow );

// shadow radius

Expand Down Expand Up @@ -611,9 +611,9 @@ function SidebarObject( editor ) {

}

if ( object.shadow.normalOffset !== objectShadowNormalOffset.getValue() ) {
if ( object.shadow.normalBias !== objectShadowNormalBias.getValue() ) {

editor.execute( new SetValueCommand( editor, object.shadow, 'normalOffset', objectShadowNormalOffset.getValue() ) );
editor.execute( new SetValueCommand( editor, object.shadow, 'normalBias', objectShadowNormalBias.getValue() ) );

}

Expand Down Expand Up @@ -663,7 +663,7 @@ function SidebarObject( editor ) {
'decay': objectDecayRow,
'castShadow': objectShadowRow,
'receiveShadow': objectReceiveShadow,
'shadow': [ objectShadowBiasRow, objectShadowNormalOffsetRow, objectShadowRadiusRow ]
'shadow': [ objectShadowBiasRow, objectShadowNormalBiasRow, objectShadowRadiusRow ]
};

for ( var property in properties ) {
Expand Down Expand Up @@ -858,7 +858,7 @@ function SidebarObject( editor ) {
if ( object.shadow !== undefined ) {

objectShadowBias.setValue( object.shadow.bias );
objectShadowNormalOffset.setValue( object.shadow.normalOffset );
objectShadowNormalBias.setValue( object.shadow.normalBias );
objectShadowRadius.setValue( object.shadow.radius );

}
Expand Down
6 changes: 3 additions & 3 deletions editor/js/Strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function Strings( config ) {
'sidebar/object/decay': 'Decay',
'sidebar/object/shadow': 'Shadow',
'sidebar/object/shadowBias': 'Shadow Bias',
'sidebar/object/shadowNormalOffset': 'Shadow Normal Offset',
'sidebar/object/shadowNormalBias': 'Shadow Normal Bias',
'sidebar/object/shadowRadius': 'Shadow Radius',
'sidebar/object/cast': 'cast',
'sidebar/object/receive': 'receive',
Expand Down Expand Up @@ -430,7 +430,7 @@ function Strings( config ) {
'sidebar/object/decay': 'Affaiblissement',
'sidebar/object/shadow': 'Ombre',
'sidebar/object/shadowBias': 'Biais directionnel des ombres',
'sidebar/object/shadowNormalOffset': 'Shadow Normal Offset',
'sidebar/object/shadowNormalBias': 'Shadow Normal Bias',
'sidebar/object/shadowRadius': 'Rayon de l\'ombre',
'sidebar/object/cast': 'Projète',
'sidebar/object/receive': 'Reçoit',
Expand Down Expand Up @@ -748,7 +748,7 @@ function Strings( config ) {
'sidebar/object/decay': '衰减',
'sidebar/object/shadow': '阴影',
'sidebar/object/shadowBias': '阴影偏移',
'sidebar/object/shadowNormalOffset': '阴影法线偏移',
'sidebar/object/shadowNormalBias': 'Shadow Normal Bias',
'sidebar/object/shadowRadius': '阴影半径',
'sidebar/object/cast': '产生',
'sidebar/object/receive': '接受',
Expand Down
2 changes: 1 addition & 1 deletion src/lights/LightShadow.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class LightShadow {

camera: Camera;
bias: number;
normalOffset: number;
normalBias: number;
radius: number;
mapSize: Vector2;
map: RenderTarget;
Expand Down
4 changes: 2 additions & 2 deletions src/lights/LightShadow.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function LightShadow( camera ) {
this.camera = camera;

this.bias = 0;
this.normalOffset = 0;
this.normalBias = 0;
this.radius = 1;

this.mapSize = new Vector2( 512, 512 );
Expand Down Expand Up @@ -121,7 +121,7 @@ Object.assign( LightShadow.prototype, {
const object = {};

if ( this.bias !== 0 ) object.bias = this.bias;
if ( this.normalOffset !== 0 ) object.normalOffset = this.normalOffset;
if ( this.normalBias !== 0 ) object.normalBias = this.normalBias;
if ( this.radius !== 1 ) object.radius = this.radius;
if ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray();

Expand Down
2 changes: 1 addition & 1 deletion src/loaders/ObjectLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ ObjectLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
if ( data.shadow ) {

if ( data.shadow.bias !== undefined ) object.shadow.bias = data.shadow.bias;
if ( data.shadow.normalOffset !== undefined ) object.shadow.normalOffset = data.shadow.normalOffset;
if ( data.shadow.normalBias !== undefined ) object.shadow.normalBias = data.shadow.normalBias;
if ( data.shadow.radius !== undefined ) object.shadow.radius = data.shadow.radius;
if ( data.shadow.mapSize !== undefined ) object.shadow.mapSize.fromArray( data.shadow.mapSize );
if ( data.shadow.camera !== undefined ) object.shadow.camera = this.parseObject( data.shadow.camera );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default /* glsl */`
struct DirectionalLightShadow {
float shadowBias;
float shadowNormalOffset;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
Expand All @@ -24,7 +24,7 @@ export default /* glsl */`
struct SpotLightShadow {
float shadowBias;
float shadowNormalOffset;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
Expand All @@ -40,7 +40,7 @@ export default /* glsl */`
struct PointLightShadow {
float shadowBias;
float shadowNormalOffset;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default /* glsl */`
struct DirectionalLightShadow {
float shadowBias;
float shadowNormalOffset;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
Expand All @@ -24,7 +24,7 @@ export default /* glsl */`
struct SpotLightShadow {
float shadowBias;
float shadowNormalOffset;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
Expand All @@ -40,7 +40,7 @@ export default /* glsl */`
struct PointLightShadow {
float shadowBias;
float shadowNormalOffset;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
Expand Down
6 changes: 3 additions & 3 deletions src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default /* glsl */`
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalOffset, 0 );
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
}
Expand All @@ -27,7 +27,7 @@ export default /* glsl */`
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalOffset, 0 );
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;
}
Expand All @@ -40,7 +40,7 @@ export default /* glsl */`
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalOffset, 0 );
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
}
Expand Down
6 changes: 3 additions & 3 deletions src/renderers/shaders/UniformsLib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export let UniformsLib: {
value: any[];
properties: {
shadowBias: {};
shadowNormalOffset: {};
shadowNormalBias: {};
shadowRadius: {};
shadowMapSize: {};
};
Expand All @@ -96,7 +96,7 @@ export let UniformsLib: {
value: any[];
properties: {
shadowBias: {};
shadowNormalOffset: {};
shadowNormalBias: {};
shadowRadius: {};
shadowMapSize: {};
};
Expand All @@ -116,7 +116,7 @@ export let UniformsLib: {
value: any[];
properties: {
shadowBias: {};
shadowNormalOffset: {};
shadowNormalBias: {};
shadowRadius: {};
shadowMapSize: {};
};
Expand Down
6 changes: 3 additions & 3 deletions src/renderers/shaders/UniformsLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const UniformsLib = {

directionalLightShadows: { value: [], properties: {
shadowBias: {},
shadowNormalOffset: {},
shadowNormalBias: {},
shadowRadius: {},
shadowMapSize: {}
} },
Expand All @@ -139,7 +139,7 @@ const UniformsLib = {

spotLightShadows: { value: [], properties: {
shadowBias: {},
shadowNormalOffset: {},
shadowNormalBias: {},
shadowRadius: {},
shadowMapSize: {}
} },
Expand All @@ -156,7 +156,7 @@ const UniformsLib = {

pointLightShadows: { value: [], properties: {
shadowBias: {},
shadowNormalOffset: {},
shadowNormalBias: {},
shadowRadius: {},
shadowMapSize: {},
shadowCameraNear: {},
Expand Down
12 changes: 6 additions & 6 deletions src/renderers/webgl/WebGLLights.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function ShadowUniformsCache() {
case 'DirectionalLight':
uniforms = {
shadowBias: 0,
shadowNormalOffset: 0,
shadowNormalBias: 0,
shadowRadius: 1,
shadowMapSize: new Vector2()
};
Expand All @@ -112,7 +112,7 @@ function ShadowUniformsCache() {
case 'SpotLight':
uniforms = {
shadowBias: 0,
shadowNormalOffset: 0,
shadowNormalBias: 0,
shadowRadius: 1,
shadowMapSize: new Vector2()
};
Expand All @@ -121,7 +121,7 @@ function ShadowUniformsCache() {
case 'PointLight':
uniforms = {
shadowBias: 0,
shadowNormalOffset: 0,
shadowNormalBias: 0,
shadowRadius: 1,
shadowMapSize: new Vector2(),
shadowCameraNear: 1,
Expand Down Expand Up @@ -261,7 +261,7 @@ function WebGLLights() {
const shadowUniforms = shadowCache.get( light );

shadowUniforms.shadowBias = shadow.bias;
shadowUniforms.shadowNormalOffset = shadow.normalOffset;
shadowUniforms.shadowNormalBias = shadow.normalBias;
shadowUniforms.shadowRadius = shadow.radius;
shadowUniforms.shadowMapSize = shadow.mapSize;

Expand Down Expand Up @@ -303,7 +303,7 @@ function WebGLLights() {
const shadowUniforms = shadowCache.get( light );

shadowUniforms.shadowBias = shadow.bias;
shadowUniforms.shadowNormalOffset = shadow.normalOffset;
shadowUniforms.shadowNormalBias = shadow.normalBias;
shadowUniforms.shadowRadius = shadow.radius;
shadowUniforms.shadowMapSize = shadow.mapSize;

Expand Down Expand Up @@ -369,7 +369,7 @@ function WebGLLights() {
const shadowUniforms = shadowCache.get( light );

shadowUniforms.shadowBias = shadow.bias;
shadowUniforms.shadowNormalOffset = shadow.normalOffset;
shadowUniforms.shadowNormalBias = shadow.normalBias;
shadowUniforms.shadowRadius = shadow.radius;
shadowUniforms.shadowMapSize = shadow.mapSize;
shadowUniforms.shadowCameraNear = shadow.camera.near;
Expand Down

0 comments on commit 5411988

Please sign in to comment.