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

353
Views
ThreeJS voxel test, weird gaps between textures

Edit: I've narrowed down the problem. My texture atlas is 256px by 256px with 16x16 textures. For some reason setting my UV coordinates to 1/16th is adding a 1 pixel border on all edges. I'm unsure why, but think I can figure it out.

As a way to learn ThreeJS and graphics rendering I am working on a voxel engine to somewhat simulate Minecraft. I've recently implementing mesh culling and a lot of other optimizations for rendering large scenes of voxels efficiently. Now I am in the process of adding textures to the meshes. I recently implemented a very standard basic vertex and fragment shader you can find here:

const vertexShader = `
    varying vec2 vUv;

    void main(){
        vUv = uv;
        gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
    }
`;

const fragmentShader  = `
    uniform sampler2D texture1;
    varying vec2 vUv;

    void main() {
        gl_FragColor = texture2D(texture1, vUv);
    }
`;

The problem can be seen here: World View

Close View

In my world generation function (some simple perlin noise) I assign each block an ID which then corresponds to a specific UV value in my texture atlas when that block/face is being rendered. As for meshes, I create the voxels using 6 "master" PlaneBufferGeometries (one for each direction). When it comes to rendering a block, whatever face is visible is cloned, translated, given uv attributes, and then pushed to an array that is eventually merged together to form the mesh for each chunk.

Before I implemented my vertex and fragment shader, each "master" plane was given it's own texture, just so I didn't have to use wireframe. During this time, the textures all fit together perfectly, and this gapping was not there. Does anyone have any insight that would potentially help me? The gap only exists at off angles. If I straighten my view, the gap dissapears. For some reason up close, one of the axis's doesn't have the gap, but at a distance it does. Antialiasing is on, texture wrapping is off. When I toggle either of those parameters, the problem becomes worse.

Any help is appreciated.

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!