A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
#pragma shader "Dissolve"
#pragma version 300 es
#pragma domain Unlit
#pragma param u_progress float default(0) range(0,1) ui(slider)
#pragma param u_edgeColor color default(1,0.5,0,1)
#pragma param u_edgeWidth float default(0.08) range(0,0.5)
#pragma param u_noiseScale float default(12) range(1,64)
#pragma fragment
precision mediump float;
in vec4 v_color;
in vec2 v_texCoord;
uniform sampler2D u_textures[8];
out vec4 fragColor;
float hash2d(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123); }
float noise2d(vec2 p) {
vec2 i = floor(p);
vec2 f = fract(p);
f = f * f * (3.0 - 2.0 * f);
return mix(mix(hash2d(i), hash2d(i + vec2(1.0, 0.0)), f.x),
mix(hash2d(i + vec2(0.0, 1.0)), hash2d(i + vec2(1.0, 1.0)), f.x), f.y);
}
// u_progress 0 = intact, 1 = fully dissolved; a glowing edge leads the cut.
void main() {
vec4 base = texture(u_textures[0], v_texCoord) * v_color;
float n = noise2d(v_texCoord * u_noiseScale);
float cut = u_progress * (1.0 + u_edgeWidth);
if (n < cut - u_edgeWidth) discard;
vec3 rgb = (n < cut) ? u_edgeColor.rgb : base.rgb;
fragColor = vec4(rgb, base.a);
}
#pragma end