Displaying 100,000 sprites with a faint 0.1 opacity, utilizing see-through backgrounds and crisp antialiasing

In my current setup, I have the following key pieces of code:

Renderer

renderer = new THREE.WebGLRenderer({ 
    antialias: true, alpha: true, canvas: canvas 
});

Textures

dot: THREE.ImageUtils.loadTexture('./assets/images/dot.png')

Material

let material = new THREE.PointsMaterial({
    size: size,
    sizeAttenuation: true,
    color: color,
    map: textures.dot,
    // alphaMap: textures.dotAlpha,
    blending: THREE.NormalBlending, // THREE.MultiplyBlending
    transparent: true,
    alphaTest: 0.1,
    opacity: 0.3
});

Point cloud Typically, there are 20 to 50 point clouds with anywhere from 1k to 10k dots each. However, only a fraction of these dots are visible on the screen.

pointCloud = new THREE.Points(geometry, material);

Adding points

cfg.pointCloud.forEach(point => {
    var vertex = new THREE.Vector3();
    vertex.x = point.x;
    vertex.y = point.y;
    vertex.z = point.z;
    geometry.vertices.push(vertex);
});

I am facing some challenges:

  • Overlapping sprites just clip each other instead of rendering on top, causing many points to be obscured.
  • Setting material.alphaTest = 0.5 and material.opacity:0.1 results in sharp edges for the sprites, losing any anti-aliasing effect. At a distance, they render poorly and often disappear completely.
  • As the camera moves away from the origin, sprites start disappearing after a certain distance.
  • Dots tend to disappear when using low opacity values.

How can I enhance this rendering? Is there an alternative approach to sprites that I should consider? Without the expertise in custom shader writing, I would greatly appreciate any suggestions for improving this rendering.

Below are sample images illustrating the issues faced:

  • The blue dots, despite being denser in the green zone, are often obscured. This could be due to the rendering order of different colored dots introduced in the scene.

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

  • Tilting the camera sometimes reveals hidden dots due to depth indexing changes.

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

  • Increasing the opacity of certain point clouds may cause them to be obscured by lower-opacity sprites, rather than producing a blending effect as expected.

https://i.sstatic.net/mAgPh.jpg

  • Clustering of most dots leads to many disappearing due to rendering quirks.

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

  • Close-up views exhibit clipping effects between overlapping sprites.

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

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

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

Answer №1

I was able to achieve a significant enhancement in the quality of rendering by making some adjustments. A helpful answer on Stack Overflow provided valuable insights, and I also found useful information in this related question.

To improve the rendering quality, I set both depthWrite and depthTest parameters to false in the material.

let material = new THREE.PointsMaterial({
    size: size,
    sizeAttenuation: true,
    color: color,
    map: this._textures.dot,
    blending: THREE.NormalBlending,
    transparent: true,
    alphaTest: 0.1,
    opacity: 0.3,
    depthWrite: false,
    depthTest: false
});

The difference in the output was quite noticeable:

https://i.sstatic.net/6m2YA.png

https://i.sstatic.net/IYrTV.jpg

However, I am still faced with the challenge of resolving antialiasing issues. When the dots are far away from the camera, they tend to lose clarity and fade out, as depicted in this close-up image.

https://i.sstatic.net/COb9P.jpg

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 setting up 2-factor authentication on GitHub using an AJAX request

My task is to query GitHub for all open pulls, but I'm new to this and don't have anyone to turn to for guidance. The only resources I've found so far are the documentation on . I came across a solution on that explains how to provide a us ...

Neglect to notify about the input text's value

Having trouble retrieving the text from a simple <input id="editfileFormTitleinput" type="text>. Despite my efforts, I am unable to alert the content within the input field. This is the code snippet I've attempted: $('#editfileFormTitleinp ...

Essential Guide to Binding Events with JQuery

Why is the handler for an event on an element triggering the wrong response? I was expecting the click event of Div1 to display a dialog stating 'div1', but it's showing 'div2' instead. I am new to this and trying to figure out wh ...

Implementing CSS styles with the className attribute in a Material UI component within a ReactJS application sourced from a dynamic JSON object

I have a dynamic JSON object that includes a button element. I am using createElement and Material UI to display the data from this object. I wanted to add custom CSS styling to the button component using className, but I've been struggling to achiev ...

Utilizing Node.js and Eclipse to Transfer MongoDB Data to Browser

I am working on a project where I need to display data fetched from MongoDB using Node.js in a web browser. The data is stored in the 'docs' object and I want to pass it to an EJS file so that I can insert it into a table: var express = require( ...

I'm having trouble persisting my mongoose model data in my MongoDB database

Hey there, I'm new to this and currently attempting to save the Amadeus object I've created into mongosh using the .save() method. However, after connecting to my file through node, editing the Amadeus object, and running amadeus.save(), I check ...

Problem with a for loop: retrieve only the final item

Using the fileReader to read the content of selected files and appending it to the DOM creates a paragraph element for each file. However, when attempting to store each file's content in local storage, only the last item is being saved. What could be ...

Learn the art of closing an AngularJS accordion automatically when another accordion is opened within an AngularJS application

I have encountered an issue with the AngularJS accordion functionality. It seems that when I have multiple accordions, such as accordion-1, accordion-2, and accordion-3, they all open simultaneously if clicked on individually. My main concern is: How can ...

Exploring Nashorn's Global Object Variables Through Access and Intercept Techniques

I recently came across a question called "Capturing Nashorn's Global Variables" that got me thinking. I'm facing limitations when it comes to capturing the assignment of variables to the global object. For example, let's say I evaluate the ...

Angular.js - index template fails to execute controller, but other templates work flawlessly

I am facing a strange issue with my Angular application that uses ngRoute. I have set up different controllers for each template in the routes.js file: routes.js: angular.module('PokeApp', ['ngRoute']) .config(function($routeProvide ...

Using JQuery to Iterate Through All Form Inputs

I am attempting to retrieve the values of all input fields from a form using JQuery and store them in an array to be sent via AJAX with a GET request. My initial approach did not yield the desired results: function gatherFormData(){ $('#formId i ...

What steps can I take to ensure that my bot disregards any actions taken by other bots?

I need assistance with configuring my bot to ignore certain actions by other bots and prevent logging them. Below is the snippet of my code: let messagechannel = oldMember.guild.channels.find(r => r.name === config.logsChannel); if (!messagecha ...

Using `preventDefault()` will also block any text input from being entered

Note: I am looking for a way to clear the text box using the enter key after typing some text. My apologies for any confusion caused. Update 2: The missing event parameter was causing all the issues. I feel like a failure as a programmer. I am trying to ...

Pressing the shortcut key will activate the function specified in ng-click,

I have been searching for a solution to my problem, but I haven't found anything that really helps. What I am looking for is a shortcut within an ng-click directive where there is only an if condition without an else expression. Essentially, I just wa ...

Is there a way to assign a value to an Angular-specific variable using PHP?

In the development of my Angular 4 application, I encountered an issue while receiving JSON data based on an id value through a PHP script. Upon examining the code, it seems that there should be a value passed into this.PropertiesList. examineProperties(i ...

How to completely disable a DIV using Javascript/JQuery

Displayed below is a DIV containing various controls: <div id="buttonrow" class="buttonrow"> <div class="Add" title="Add"> <div class="AddButton"> <input id="images" name="images" title="Add Photos" ...

What is the best way to transform React API data into props that can be utilized in different components?

I've been struggling with this issue for quite some time now, unable to understand how to manipulate the data in a way that allows me to use it in other components. Although I can display the data correctly, I'm advised to structure it within a f ...

Guide on dynamically changing the color of polymer 1.0 paper-button from an array of colors

I have an array called buttonColors that contains a set of colors in hex format. I am looking to create paper-buttons, each with the color from the buttonColors array. How can I achieve this in Polymer 1.0? <template is="dom-repeat" items="{{buttonCo ...

"Trouble encountered when submitting data to an external system by writing the image source - issues with Firefox and

I've been diving deep into various online resources to find a solution for an issue I'm encountering. My familiarity with Javascript is limited, so please bear with me. Whenever I click on the next button during checkout, a script runs to submit ...

What could be the reason my Angular interceptor isn't minified correctly?

I have come across this interceptor in my Angular project: angular.module('dwExceptionHandler', []) .factory('ExceptionInterceptor', ['$q', function ($q) { return function (promise) { return promise.th ...