Issue with replacing fragment shader in three.js not resolved in versions above 131

I have created an example showcasing the replacement of standard material (fragment and vertex shader) that was functioning properly in three.js versions prior to r131. However, in releases above 131, the changes made to the fragment shader are no longer working (the vertex shader still functions as expected).

Is anyone else experiencing this issue? Any advice would be greatly appreciated.

Answer №1

Consider integrating this adjustment (r144) as an alternative:

    shader.fragmentShader = shader.fragmentShader.replace(
      `#include <dithering_fragment>`,
      `#include <dithering_fragment>

        float t = time * 0.01 * 10.; // 10 variable speed
        float l = line(vPos, gridWidth, vec3(2.0));
        vec3 base = roadColor * wave(tuv.x, mix(0.5, roadCurve, getDelta(vPos.y*PI2 /50.0  * sin(t) )), roadWidth, roadSmoothing) /1. ; // road strip
    
        vec3 c = mix(gl_FragColor.rgb, base, l);
        // vec3 base2 = vec3(0.1,0.6,0.4) * wave(tuv.x, mix(0.5, 0.36, getDelta(vPos.y*PI2 /50.0  * cos(t) )), 0.06, 0.02) /1. ; // road strip
        // vec3 c2 = mix(c, base2, l);
        
     
        gl_FragColor = vec4(c, diffuseColor.a);
      `,
    )

This modification enhances the capabilities incorporated at the concluding segment of the fragment shader's main function.

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

JavaScript Question: How can I extract the click value from a JavaScript visualization when displayed in a table?

I am working with a Hierarchical Edge Bundling visualization in JS. My goal is to have the name of the value displayed on the table when I click on it. Currently, I am facing an issue with retrieving the value dynamically. If I manually input a value, I c ...

Tips for integrating external JavaScript libraries and stylesheets into a widget

I am currently working on developing a custom Javascript widget that requires users to insert specific lines of code into their web pages. This code will then dynamically add an externally hosted javascript file, allowing me to inject HTML content onto the ...

Is AngularJS Service a Singleton for Your Application?

As a relative newcomer to angularJS, I've learned that services should be singleton, but for some reason it's not working for me. Here is my service: .factory('TrainingPlan', function($http, SERVER){ var o = { exercises: [], ...

Vue.js computed property fails to initiate

Why is the Vue JS computed property not triggered with this markup? <!-- language: lang-html --> <p>£{{plant_price}}</p> <div v-if="selected.plant.variations.length > 0 "> <select v-model="selected.plant.selected_ ...

Tips for duplicating specific div elements

Is there a way to create copies of selected divs within the same panel using a Javascript report designer? I attempted to achieve this by using the following code snippet: function DesignerClone() { $(".ui-selected").each(function () { va ...

Updating token (JWT) using interceptor in Angular 6

At first, I had a function that checked for the existence of a token and if it wasn't present, redirected the user to the login page. Now, I need to incorporate the logic of token refreshing when it expires using a refresh token. However, I'm enc ...

Transitioning classes in Vue elements

Is it achievable to create a smooth transition between two CSS classes with different background images? That's the challenge I'm currently facing. Here is the Vue code snippet I am working on: <div id="flip-list-demo" class="demo"> & ...

Access-Control-Allow-Headers does not allow the use of X-Requested-With

I'm currently working on a system that includes an add item to cart feature. This functionality involves using Jquery's $.ajax method. However, I've encountered an error when attempting to access the online server - "XMLHttpRequest canno ...

Guide on extracting matching values from one object based on the properties of another object

Looking to iterate through the object below and extract author names based on matching titles with other objects. The goal is to create a new object for easier management. business1 { "type": "FeatureCollection", "features": [ { ...

How to modify a nested object in MongoDB based on the JSON data provided

In my possession, there exists a structured form of JSON data as displayed below: [ {"size":100,"year":2015,"geography":"London","age":"21","gender":"Female"}, {"size":80,"year":2015,"geography":"Cardiff","age":"38","gender":"Male"}, {"size":80,"year":201 ...

Having trouble with the Document.createElement function not functioning properly when trying to download a

ISSUE While my PDF download feature functions properly in Chrome, it encounters difficulty when attempting to work in IE 11/10/9. When using IE, I receive a security warning prompt. After selecting Yes to allow the download, nothing happens. SOURCE CODE ...

Executing NPM commands in a sequential manner

If I have the following npm scripts: "scripts": { "pre-build": "echo \"Welcome\" && exit 1", "build_logic": "start cmd.exe @cmd /k \"yo esri-appbuilder-js:widget && exit 1\"", "post_build": "start C:\ ...

What is the best way to handle mapping an array with uncertain levels of nesting?

My task involves rendering an array of comments in ReactJs, each of which can have nested comments at unknown levels. I am struggling to figure out how to display these comments with their respective nesting levels. comment 1 -- comment 2 -- comment 3 --- ...

Is there a way for me to display a gif similar to 9GAG on my

I'm looking to implement a feature on my website that allows me to pause and play a gif, similar to the functionality on 9gag. Can anyone provide guidance on how I can achieve this? I understand that I need to use both .jpg and .gif files, but my at ...

Tips for declaring the OpenLayers map object globally

I have successfully created a map with ol 6 and added an OSM layer. Now I am trying to incorporate a vector layer that is coded in another JavaScript file, using the same 'map' object. Despite my efforts to declare it globally, it doesn't se ...

Utilizing JavaScript and jQuery to make a query to mySQL

Looking to solve a SQL database query challenge using JavaScript or jQuery? Here's the scenario: I have a SQL db and typically use the following query to retrieve data based on distance from specified coordinates: SELECT id, ( 3959 * acos( cos( rad ...

Displaying properties of objects in javascript

Just starting with JavaScript and struggling to solve this problem. I attempted using map and filter but couldn't quite implement the if condition correctly. How can I find the records in the given array that have a gender of 0 and color is red? let s ...

React and SASS - issue with checkbox component not being properly aligned with its label

I'm brand new to React and I'm currently in the process of converting a pure HTML page into a React component. How can I adjust the SASS stylesheet to match the original HTML layout? Here is my current React setup (the checkbox displays on the r ...

Prevent the user from selecting an option if the value is already present

In the process of creating a library membership form, I am utilizing an ajax request to populate the student list in a select option. The goal now is to disable the options for students who are already members of the library. View of the Form <div cla ...

Incorporating a fixed header title when creating a customizable table

I am working on creating a dynamic table with rows and columns based on JSON data. JSON: $scope.dataToShow=[ tableHeder=["First Name","Age"], { name:"rahim", age:23 }, ...