matrix-engine-wgpu
Version:
Networking implemented - based on kurento openvidu server. fix arcball camera,instanced draws added also effect pipeline blend with instancing option.Normalmap added, Fixed shadows casting vs camera/video texture, webGPU powered pwa application. Crazy fas
50 lines (40 loc) • 1.27 kB
JavaScript
export const pointerEffect = `
struct Camera {
viewProjMatrix : mat4x4<f32>,
};
var<uniform> camera : Camera;
struct Model {
modelMatrix : mat4x4<f32>,
};
var<uniform> model : Model;
struct VertexInput {
position : vec3<f32>,
uv : vec2<f32>,
};
struct VSOut {
Position : vec4<f32>,
v_uv : vec2<f32>,
};
fn vsMain(input : VertexInput) -> VSOut {
var out : VSOut;
let worldPos = model.modelMatrix * vec4<f32>(input.position,1.0);
out.Position = camera.viewProjMatrix * worldPos;
out.v_uv = input.uv;
return out;
}
fn fsMain(input : VSOut) -> vec4<f32> {
// Center the UVs (0.0–1.0 → -1.0–1.0)
let uv = input.v_uv * 2.0 - vec2<f32>(1.0, 1.0);
// Distance from center
let dist = length(uv);
// Glow falloff
let glow = exp(-dist * 1.0); // try values 3.0–6.0 for tighter glow
// Gradient color (inner bright → outer dim)
let baseColor = vec3<f32>(0.2, 0.7, 1.0);
let glowColor = vec3<f32>(0.7, 0.9, 1.0);
// Blend based on glow strength
let color = mix(baseColor, glowColor, glow) * glow;
return vec4<f32>(color, 1.0);
}`;