Rendering sharp text as a three.js texture
Asked Answered
L

1

7

I have a 512x512 SVG i'm drawing to a circular plane like this

    const texture = new THREE.TextureLoader().load('img/plane.svg');
​
    const material = new THREE.MeshBasicMaterial({
        transparent: true,
        map: texture,
        side: THREE.DoubleSide
    });
    const geometry = new THREE.CircleGeometry(5, 64);
    const plane = new THREE.Mesh(geometry, material);
    plane.rotation.x = -1;
    scene.add(plane);

It's working fine, but this SVG has some text on it and it's really blurry when rendered in three.js:

screenshot of blurry text in webgl

How do I make this as sharp as possible?

For reference, here's the SVG rendered as a 512x512 png:

sharp compass

Lapel answered 18/7, 2018 at 20:18 Comment(0)
L
16

… And just as I decide to post here I solved my issue, by adding material.map.minFilter = THREE.LinearFilter;

Lapel answered 18/7, 2018 at 20:39 Comment(2)
Thank you! Detailed explanation here threejsfundamentals.org/threejs/lessons/threejs-textures.html part "Filtering and Mips"Sheepshank
Also, make sure you set the pixel ratio from the window object, like: renderer.setPixelRatio(window.devicePixelRatio); (don't put a number) If you have a retina screen for exemple, it'll be way betterBank

© 2022 - 2024 — McMap. All rights reserved.