What's New
Shader effects made easy. Effects that used to demand WebGL expertise, like a pond rippling with the scene reflected in it, heat haze, or frosted glass, now take a few lines of shader code: the engine hands your effect the screen behind it and the right coordinates, animated noise textures come built-in, and shaders preload like any other asset. See the new Water Overworld example for all of it in action, and the updated Shader Effects wiki guide.
New Features
- Shader builtins:
screen_texture/screen_uv/noise_uv— annotate a sampler with: screen_textureand the engine keeps it filled with the screen behind the object;screen_uv/noise_uvare free varyings for screen-space and frame-local (atlas-independent) coordinates. No JS plumbing, fully backward compatible (design and demo scene contributed by @Vareniel) renderer.toFrameTexture()— GPU capture of everything drawn so far, as a liveTexture2dfor shader input (initial approach contributed by @Vareniel)- Shader preloading — the
"shader"asset type compiles GLSL at load time;loader.getShader()returns the shared instance (clone()for per-renderable uniforms). A{vertex, fragment}pair compiles into a rawGLShaderforMesh/ custom-batcher shaders ShaderEffect.setTexture(name, image[, repeat])— bind extrasampler2Dtextures (noise, masks, LUTs) to an effect (thanks @Vareniel)ShaderEffect.setTime(seconds)and asharedflag onShaderEffect/GLShaderfor effects reused across renderables- Procedural noise:
Noise+NoiseTexture2d— deterministic CPU-samplable coherent noise (simplex / perlin / value / cellular, fractal layering, domain warp), bakeable as grayscale, a color ramp, or an animated normal map - Anchor-point presets +
Sprite3danchor support —anchorPoint: "bottom","top-left", … uniformly across every renderable;Sprite3dgains the same key, vertex-baked and runtime-mutable (thanks @asadullahbro) - Holes & compound paths in
Path2D/ SVG fills — inner sub-paths render as holes (donuts, letter counters) under both renderers - BMFont XML support for
BitmapText— the AngelCode XML flavour loads directly, auto-detected Texture2dbase class — renderables accept any texture asset directly asimage
Bug Fixes
- Asset loading over the
file:protocol works again (Cordova/Capacitor APK) —fetchDatafalls back to XHR wherefetch()refusesfile://(thanks @Vareniel) - Loader:
unloadAll()no longer throws on fontfaces or leaks videos;load()no longer mutates the caller's asset descriptor; video preloading no longer hangs on autoplay-restricted browsers or forces anonymous CORS; compressed-texture loading no longer crashes on devices missing a compression family - Audio batch: preload/retry/unload lifecycle fixes and honest getter/setter types across
seek,rate,position,stereo,resume,getCurrentTrack - Texture atlas batch: aseprite trim/rotation/pivot and per-frame durations are honored; coordinate-alias cache, video regions, padded spritesheets, and malformed-atlas validation all fixed
- WebGL batcher batch: texture-unit collisions (lit normal maps, re-uploads, post-effect unit 0), oversized primitive shapes, GPU texture/buffer leaks, and multi-renderer state crosstalk all fixed
- Rendering: nested multi-effect post-effects no longer crash; gradient fills respect inverted/nested masks;
disableScissor()flushes; WebGLclearRect()erases; CanvasclipRect()honors transforms; largepos.zsort keys no longer clip-cull sprites (19.7 regression) - Geometry/math:
Path2Darcs connect per spec;Rectedge/vertex fixes;moveTowards()lands exactly;Matrix2d6-argument form fixed; CSS color keyword table spec-validated NineSliceSpritekeeps its expanded size when animated (thanks @NemoStein);Textgeneric CSS font families render correctly
Compatibility
No breaking changes — everything additive / back-compatible.
Install
npm install melonjs@19.9.0Full details in the CHANGELOG.