structureTensor

@three-blocks/coreWebGPUWebGL
structureTensor(textureNode : Node) : Node<vec4>

Compute structure tensor for edge-aware image filtering.

Algorithm

  • Computes image gradients using Sobel operator (3×3 kernel)
  • Calculates outer product of gradient: J = [∇I ⊗ ∇I]
  • Outputs (Jxx, Jyy, Jxy) in RGB channels for downstream use

Use Cases

  • Input for Kuwahara filter (kuwahara)
  • Edge detection and orientation analysis
  • Anisotropic filtering and diffusion

Pipeline Structure tensor is typically used as a first pass before applying edge-aware filters like Kuwahara.

Parameters
textureNodeNode
Source texture for gradient analysis.
Returns
Node<vec4> — Structure tensor (Jxx, Jyy, Jxy, 1.0) in RGBA.
See also
Example
import { structureTensor, kuwahara } from '@three-blocks/core';
import { pass } from 'three/tsl';

// First pass: compute structure tensor
const scenePass = pass(scene, camera);
const tensorPass = structureTensor(scenePass);

// Second pass: use tensor for edge-aware filtering
const filtered = kuwahara(scenePass, tensorPass, { radius: 5 });

postProcessing.outputNode = filtered;