Three.js: Objects in the distance appear more subtle

Currently, I am developing a three.js scenario that showcases textured point sprites. These sprites obtain their textures from a single uniform, which is a 2D canvas containing the alphabet:

https://i.stack.imgur.com/Ceh9x.png

In my scene, all the letters on the canvas are in black color. However, distant points in the three.js scene appear faintly. Here's a snippet of the code I'm working with:

// aliases
var BA = THREE.BufferAttribute,
    IBA = THREE.InstancedBufferAttribute,
    ARR = Float32Array;


function Wordmap() {
  // configuration settings
  this.wordScalar = 0.0003;
  this.heightScalar = 0.002;
  this.sep = 0.9;
  this.maxWords = 1000000;
  this.background = '#fff';
  this.color = '#000';
  this.size = 64;

  // state variables
  this.state = {
    layout: 'grid',
    flying: false,
    clock: null,
    transitioning: false,
    transitionQueued: false,
  }

  // data storage
  this.data = {
    input: null,
    words: [],
    layouts: {},
    heightmap: {},
    characters: {},
  }
  
  // initialize function
  this.init();
}

// More functions and methods follow for creating scenes, handling characters, generating heightmaps, setting geometry, etc.

I have tried adjusting the alpha value in the fragment shader to increase the opacity, but it resulted in chunky and pixelated font display. Is there a way to enhance the opacity of distant points without affecting the font weight in the visualization? Your insights would be greatly appreciated!

Answer №1

One possible reason for this issue is the mipmapping applied to the sprite texture, causing the black pixels in your text to blend into grey when downscaled.

To avoid using mipmapped textures, you can change the .minFilter property of your texture after declaration, as shown in the code snippet below:

tex.minFilter = THREE.LinearFilter;

The only two options available for minification filters without mipmapping are LinearFilter and NearestFilter. Disabling mipmapping may result in an aliased appearance for your textures.

Alternatively, you can create custom mipmaps in Photoshop that do not fade to grey and define them using texture.mipmaps.

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

A blank page is appearing mysteriously, free of any errors

I have experience with ReactJs, but I am new to Redux. Currently, I am working on implementing an async action where I call an API and display the data received from it. Initially, when all the Redux components (actions, reducers, containers) were on a sin ...

Protractor experiencing difficulty in adjusting price slider

As a newcomer to protractor, I am attempting to test a price slider that sorts products based on the provided price range. Unfortunately, I am facing difficulty in dragging the slider (min point) using protractor. Can anyone provide guidance on how to move ...

After the initial iteration, the .length function ceases to function properly when

A validation method is set up to check the length of a user input field. It functions properly on the initial try, but does not update if I go back and modify the field. $("#user").blur(function () { if ($("#user").val().length < 3) { $("#userval ...

In a designated paragraph, set the display of all <span> elements to none using JavaScript

I have a long paragraph with over 10,000 lines of text and I need a way to quickly remove all the lines without hiding the entire paragraph. Specifically, I want to hide each line individually by changing the span style from "display:block" to "display:non ...

Sending arrays' values in JavaScript

Here is a list of different groups to choose from: <select multiple="multiple" name="groups[]" id="groups[]" class="myclass"> <option value="1">Employees</option> <option value="2">Vendors</option> <option valu ...

Deleting information from several stores in React Reflux using a single action function

In the AuthActions file, there is a straightforward function called _clear that assigns this.data to undefined. This function is only invoked when a user logs out. However, upon logging back in with a different user, remnants of data from the previous ac ...

Guide on integrating react-tether with react-dom createPortal for custom styling of tethered components based on their target components

Within a Component, I am rendering buttons each with its own tooltip. The challenge is to make the tooltip appear upon hovering over the button since the tooltip may contain more than just text and cannot be solely created with CSS. The solution involves ...

The 'this' variable is malfunctioning when trying to assign a JSONP array to an AngularJS controller

I'm working with a REST service in my angular controller and using JSONP to make the call. I need to store the array that is returned from the service into a variable. This is what I currently have: this.testTheRest = function() { $http.jsonp(&a ...

Construct a div element using JSON information

I am retrieving information from a database and organizing it into a JSON array. Here is the data that I have: [{"id":"0","name":"red","percentage":"60"},{"id":"1","name":"blue","percentage":"58"},{"id":"4","name":"green","percentage":"12"}] The structu ...

Having trouble getting sweet alert to work with my PHP script

I’m integrating Sweet Alerts 2 into my webpage in order to prompt the user when trying to delete something. However, I'm encountering an issue where the PHP file is not being triggered when the user presses delete and the Sweet Alert does not appear ...

A method in JQuery to replace an input with a select element is by using the replace

I have multiple input fields with pre-existing values. My goal is to replace these inputs with select dropdowns that have the same options while retaining the original values. Here is the current HTML structure: <span id="span1"> <input type=" ...

Perform multiple function invocations on a single variable using JavaScript

Is there a way to execute multiple functions on a single object in JavaScript? Maybe something like this: element .setHtml('test'), .setColor('green'); Instead of: element.setHtml('test'); element.setColor('gre ...

What is the best way to append a JavaScript object to a JSON file on a new line

What changes should be made to this function in order to append each object in the file on a new line? exports.addWaypoint = function(id, type, param){ var dataIn = fs.readFileSync('./markers.json'); var obj = JSON.parse(dataI ...

What is the best way to apply changes to every class in JavaScript?

Check out this HTML and CSS code sample! body{ font-family: Verdana, Geneva, sans-serif; } .box{ width: 140px; height: 140px; background-color: red; display: none; position:relative; margin-left: auto; margin-right: auto; } .bold{ font ...

The Vue mixin properties are devoid of content and lack reactivity

Could you please guide me in the right direction if this question has already been asked before? I really hope it's not a duplicate. I have a Vue application that is compiled using Webpack@NPM. In order to pass a property (roles) across all component ...

Why is the 'name' property used in the export default{} syntax?

Vuejs is my current learning focus, and one thing that puzzles me is the necessity of this particular name. <template> </template> <script> export default { name: 'NotFound' } </script> <style> </style&g ...

Using JavaScript, implement the array.filter method on a JSON array to retrieve the entire array if a specific property matches a given

Help needed with filtering an array: In the user_array, there are arrays that need to be compared to see if the header_info.sap_number matches any value in the valid_sap_number array. If a property value matches anything in the valid_sap_number array, th ...

Results don't align with search parameters

const searchClientes = (event) => { if (event.target.value === '') { getClientes(); return; } else { const searchTerm = event.target.value; const filteredClients = clientes.filter(cliente => { return cliente.nome ...

Managing "unprocessed information" in a Node.js environment and transferring the information through a Node Express endpoint

Currently, I am in the process of making an API call to retrieve a file using axios: async function fetchData() { const configuration = {}; // { responseType: 'stream'}; const { response } = await axios.get(URL, configuration); c ...

Ensure that TypeScript compiled files are set to read-only mode

There is a suggestion on GitHub to implement a feature in tsc that would mark compiled files as readonly. However, it has been deemed not feasible and will not be pursued. As someone who tends to accidentally modify compiled files instead of the source fil ...