1

I prepared an example of replacing standard material (fragment and vertex shader) code sandbox r131.3 which was working well in three.js versions below r131. In releases above 131 changes applied to fragment shader stopped working (vertex works still as before).

Does anyone facing the same issue (any advice is warm welcome)?

1
  • 1
    Shader got changes since r131 and there is no that line gl_FragColor = vec4( outgoingLight, diffuseColor.a ); anymore. Thus, there is no replacing with your modificaitions. Commented Sep 11, 2022 at 21:00

1 Answer 1

2

As an option, use this modification (r144):

    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);
      `,
    )

It adds the functionality you provide at the very end of the fragment shader's main function.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.