Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
Problems with ShaderMaterial

To start off, I am new to the ShaderMaterial and GLSL. I did read up on the GLSL Manual and looked at some examples found in my Google searches, and I'm trying my hand at this to create some texture effects in my projects. Right now I am just trying to put a texture on a surface as if I was just using MeshBasicMaterial. The code pieces look like this:

<script type="x-shader/x-vertex" id="vertexskyshader">
    varying vec2 vUv;
    void main()
    {
        vUv = uv;
        gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
    }
</script>

<script type="x-shader/x-fragment" id="fragskyshader">
    varying vec2 vUv;
    uniform sampler2D material;
    void main()
    {
        gl_FragColor = texture2D(material, vUv);
    }
</script>

<script type="module">
    import * as THREE.........

    for(f = 0; f < lvlfaces.length; f++)
    {
        var facemat = new THREE.ShaderMaterial({ vertexColors: THREE.VertexColors, transparent: lvlfaces[f].adjmode, depthWrite: !lvlfaces[f].adjmode, depthTest: !lvlfaces[f].adjmode,
            uniforms: { texture: { value: matTable[lvlfaces[f].mat] } },
            vertexShader: document.getElementById("vertexskyshader").textContent,
            fragmentShader: document.getElementById("fragskyshader").textContent });

The lvlfaces are being loaded from a file and are an array of objects containing information about the surface (like texture file name .mat, vertices used, uv coords, etc). matTable array where the elements are named after the texture file names contain the actual texture data (loaded from THREE.TextureLoader()). The problem I am having is that when I move around the object the textures shown change to a different texture in the matTable. Not only that but another object that uses this same loop but is assigned different textures shows the exact same textures and changes as the object I'm moving around.

animation too large for import

I have a feeling there is a conflict somewhere here but I have no idea what the fix would be.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!