Scene color
import { sampleSceneColor, screenUV, RgbaNode } from "@hology/core/shader-nodes";
const color: RgbaNode = sampleSceneColor(screenUV)Example - Shockwave sprite

Last updated
import { sampleSceneColor, screenUV, RgbaNode } from "@hology/core/shader-nodes";
const color: RgbaNode = sampleSceneColor(screenUV)
Last updated
import { SpriteNodeShader } from '@hology/core';
import { distance, normalize, oneMinus, particleUniforms, sampleSceneColor, screenUV, sin, smoothstep, timeUniforms, varyingAttributes, vec2 } from "@hology/core/shader-nodes";
import { NodeShaderOutput, Parameter } from "@hology/core/shader/shader";
export default class ShockwaveShader extends SpriteNodeShader {
@Parameter()
distortionStrength: number = 0.05
@Parameter()
waveScale: number = 20
@Parameter()
waveSpeed: number = 0.2
@Parameter()
fadeDistance: number = 0.1
output(): NodeShaderOutput {
const center = vec2(0.5)
const dir = normalize(varyingAttributes.uv.subtract(center))
const dist = distance(varyingAttributes.uv, center)
const alpha = smoothstep(0.5, 0.5 + this.fadeDistance, oneMinus(dist))
const wave = sin(
dist.subtract(timeUniforms.elapsed.multiply(this.waveSpeed)).multiply(this.waveScale)
).multiply(this.distortionStrength).multiply(alpha)
const offset = dir.multiplyScalar(wave)
const sample = sampleSceneColor(screenUV.add(offset)).rgb
return {
color: sample.rgba(alpha.multiply(particleUniforms.opacity)),
transparent: false
}
}
}