Lighting

Lighting is an important and non trivial part of creating shaders.

Built in

The library comes with some built in implementations of materials.

Lambert

The Lambert material implementation is highly efficient as it only calculated the light at each vertex. It can take a diffuse color and returns an RgbaNode.

import { lambertMaterial, RgbaNode, rgb } from "@hology/core/shader-nodes"

const color: RgbaNode = lambertMaterial(rgb(0x00ff00))

Standard

The standard material is based on a physically based rendering approach and looks just like THREE.MeshStandardMaterial except it that it does not have features like metalness or refraction.

import { standardMaterial, RgbaNode, rgb } from "@hology/core/shader-nodes"

const color: RgbaNode = standardMaterial({ 
    color: rgb(0x00ff00), 
    emissive: rgb(0x9f7070), 
    emissiveIntensity: float(0),
    roughness: float(1)
})

Creating your own

Light and shadow information is passed in by ThreeJS based on what exists in the scene and you can access them with uniforms. Check out the / for what predefined uniforms exist and for how to create new ones if some you need are missing.

Last updated