Objects hidden in the darkness, utilizing the traditional MeshPhongMaterial

Currently struggling with my shadows issue. Here is a snapshot of the problem I am encountering:

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

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

The presence of those lines puzzles me, as the scene should be evenly illuminated! The shadows appear smooth and borders are satisfactory for my requirements, but these mysterious lines ruin the overall effect.

Here's how I've configured the lighting:

var dirLight = new THREE.DirectionalLight(0xfeffaf, 1);
dirLight.position.set(dimensions.middlePoint.x, 
    dimensions.middlePoint.y + ( dimensions.lengthY / 2),
    dimensions.middlePoint.z + dimensions.lengthZ);
dirLight.target.position.set(
    dimensions.middlePoint.x, 
    dimensions.middlePoint.y, 
    dimensions.minZ);
dirLight.castShadow = true;
dirLight.shadowDarkness = 0.4;
dirLight.shadowMapWidth = 1024;
dirLight.shadowMapHeight = 1024;
dirLight.shadowCameraNear = 1;
dirLight.shadowCameraFar = dimensions.lengthY * 2;
dirLight.shadowCameraLeft = - dimensions.lengthX / 2;
dirLight.shadowCameraRight = dimensions.lengthX / 2;
dirLight.shadowCameraTop = dimensions.lengthY / 2;
dirLight.shadowCameraBottom = -dimensions.lengthY / 2;
dirLight.shadowBias = 0.0000005;
scene.add(dirLight);

In addition, here is my rendering configuration:

threeRender = new THREE.WebGLRenderer({ antialias: true });
threeRender.shadowMap.enabled = true;
threeRender.shadowMap.renderReverseSided = false;
threeRender.shadowMapSoft = true;
threeRender.shadowMapType = THREE.PCFSoftShadowMap;

I would greatly appreciate any insights on resolving this issue and guidance on the correct troubleshooting path. Thank you for your assistance.

Answer №1

To eliminate shadow acne, try increasing the value of your shadowBias. This will help improve the quality of shadows in your rendering:

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

For a more in-depth explanation, you can check out this resource.

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

Guide to populating jQuery DataTables with JSON data

I am currently implementing jquery datatable in my application. You can find the plugin link here My goal is to populate the datatable with JSON data, but I have encountered a problem. Here is the code snippet that I am working with: HTML: <table id= ...

Practical tips for sending an array of objects via RESTful query strings?

What is the most effective way to include an array of objects in a query string using REST principles? Consider the following array: examples[] = [ { name: "foo", value: "1" }, { name: "bar", value: &qu ...

What is the best way to ensure my jQuery plugin is up to date?

I have a question regarding the functionality of this plugin I am using. My goal is to update the timer it provides. To start the countdown timer with 5000 milliseconds remaining, I use the following code: $('#CountdownTimer').countdown({ remai ...

Issue with ExtJs 4 Grid panel resizing incorrectly when window is resized

I have a Grid Panel rendered in a DIV without specifying any width for either the DIV or the Grid Panel. I want them to take up all available browser width, but the Grid does not resize itself when the browser window is resized by the user. I have tried va ...

When a previous form field is filled, validate the next 3 form fields on keyup using jQuery

Upon form submission, if the formfield propBacklink has a value, the validation of fields X, Y, and Z must occur. These fields are always validated, regardless of their values, as they are readonly. An Ajax call will determine whether the validation is tru ...

Unable to utilize the forEach() function on an array-like object

While I generally know how to use forEach, I recently encountered a situation that left me puzzled. Even after searching online, I couldn't find any new information that could help. I recently started delving into TypeScript due to my work with Angul ...

What is the best way to execute my node script with a shell script file?

Currently, I'm working on a personal website using node to help me organize the ebooks I'm reading. Right now, my process involves moving to the project folder and running node server.js. I had an idea to create a shell script so that all I hav ...

How can I stop jQuery mobile from updating the document title?

It appears that jQuery mobile automatically uses the text content of data-role="header" to set the document.title. For example: <div data-position="fixed" data-role="header"> <h1>This text</h1> </div> To work around this, I ha ...

Drawer in Material-UI has whitespace remaining at the corners due to its rounded edges

While using the Material UI drawer, I attempted to round the corners using CSS: style={{ borderRadius: "25px", backgroundColor: "red", overflow: "hidden", padding: "300px" }} Although it somewhat works, the corners appear white instea ...

Customizing the Switch component individually for each item fetched from an API in React Native

I'm struggling with setting the switch button individually for each item in my API. Despite trying multiple solutions, none of them seem to work for me. const results = [ { Id: "IySO9wUrt8", Name: & ...

What is the best method for conducting comprehensive testing of all projects and libraries within NestJS (nx)?

Our NestJS project has been established with multiple libraries through Nx. We have successfully run tests on individual projects/libraries using the following command: npx nx test lib1 --coverage While this method works well, we are faced with numerous l ...

Is it possible to automatically reload the previous link when the back button of the browser is clicked?

I am working on a website where the main content is loaded using jQuery Ajax based on the selected menu item. When a menu item is selected, the URL changes according to this pattern: http://host/domain/index.php?pageid=page In this scenario, the 'p ...

Error message: "Despite using the 'use client' function in Next.js, a ReferenceError occurs as 'window' is undefined."

What is the reason for the server running this hook when "use client" is included? It does not lead to any application crashes, everything functions with no errors, but an error is logged at the const [windowWidth, setWindowWidth] = useState(window.innerWi ...

Interacting with a form input by triggering the onChange event

I am encountering a problem where I need to be able to select a radio button both onChange via keydown and mouse click. However, I am struggling with accessing both event parameters of the on keydown and on mouse click within the same function. As a result ...

Confusion arises from the code for processing an Ajax redirect

I finally succeeded in incorporating an Ajax call into my code, but I'm a bit puzzled about how to redirect after the call is made. Below is an example of my script, developed using CodeIgniter: <script type="text/javascript"> function myFunc ...

Can you explain the significance of foo === +bar?

Currently, I am diving into the world of express and came across a coding challenge that involves downloading a zip file and performing certain tasks. While going through the code, there is a specific line that is causing confusion: const recipe = recipes ...

Having trouble with jQuery Ajax not transmitting data properly in a CodeIgniter project?

I am brand new to the Codeigniter MVC framework. Whenever I attempt to send data through ajax from the views to the controller, I encounter an error. Please click here to view the image for more details. Here is the code snippet: views/ajax_post_view.php ...

Error message: Encountered JavaScript heap out-of-memory error during Azure DevOps React Container Production Build

I am facing challenges in building a React production Docker container with Azure DevOps pipelines. Despite upgrading my build environment and code, the pipeline failed to run successfully. After conducting some research, I attempted to add the "--node-fla ...

Having trouble choosing files on Mobile devices, whether it's IOS or Android

I'm having trouble getting an image upload to change the background of a table automatically. It works fine on Desktop computers, but not on IOS or Android. Does anyone have any advice on how to make it work across all devices? Thanks in advance. cons ...

Ways to retrieve a value from a JavaScript function without using the return statement

I wrote a Javascript method as follows: function ServerSideDatasource(server) { return { getRows: function (params) { var response = server.getData(params.request).then((res) => { var result = { success: true, ...