Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure bump map scale is texture UV scale invariant. adjust examples. #26899

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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