The ground shadows appear distorted and muddled

In my Threejs project, I have implemented a method to dynamically create a ground using perlin noise. The code snippet is shown below:

createGround() {

const resolutionX = 100
const resolutionY = 100
const actualResolutionX = resolutionX + 1 
const actualResolutionY = resolutionY + 1

const geometryPlane = new THREE.PlaneGeometry(this.sizeX, this.sizeY, resolutionX, resolutionY)

const noise = perlin.generatePerlinNoise(actualResolutionX, actualResolutionY)

let i = 0

for (let x = 0; x < actualResolutionX; x++) {
  for (let y = 0; y < actualResolutionY; y++) {
    let h = noise[i]
    }

    geometryPlane.vertices[i].z = h
    i++
  }
}

geometryPlane.verticesNeedUpdate = true
geometryPlane.computeFaceNormals()

const materialPlane = new THREE.MeshStandardMaterial({
  color: 0xffff00,
  side: THREE.FrontSide,
  roughness: 1,
  metallness: 0,
})

const ground = new THREE.Mesh(geometryPlane, materialPlane)
geometryPlane.computeVertexNormals()
ground.name = GROUND_NAME
ground.receiveShadow = true
scene.add(ground)

I am satisfied with the generated geometry, however, I am facing an issue with the accuracy of shadows on the ground.

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

Below is the code snippet for the light setup:

const light = new THREE.DirectionalLight(
  'white',
  1,
)
light.shadow.mapSize.width = 512 * 12 
light.shadow.mapSize.height = 512 * 12 
light.castShadow = true
light.position.set(100, 100, 100)
scene.add(light)

light.shadowCameraVisible = true

My query is regarding how to improve the accuracy and definition of shadows on the ground to showcase its geometry effectively.

For the complete code, visit: https://github.com/Waltari10/workwork

Answer №1

Wow, I must say, your shadow game is surprisingly strong considering the lack of proper lighting setup :).

It seems like this render is making do with either default lighting or some pre-existing lighting setup that didn't prioritize shadows.

Why not try incorporating some directional light to mimic the sun's direction and color to see if it enhances the shadows? Or, feel free to share more details about your current lighting arrangement.

If you happen to have any shadow mapping lights already in place, it might be worth checking their resolution to ensure it's sufficient - you might need to increase it.

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

What is the best way to implement multiple filters on the data of a Vue component?

I am facing a challenge in implementing multiple filters in a component. For instance, users should be able to choose a category and have the results filtered accordingly. Moreover, with a search filter already in place, I am looking for a way to combine i ...

Operate a seamless resizing of container divs within the Bootstrap carousel to avoid any sudden "jump" in size adjustments

In my current project, I am faced with the challenge of smoothly resizing container divs as users switch between image or video assets of varying sizes/heights within a Bootstrap carousel. Currently, the resizing process appears to be abrupt and not visua ...

Unwrapping React: Mastering the Art of Prop Extraction and Sharing

Imagine I have 2 input elements below, both with the same props except for the className <ReactCardFlip> <input type="text" maxLength={1} className={inputStyles.input} defaultValue={value} ...

The EJS template on the Express app is encountering an issue: it is unable to find the view "/id" within the views directory located at "/home/USER/Desktop/scholarship-app/views"

When attempting to render the request URL for an ID in my Express app, I encountered the following error: Error: Failed to find view "/id" in views directory "/home/USER/Desktop/scholarship-app/views" Here is a portion of my Express app code: app.get(&a ...

Regular Expressions for Strings in JavaScript

I want to create a regular expression in JavaScript that can search for patterns like ${.............}. For example, if I have a string like { "type" : "id", "id" : ${idOf('/tar/check/inof/high1')}, "details" : [ { ...

What is the process for accessing a table in indexedDB using Dexie.js immediately after it has been opened?

I am faced with the challenge of needing to verify if a specific table already exists in IndexedDB right after it has been opened. However, I am unsure how to access the DexieDB object inside the 'then' statement. this.db = new Dexie("DBNAME"); ...

Styling the button in jQuery to switch between disabled and enabled

I'm currently working on creating a disabled/enable button style using jQuery. You can check out my demonstration page on Codepen for reference. In the demo, you'll notice a blue submit button. When you input text into the field, the button bec ...

What steps should I take to ensure I receive a response after submitting a form to a designated API?

I developed an API that retrieves data and stores it in a MongoDB database. const userDB = require('./model/user') app.post ('/signup', function (req, res){ userDB.find({username: req.body.username}). then (result=>{ ...

Node.js Sequelize QueryExplore the power of Sequelize in Node.js

I'm looking to filter the "incomers" based on age, but all I have in the table is their date of birth. I want to find people within a specific age range, how can I accomplish this? router.post('/', function (req, res, next) { let parame ...

Is there a beginner's pack or trial version available for utilizing TypeScript with IBM Cloud Functions / OpenWhisk?

While working on developing actions in IBM Cloud Functions, I have been primarily using Node.js / Javascript and Python for coding. However, I haven't come across specific instructions on how to incorporate TypeScript into IBM Cloud Functions. I am c ...

Sending Data Through Button from navBar in React-Native-Router-Flux

I have been working on a project that utilizes `react-native-router-flux` and I am facing a challenge in passing an object through `props`. Typically, I would use `Actions.someKey({ someProp: object })` for navigation. However, in this case, I need to navi ...

angularjs identifies the ng-click and href attributes within my event

md-list md-list-item.md-2-line ng-repeat="document in ctrl.documents" div.md-list-item-text ng-click="ctrl.getDocument($event, document)" span ng-bind-html="(document.content | trustedHtml)" Hey there, I've encountered an issue with my md ...

Dealing with AngularJS: Issue arises when attempting to inject $modal into a controller nested within a directive

Our team has implemented a custom directive that wraps around a checkbox and utilizes transclusion to inject content into it. Here is an example of the setup: somecheckbox.js angular.module('namespace.directives') .directive('someCheckbox& ...

What is the most efficient method for generating random dark colors using javascript code?

Looking for a function that specifically returns dark colors. Although I can generate random colors with the code below, how do I make sure it only retrieves dark ones? document.getElementById('mydiv').style.backgroundColor = '#' ...

Creating a distinctive vue form component from scratch

I have a requirement to develop a Vue component that enables users to create or edit a mailing address. The existing component structure is as follows: <template> <v-container> <v-form ref="form" lazy-validation> <v-text-field ...

Tips for eliminating duplicate entries in ag grid using Angular

Is there a way to eliminate the recurring assetCode entries in ag grid? The PRN and PRN1 values seem to be repeating unnecessarily. Check out the code below: list.component.ts ngOnInit() { this.rowData.push( { 'code': 'Machi ...

Using a background image in a React component

Currently, I am working on a webpage and facing an issue while trying to set a background image for a Material UI element using the background-image CSS property. Despite researching online for solutions, I am unable to make the image appear. P.S.1: I eve ...

The PlaneGeometry mesh is causing a black screen when used in Three.JS

As someone who is new to ThreeJS, I am trying to set a background image for a Scene. However, when I run the code below, all I see is a blank (black) screen. Can anyone help me identify the issue in the code? $().ready(function(){ var width= window.i ...

Book a spot in IndexedDB storage

Currently, I am developing a diagnostics application that updates data to IndexedDB every three seconds. The data has a fixed size and anything older than a week is automatically removed, resulting in a maximum of 201600 entries. This simplifies the proces ...

Why does my JavaScript file fail to retrieve the model.findByPk() method with the parameter "/:id"?

When attempting to retrieve items from the database based on their id, I am encountering an issue where Insomnia is returning an empty object. Specifically, in the code snippet below, my goal is to fetch a category by its ID while also retrieving any assoc ...