npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

three.shader-texture

v1.0.0

Published

A three.js texture drawn by a shader into a render target

Readme

THREE.ShaderTexture

ShaderTexture, a helper to use procedurally generated texture

Demos

2026 update

Disclaimer: this library is from 2016. three.js still has no texture driven by a GLSL shader for WebGLRenderer, so the library is still useful there. With WebGPURenderer and TSL there's one since r167 (2024), rtt(), which takes a node instead of a shader and updates itself

import { rtt, uv, vec4 } from 'three/tsl';

const material = new THREE.MeshStandardNodeMaterial();
material.colorNode = rtt( vec4( uv(), 0, 1 ), 512, 512 );

For WebGLRenderer the closest thing is FullScreenQuad, in the addons since r105 (2019). It draws a material over a render target, but the render target and when to draw are up to you

import { FullScreenQuad } from 'three/addons/postprocessing/Pass.js';

const target = new THREE.WebGLRenderTarget( 512, 512 );
const quad = new FullScreenQuad( material );

renderer.setRenderTarget( target );
quad.render( renderer );
renderer.setRenderTarget( null );

The library has been rewritten for current three.js. What changed from the 2016 version:

  • it's an ES module, and it needs three.js r152 or later
  • render() puts back the render target that was active, the old code stopped working when three.js removed the render target argument of renderer.render()
  • the texture has mipmaps again, three.js stopped generating them for render targets by default
  • a fifth argument takes render target options, and there are setSize() and dispose()
  • the examples load three.js from a CDN, turn color management off to keep the look they had in 2016, and show every texture next to the knot. The textures tile now, and the band of broken normals along the knot is gone

How to use

Use npm to install it, alongside three.js

npm i three three.shader-texture

and import it in your code

import * as THREE from 'three';
import { ShaderTexture } from 'three.shader-texture';

It's a plain ES module, so it also works without a bundler as long as an import map resolves three (see examples/index.html).

Create a material with the shader that draws the texture, and a ShaderTexture with it:

const shader = new THREE.ShaderMaterial( {
  vertexShader: 'varying vec2 vUv; void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1. ); }',
  fragmentShader: 'varying vec2 vUv; void main() { gl_FragColor = vec4( vUv, 0., 1. ); }'
} );

const shaderTexture = new ShaderTexture( renderer, shader, 1024, 1024 );

Draw it, and use the texture like any other:

shaderTexture.render();

const material = new THREE.MeshStandardMaterial( { map: shaderTexture.texture } );

Call render() again whenever the uniforms of the shader change. A texture can be the input of another shader, see the normal map in the examples.

The fifth argument is passed to THREE.WebGLRenderTarget, for instance to get a float texture:

const heightMap = new ShaderTexture( renderer, shader, 1024, 1024, { type: THREE.HalfFloatType } );

To change the size or release the texture:

shaderTexture.setSize( 512, 512 );
shaderTexture.dispose();

License

MIT licensed

Copyright (C) 2016 Jaume Sanchez Elias, http://www.clicktorelease.com