What could be causing the texture distortion in THREE.js?

I am encountering an issue with the textures loaded using the TextureLoader, as they seem to be causing tearing errors within the texture.

Below is the code snippet I am using for the material:

    var textureName = "Melamine-wood-001";
var textureUrl = "textures/wood01/"+textureName+"/";
var loadedTextureName = textureUrl + textureName;
var textureExtention = ".png";
var textureWrappingAmount = 5; // defined amount of texture wrapping

// Load diffuse texture
textureDiffuse = new THREE.TextureLoader().load(loadedTextureName+textureExtention);

// Load Specular Map 
textureSpec = new THREE.TextureLoader().load(loadedTextureName +'_spec'+textureExtention);

// Load Normal Map 
textureNormal = new THREE.TextureLoader().load(loadedTextureName +'_normal'+textureExtention);

// Load Bump Map 
textureBump = new THREE.TextureLoader().load(loadedTextureName +'_displace'+textureExtention);

// Load Environment Map 
textureEnvironment = new THREE.TextureLoader().load('textures/envMaps/envMap.jpg');

// Configure Texture Wrapping
textureDiffuse.wrapS = THREE.RepeatWrapping;
textureDiffuse.wrapT = THREE.RepeatWrapping;
textureDiffuse.repeat.set(textureWrappingAmount,textureWrappingAmount);

textureSpec.wrapS = THREE.RepeatWrapping;
textureSpec.wrapT = THREE.RepeatWrapping;
textureSpec.repeat.set(textureWrappingAmount,textureWrappingAmount);

textureNormal.wrapS = THREE.RepeatWrapping;
textureNormal.wrapT = THREE.RepeatWrapping;
textureNormal.repeat.set(textureWrappingAmount,textureWrappingAmount);

textureBump.wrapS = THREE.RepeatWrapping;
textureBump.wrapT = THREE.RepeatWrapping;
textureBump.repeat.set(textureWrappingAmount,textureWrappingAmount);

// Create Textured Material
material01 = new THREE.MeshPhongMaterial({
    map: textureDiffuse,
    specularMap: textureSpec,
    envMap: textureEnvironment,
    bumpMap: textureBump,
    normalMap: textureNormal,
    normalScale: new THREE.Vector2( 0.15, 0.15 ),
    specular: 0xffffff,
    shininess: 30,
    reflectivity: 0,
    side: THREE.DoubleSide
});

https://i.sstatic.net/bgl7J.png

I am utilizing the OBJLoader alongside r74 version.

This issue does not persist if I use a matCap shader.

// Define matCap material
materialMatCap = new THREE.ShaderMaterial( {

        uniforms: { 
            tMatCap: { 
                type: 't', 
                value: new THREE.TextureLoader().load( 'textures/matCap/ChromeB.png' ) 
            },
        },
        vertexShader: document.getElementById( 'sem-vs' ).textContent,
        fragmentShader: document.getElementById( 'sem-fs' ).textContent,
        shading: THREE.SmoothShading,
        side: THREE.DoubleSide

    } );

    THREE.ClampToEdgeWrapping;

}

https://i.sstatic.net/n3tih.png

**Any insights on what might be triggering this issue would be greatly appreciated.

Answer №1

The issue you are observing is a result of self-shadowing artifacts. To learn more, check out this informative response on Stack Overflow.

Popular solutions involve relocating the light source or modifying the light.shadow.bias property.

Using three.js version r.75

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Triggering Jquery event multiple times

I am using a jQuery datatable that gets populated with data from a database through an AJAX call when a user clicks on a load button. The data is displayed based on the date selected by the user in a datepicker. I have also added an export button to allow ...

Creating Three-Dimensional Faces in THREE.BufferGeometry

I have programmatically created a basic mesh structure: var CreateSimpleMesh = new function () { var xy = [], maxX = 7, maxY = 10, river = [[0, 5], [0, 4], [1, 3], [2, 2], [3, 2], [4, 1], [5, 1], [6, 0]], grassGeometry ...

Is the div empty? Maybe jQuery knows the answer

I currently have a <div id="slideshow"> element on my website. This div is fully populated in the index.php file, but empty in all other pages (since it's a Joomla module). When the div is full, everything works fine. However, when it's emp ...

Tips on Moving a Bootstrap Modal Popup with the Arrow Keys on Your Keyboard

This example showcases the integration of Bootstrap's Default Modal Popup with jQuery UI Draggable Function. The JS fiddle link provided below contains the code snippet. $(document).ready(function() { $("#btnTest").click(function() { $(&a ...

What is the process for creating a pop-up bubble that appears when the cursor hovers over an image displayed within a table using R Shiny?

I am currently working on code that is almost achieving my desired functionality. I want to make it so that hovering over each question mark in the table will trigger a pop-up bubble displaying the help text, rather than having the text appear at the botto ...

Having trouble setting cookies with Node.js Express?

Check out this code snippet: const app = express(); const cookieParser = require('cookie-parser'); app.use(cookieParser()); app.post("/pinfo", (req, res) => { var form = new formidable.IncomingForm(); form.parse(req, async functi ...

Learn how to create an animated refreshing icon in React when clicked

I have a refresh icon in my React app that utilizes Material UI. I want the icon to spin for a second after it is clicked, but I am unsure of how to achieve this. Despite attempting some solutions, none have been successful. const useStyles = makeStyles(( ...

Do we need to have the 'input type file' field as

I am currently working on a PHP form that includes mandatory fields for saving the data. For example: <td><input class="text_area required" type="text" name="new field" This form also has Javascript code with file upload functionality, which I ...

Issues with the functionality of minimized AngularJS JavaScript files

I combined all JS files into one and minified them, but now none of the site features are working. There were too many separate JS files to include individually, so I decided to merge them together. Is there a better method to reduce the number of HTTP r ...

Encountering NaN values in JavaScript arrays

I'm facing an issue with my HTML code that is supposed to make ball(s) bounce around the canvas. However, when I set the arrays storing the coordinates to random positions and test with alert("Co-ordinates " + (cirX[i]) + " x " + (cirY[i]));, it retur ...

When zooming out, Leaflet displays both tile layers

I'm currently working on integrating two tile layers along with a control for toggling between them. Below is the code snippet I am using: const layer1: L.TileLayer = L.tileLayer('http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png', { ...

Different ways to send data from JavaScript to Python using the 'POST' method

I have this specific section of code from my GAE application that utilizes webapp2 framework to receive data from a form through the post method. class RenderMarksheet(webapp2.RequestHandler): def post(self): regno = self.request.get('content ...

The class name remains unchanged despite the change in value

I am currently working on a webpage that features two interactive tabs. The goal is to have one tab highlighted as "active" while the other remains inactive when clicked, and then switch roles when the other tab is selected. Below is the code snippet I ha ...

Exploring the Positives and Negatives of Using JQuery and Glow JavaScript Libraries

Is there a detailed analysis available that compares JQuery with the BBC's Glow JavaScript libraries? ...

Random animation delay in an A-frame structure

I'm in the process of creating a virtual scene using A-frame () and have implemented an animation within it. My query pertains to randomizing the delay on this animation, so that it ranges from 0 to 2 seconds. Is there a method to achieve this? The cu ...

The enigmatic loop traversal

Can you figure out why the name property of the merged object is properly set in the code below, even though the for-loop starts with i = 1? function merge(root){ for ( var i = 1; i < arguments.length; i++ ){ for ( var key in arguments[i] ){ ...

Finding out whether the current date falls between a startDate and endDate within a nested object in mongoose can be done by using a specific method

My data structure includes a nested object as shown: votingPeriod: {startDate: ISOdate(), endDate: ISOdate()}. Despite using the query below, I am getting an empty object back from my MongoDB. const organizations = await this.organizationRepository.find( ...

Strange behavior of focus()

My objective is to launch a popup containing an input field and automatically bring focus to that input. I have attempted using $('#input').focus(), $('#input').first().focus(), and $('#input')[0].focus(), but unfortunately, ...

Verify if the currentRoute begins with a specific text pattern (such as something/something/*...) in Angular

I need to prevent a loader from appearing on certain screens, so I used ngIf on routes where the loader is not necessary. Here's the code snippet from app.component.ts : <router-outlet> <app-spinner></app-spinner> <ngx-ui-load ...

Leveraging JavaScript's regular expressions to identify and capture the end of a

I am in need of using regular expressions (regex) to validate an ajax call to retrieve an output log from a server to check if a certain process is "finished". I have a PHP file that can provide the last line of the log under any circumstances. The Ajax ...