How to get smooth shading on TextGeometry, please 🙏

Ahh, ok, read that but somehow missed it - my bad. Hmm… maybe some blurring can do the job then? Apart from iterating through and adjusting the position attribute followed by recomputing normals for the whole geometry, that is… :thinking:

P.S. Altering the position attribute for a sphere is done like this (don’t know for the text though, it probably depends on its specific segments):

  var posidx, posval = new THREE.Vector3(), dirval = new THREE.Vector3(), disval;
  for (var j = 0; j < geometry.parameters.heightSegments + 1; j++)
  {
    for (var i = 0; i < geometry.parameters.widthSegments + 1; i++)
    {
      // ideally you'd only alter the positions in curved segments here
      posidx = (geometry.parameters.widthSegments + 1) * j + i;
      posval.fromBufferAttribute(geometry.attributes.position, posidx);
      dirval.fromBufferAttribute(geometry.attributes.normal, posidx);
      // the distance by which you alter vertices will depend here
      disval = 0;
      posval.addScaledVector(dirval, disval);
      geometry.attributes.position.setXYZ(posidx, posval.x, posval.y, posval.z);
    };
  };
  geometry.computeVertexNormals();
  geometry.attributes.position.needsUpdate = true;

If you can figure out a way to adjust vertices only for positions belonging to curved segments and in a way that follows some trigonometric function, something similar to this will probably do it. I’m not sure if simply adjusting vertices with a hardcoded value to trigger smoothing via recomputing normals will work, but you can try.

1 Like