Skip to main content

πŸ—“οΈ 10052025 2145
πŸ“Ž

textures_3js

SUMMARY

Images that will cover the surface of your geometries

types​

typedescription
color (albedo)takes pixel of texture and apply them to the geometry
alphagrayscale image where white is visible and black is not
heightgrayscale image that will move vertices to create some relief (requires subdivision to be seen)
normalfor luring light into thinking face is oriented differently (performant way of adding details)
ambient occlusiongrayscale shadow for faking shadow
metalnessgrayscale image for specifying metalness (white is metallic, non-metallic is black)
roughnessgrayscale image that comes with metalness (white - rough, smooth -black)

metalness and roughness follows physically_based_rendering principles

WARNING

Take into account the color space of your texture

components​

componentdescription
TextureLoaderLoads textures
LoadingManagerFor managing texture load events
NOTE

The LoadingManager is useful for managing the progress of loading Texture assets

Can uess it to manager a loading bar

Texture format and optimisation​

TLDR

Elements to keep in mind when preparing textures

The weight​

Important because textures have to be downloaded

  • .jpgΒ ()
    • lossy compression
    • usually lighter
  • .pngΒ ()
    • lossless compression
    • usually heavier
  • Try to apply the usual methods to get an acceptable image but as light as possible
  • Use compression websites likeΒ TinyPNGΒ (also works with jpg) or any software.

The size​

  • Each pixel of the textures you are using will have to be stored on the GPU regardless of the image's weight
  • GPU has storage limitations
  • Automatically generated mipmapping increases the number of pixels that have to be stored
IMPORTANT
  • Texture width and height must be a power of 2

  • That is mandatory so that Three.js can divide the size of the texture by 2

The data​

  • jpg files don't have an alpha channel
  • can use alpha map

If you are using a normal texture (the purple one), you will probably want to have the exact values for each pixel's red, green, and blue channels, or you might end up with visual glitches. For that, you'll need to use a png because its lossless compression will preserve the values.

Where to find textures​

IMPORTANT

Always make sure that you have the right to use the texture if it's not for personal usage.


References