Class: ShaderAnisotropicDiffusion

ShaderAnisotropicDiffusion

ShaderAnisotropicDiffusion extends the base Shader class to implement a Perona-Malik anisotropic diffusion filter to enhance inscriptions on metal surfaces based on normal maps.

This filter preserves and enhances edges while smoothing other areas, making it ideal for revealing inscriptions on uneven surfaces.


new ShaderAnisotropicDiffusion( [options])

Creates a new Anisotropic Diffusion Shader instance.

Parameters:
Name Type Argument Description
options Object <optional>

Configuration options passed to parent Shader

Properties
Name Type Argument Default Description
kappa number <optional>
15.0

Diffusion conductance parameter

iterations number <optional>
3

Number of diffusion iterations

lambda number <optional>
0.25

Diffusion rate (0.0-0.25 for stability)

normalStrength number <optional>
1.0

Normal contribution strength

Source:

Methods


fragShaderSrc(gl)

Override fragment shader source to implement anisotropic diffusion. This version is compatible with both WebGL 1.0 and 2.0+.

Parameters:
Name Type Description
gl WebGLRenderingContext

WebGL context

Source:
Returns:

Fragment shader source code

Type
string

setIterations(value)

Sets the number of diffusion iterations. More iterations produce smoother results but take longer to compute.

Parameters:
Name Type Description
value number

Number of iterations (typically 1-10)

Source:

setKappa(value)

Sets the kappa parameter which controls edge sensitivity. Higher values preserve fewer edges.

Parameters:
Name Type Description
value number

Kappa value (typically 5-50)

Source:

setLambda(value)

Sets the lambda parameter which controls diffusion rate. Should be between 0.0 and 0.25 for numerical stability.

Parameters:
Name Type Description
value number

Lambda value (0.0-0.25)

Source:

setNormalStrength(value)

Sets the normal strength parameter which controls how much the normal map information influences the final result.

Parameters:
Name Type Description
value number

Normal strength multiplier

Source: