Skip to content

Commit

Permalink
ensure bump map scale is texture scale invariant. adjust examples. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bhouston authored Oct 5, 2023
1 parent 8de143f commit 7b13bb5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions examples/webgl_lights_physical.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
roughness: 0.8,
color: 0xffffff,
metalness: 0.2,
bumpScale: 0.0005
bumpScale: 1
} );
const textureLoader = new THREE.TextureLoader();
textureLoader.load( 'textures/hardwood2_diffuse.jpg', function ( map ) {
Expand Down Expand Up @@ -149,7 +149,7 @@
cubeMat = new THREE.MeshStandardMaterial( {
roughness: 0.7,
color: 0xffffff,
bumpScale: 0.002,
bumpScale: 1,
metalness: 0.2
} );
textureLoader.load( 'textures/brick_diffuse.jpg', function ( map ) {
Expand Down
2 changes: 1 addition & 1 deletion examples/webgl_materials_bumpmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
specular: 0x666666,
shininess: 25,
bumpMap: mapHeight,
bumpScale: 0.1
bumpScale: 10
} );

loader = new GLTFLoader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ export default /* glsl */`
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
vec3 vSigmaX = dFdx( surf_pos.xyz );
vec3 vSigmaY = dFdy( surf_pos.xyz );
// normalize is done to ensure that the bump map looks the same regardless of the texture's scale
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
vec3 vN = surf_norm; // normalized
vec3 R1 = cross( vSigmaY, vN );
Expand Down

0 comments on commit 7b13bb5

Please sign in to comment.