angular-three-soba/shaders

December 31, 2025 ยท View on GitHub

This secondary entry point provides specialized shader materials for advanced visual effects.

Dependencies

npm install three-mesh-bvh
# yarn add three-mesh-bvh
# pnpm add three-mesh-bvh

TOC

MeshRefractionMaterial

A shader material that simulates realistic light refraction through transparent objects like glass or diamonds. Uses BVH for accurate ray tracing and supports chromatic aberration.

Usage

import { extend } from 'angular-three';
import { MeshRefractionMaterial } from 'angular-three-soba/shaders';

extend({ MeshRefractionMaterial });

Options (MeshRefractionMaterialOptions)

PropertyDescriptionDefault Value
envMapEnvironment map for reflections/refractionsnull
bouncesNumber of internal light bounces3
iorIndex of refraction (air=1.0, water=1.33, glass=1.5, diamond=2.4)2.4
correctMipsWhether to correct mip levels for smoother samplingtrue
aberrationStrengthChromatic aberration intensity (0 to disable)0.01
fresnelFresnel reflection intensity at grazing angles0
colorBase color tint'white'
opacityMaterial opacity1
<ngt-mesh>
	<ngt-icosahedron-geometry />
	<ngt-mesh-refraction-material [envMap]="envMap" [ior]="2.4" [bounces]="3" [aberrationStrength]="0.01" />
</ngt-mesh>

GridMaterial

A shader material that renders an infinite grid with customizable cells and sections. Supports fading, camera following, and dual-layer grid lines.

Usage

import { extend } from 'angular-three';
import { GridMaterial } from 'angular-three-soba/shaders';

extend({ GridMaterial });

Options (GridMaterialOptions)

PropertyDescriptionDefault Value
cellSizeSize of individual grid cells0.5
cellThicknessThickness of cell grid lines0.5
cellColorColor of the cell grid lines'black'
sectionSizeSize of section divisions (larger squares)1
sectionThicknessThickness of section grid lines1
sectionColorColor of the section grid lines'#2080ff'
followCameraWhether the grid follows camera positionfalse
infiniteGridDisplay grid infinitely to the horizonfalse
fadeDistanceDistance at which the grid starts to fade100
fadeStrengthStrength of the fade effect1
fadeFromFade origin (1=camera, 0=origin)1
sideWhich side of the material to renderTHREE.BackSide
<ngt-mesh [rotation]="[-Math.PI / 2, 0, 0]">
	<ngt-plane-geometry *args="[100, 100]" />
	<ngt-grid-material [cellSize]="0.5" [sectionSize]="1" [fadeDistance]="100" [infiniteGrid]="true" transparent />
</ngt-mesh>

PointMaterial

An enhanced PointsMaterial that renders points as smooth, anti-aliased circles instead of the default square points.

Usage

import { extend } from 'angular-three';
import { PointMaterial } from 'angular-three-soba/shaders';

extend({ PointMaterial });

This material accepts all standard THREE.PointsMaterialParameters options.

<ngt-points>
	<ngt-buffer-geometry />
	<ngt-point-material [size]="0.1" [color]="'red'" />
</ngt-points>