melonjs 20.5.0 → 20.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/application/defaultApplicationSettings.d.ts +1 -0
- package/build/application/defaultApplicationSettings.d.ts.map +1 -1
- package/build/application/settings.d.ts +37 -0
- package/build/application/settings.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/geometries/polygon.d.ts.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +22428 -21236
- package/build/index.js.map +4 -4
- package/build/lang/deprecated.d.ts.map +1 -1
- package/build/level/gltf/GLTFScene.d.ts.map +1 -1
- package/build/level/level.d.ts +1 -0
- package/build/level/level.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/lighting/light2d.d.ts +68 -2
- package/build/lighting/light2d.d.ts.map +1 -1
- package/build/lighting/light3d.d.ts.map +1 -1
- package/build/loader/loader.d.ts +54 -0
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/loadingscreen.d.ts.map +1 -1
- package/build/loader/parsers/fontface.d.ts +2 -0
- package/build/loader/parsers/fontface.d.ts.map +1 -1
- package/build/loader/parsers/mtl.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +143 -2
- package/build/physics/adapter.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +6 -16
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
- package/build/physics/builtin/detector.d.ts.map +1 -1
- package/build/physics/builtin/sat.d.ts.map +1 -1
- package/build/physics/builtin/sat3d.d.ts.map +1 -1
- package/build/physics/physicseditor.d.ts +2 -0
- package/build/physics/physicseditor.d.ts.map +1 -0
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/entity/entity.d.ts +2 -0
- package/build/renderable/entity/entity.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +23 -1
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts +39 -1
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +72 -0
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/trigger.d.ts +12 -9
- package/build/renderable/trigger.d.ts.map +1 -1
- package/build/state/stage.d.ts +22 -0
- package/build/state/stage.d.ts.map +1 -1
- package/build/video/buffer/vertex.d.ts.map +1 -1
- package/build/video/gpu/meshmaterial.d.ts +2 -0
- package/build/video/gpu/meshmaterial.d.ts.map +1 -0
- package/build/video/renderer.d.ts +44 -0
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/webgl/batchers/batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts +2 -1
- package/build/video/webgl/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgl/batchers/mesh_batcher.d.ts +2 -0
- package/build/video/webgl/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/shaders/multitexture-lit.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts +17 -0
- package/build/video/webgpu/batchers/lit_quad_batcher.d.ts.map +1 -1
- package/build/video/webgpu/batchers/mesh_batcher.d.ts.map +1 -1
- package/build/video/webgpu/effect_binding.d.ts.map +1 -1
- package/build/video/webgpu/pipeline/cache.d.ts.map +1 -1
- package/build/video/webgpu/texture/store.d.ts.map +1 -1
- package/build/video/webgpu/webgpu_renderer.d.ts +1 -0
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/melonjs-3d/SKILL.md +16 -0
- package/skills/melonjs-3d-assets/SKILL.md +51 -8
- package/skills/melonjs-effects-and-shaders/SKILL.md +37 -0
- package/skills/melonjs-lighting/SKILL.md +45 -1
- package/skills/melonjs-loading-assets/SKILL.md +43 -9
- package/skills/melonjs-performance/SKILL.md +34 -6
- package/skills/melonjs-physics/SKILL.md +320 -3
- package/skills/melonjs-renderables/SKILL.md +13 -0
- package/skills/melonjs-scenes-and-state/SKILL.md +37 -0
- package/skills/melonjs-tilemaps/SKILL.md +9 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect_binding.d.ts","sourceRoot":"","sources":["../../../src/video/webgpu/effect_binding.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"effect_binding.d.ts","sourceRoot":"","sources":["../../../src/video/webgpu/effect_binding.js"],"names":[],"mappings":"AAiCA;;;;;;;;GAQG;AACH;;;;;;;;;;;;;;GAcG;AACH,yCANW,MAAM,UACN,MAAM,eACN,MAAM,QAuKhB;AAqCD;;;;;;;;;;GAUG;AACH,+CAPW,OAAO,sBAAsB,EAAE,OAAO,UACtC,OAAO,4BAA4B,EAAE,OAAO,GAC1C;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,YAAY,GAAC,IAAI,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAA;CAAC,GAAC,IAAI,CAgJ/G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/pipeline/cache.js"],"names":[],"mappings":"AA8BA;;;;;;;;GAQG;AACH,gCAAiC,CAAC,CAAC;AAEnC;;;;;;;;GAQG;AACH,mCAAoC,sBAAsB,CAAC;AA8E3D;;;;;;;;;;;;;GAaG;AACH;
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/pipeline/cache.js"],"names":[],"mappings":"AA8BA;;;;;;;;GAQG;AACH,gCAAiC,CAAC,CAAC;AAEnC;;;;;;;;GAQG;AACH,mCAAoC,sBAAsB,CAAC;AA8E3D;;;;;;;;;;;;;GAaG;AACH;IA8KC;;;;OAIG;IACH,4BAAwB;IAlLxB;;;OAGG;IACH,oBAHW,SAAS,UACT,M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;QAAC,UAAU,CAAC,EAAE,OAAO,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAC,GAMxE,iBAAiB,CA2D7B;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,iBAXW,MAAM,aACN,MAAM,SACN,MAAM,OACN,OAAO,WACP,MAAM,aACN,MAAM,QACN,MAAM,GACJ,2BAA2B,CA2CvC;IAED;;;OAGG;IACH,cAEC;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/texture/store.js"],"names":[],"mappings":"AAwBA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;OAEG;IACH,sBAFW,OAAO,uBAAuB,EAAE,OAAO,EAoBjD;IAhBA,kDAAwB;IACxB,8BAA6B;IAC7B,sCAAsC;IACtC,UADW,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CACT;IAKzB,yBAMC;IAIF;;;;;;;OAOG;IACH,mBANW,MAAM,UACN,MAAM,sBACJ,UAAU,CAmCtB;IAED;;;;;;;;;;OAUG;IACH,oBANW,MAAM,YAEd;QAA0B,KAAK;QACN,MAAM;KAC/B,GAAU,YAAY,CAuMxB;IAjHE;;;;kBAAwB;IAmH3B;;;;;;;;;OASG;IACH,wBAJW,MAAM,QA0EhB;IA/DC,0CAME;IAIF,2CAYE;IACF,mCAIE;IAsCJ;;;;;;;OAOG;IACH;;;;MAqBC;IAED
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/video/webgpu/texture/store.js"],"names":[],"mappings":"AAwBA;;;;;;;;;;;;;;;;GAgBG;AACH;IACC;;OAEG;IACH,sBAFW,OAAO,uBAAuB,EAAE,OAAO,EAoBjD;IAhBA,kDAAwB;IACxB,8BAA6B;IAC7B,sCAAsC;IACtC,UADW,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CACT;IAKzB,yBAMC;IAIF;;;;;;;OAOG;IACH,mBANW,MAAM,UACN,MAAM,sBACJ,UAAU,CAmCtB;IAED;;;;;;;;;;OAUG;IACH,oBANW,MAAM,YAEd;QAA0B,KAAK;QACN,MAAM;KAC/B,GAAU,YAAY,CAuMxB;IAjHE;;;;kBAAwB;IAmH3B;;;;;;;;;OASG;IACH,wBAJW,MAAM,QA0EhB;IA/DC,0CAME;IAIF,2CAYE;IACF,mCAIE;IAsCJ;;;;;;;OAOG;IACH;;;;MAqBC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,wBATW,YAAY,gBACZ,YAAY,iBACZ,MAAM,YAEN,MAAM,GACJ,YAAY,CA4FxB;IAED;;;;;OAKG;IACH,4EAeC;IAED;;;;;;;;OAQG;IACH,2BAJW,MAAM,YACN,MAAM,GACJ,MAAM,CAKlB;IAED;;;;;;;;OAQG;IACH,mBAJW,UAAU,QAMpB;IAED;;;;OAIG;IACH,6BAIC;IAED;;;;;OAKG;IACH,wBAFW,MAAM,QAchB;IAED;;OAEG;IACH;;;;;;OAMG;IACH,kBAJW,UAAU,QAMpB;IAED;;OAEG;IACH,gBAIC;CACD;6BA9nB4B,2BAA2B"}
|
|
@@ -338,6 +338,7 @@ export default class WebGPURenderer extends Renderer {
|
|
|
338
338
|
*/
|
|
339
339
|
override drawLight(light: Light2d): void;
|
|
340
340
|
lightShader: RadialGradientEffect | undefined;
|
|
341
|
+
flatNormalAtlas: TextureAtlas | undefined;
|
|
341
342
|
lightAtlas: TextureAtlas | undefined;
|
|
342
343
|
/**
|
|
343
344
|
* Draw a pattern within the given rectangle.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webgpu_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgpu/webgpu_renderer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"webgpu_renderer.d.ts","sourceRoot":"","sources":["../../../src/video/webgpu/webgpu_renderer.js"],"names":[],"mappings":"AA4DA;;;;;;;;;;;;;;;GAeG;AACH,iDANW,OAAO,qBACP,OAAO,GACL;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AIhB;IAED;;;;;;;OAOG;IACH,UANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,UACN,MAAM,QAIhB;IAED;;;;;;OAMG;IACH,QALW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,QAIhB;IAED;;;;;;;OAOG;IACH,aANW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,SACN,MAAM,QAIhB;IAED;;OAEG;IACH,kBAEC;IAED;;;;OAIG;IACH,eAHW,IAAI,GAAC,SAAS,GAAC,OAAO,GAAC,IAAI,GAAC,OAAO,GAAC,MAAM,SAC1C,OAAO,QA2BjB;IAED;;;OAGG;IACH,aAFW,IAAI,GAAC,SAAS,GAAC,OAAO,GAAC,IAAI,GAAC,OAAO,GAAC,MAAM,QAIpD;IAmCD;;;;;OAKG;IACH,+BAwCC;IAED;;;OAGG;IACH,cAFa,gBAAgB,CAI5B;CAqFD;qBA3sHoB,gBAAgB;0CA0BK,oCAAoC;yBAtBrD,qBAAqB;yBA1BrB,wBAAwB;uBAC1B,yBAAyB;gCA8CU,qBAAqB;8BAHjD,mBAAmB;8BACnB,yBAAyB;+BAMxB,oBAAoB;+BA3BpB,uCAAuC;wBAN9C,2BAA2B;sBAnBlB,qBAAqB;0BA4C5B,8BAA8B;iCAvBvB,8BAA8B;6BAKrB,qBAAqB"}
|
package/package.json
CHANGED
|
@@ -527,6 +527,22 @@ and spot, a stylised quadratic falloff, not inverse-square),
|
|
|
527
527
|
**`Light2d` is 2D-only** and produces visible artifacts under perspective
|
|
528
528
|
projection. Do not combine it with `Camera3d`.
|
|
529
529
|
|
|
530
|
+
**`lit: true` only does anything under a `Camera3d`.** Lighting a mesh needs
|
|
531
|
+
world-space normals and a world-space fragment position, and the 2D-camera path
|
|
532
|
+
has neither: its vertices are already the projected output, so there is no world
|
|
533
|
+
space left to light in. Such a mesh degrades to unlit and warns once, naming the
|
|
534
|
+
fix. If you want lit 3D props in an otherwise 2D game, set
|
|
535
|
+
`cameraClass: Camera3d` on the application. (For 2D **sprites**, lighting is a
|
|
536
|
+
separate system that works under a 2D camera as normal, see the lighting skill.)
|
|
537
|
+
|
|
538
|
+
A `lit` mesh takes a **tangent-space normal map**, so relief comes from the
|
|
539
|
+
material rather than from geometry — `settings.normalMap` (a loader key or any
|
|
540
|
+
image-like source), or MTL `map_bump` / `bump` / `norm`, which the MTL loader
|
|
541
|
+
fetches and applies per material. The tangent frame is derived per fragment, so
|
|
542
|
+
the model needs no tangent attribute, and an unmapped mesh is unaffected. This
|
|
543
|
+
is the 3D counterpart of the `Sprite` normal maps in the lighting skill; they
|
|
544
|
+
are separate systems and a `Mesh` uses this one.
|
|
545
|
+
|
|
530
546
|
Ground shadows are **on by default** (the `castGroundShadow` application
|
|
531
547
|
setting), and need a GPU backend and a `Camera3d`. As a blanket default they
|
|
532
548
|
skip geometry with no vertical extent — a ground plane. Per object,
|
|
@@ -63,6 +63,32 @@ level.load("diorama", { scale: 50, onLoaded: () => {
|
|
|
63
63
|
}});
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
+
### The same options from a Tiled `Trigger`
|
|
67
|
+
|
|
68
|
+
A `Trigger` authored in Tiled forwards these to `level.load()`, so a trigger that
|
|
69
|
+
walks the player into a glTF level carries the scene's settings as Tiled
|
|
70
|
+
properties:
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
world.addChild(new Trigger(x, y, {
|
|
74
|
+
shapes: [new Rect(0, 0, 100, 100)],
|
|
75
|
+
to: "diorama", // the level id — `to`, not `level`
|
|
76
|
+
scale: 50,
|
|
77
|
+
rightHanded: false,
|
|
78
|
+
castGroundShadow: false,
|
|
79
|
+
}));
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`scale`, `rightHanded`, `lights`, `lightIntensityScale`, `castGroundShadow` and
|
|
83
|
+
`shadowGroundY` all travel, and so do `container`, `onLoaded`, `flatten` and
|
|
84
|
+
`setViewportBounds`. That list is **hardcoded** in `Trigger` — a `level.load`
|
|
85
|
+
option outside it is dropped without a warning.
|
|
86
|
+
|
|
87
|
+
**`async` is deliberately excluded.** A trigger with a `color` + `duration`
|
|
88
|
+
sets it itself, because it needs the promise to sequence its fade and reveal; a
|
|
89
|
+
trigger without one loads fire-and-forget and never sets it. Either way an
|
|
90
|
+
authored `async` property is ignored rather than honoured.
|
|
91
|
+
|
|
66
92
|
## `rightHanded` — and the default that differs between the two APIs
|
|
67
93
|
|
|
68
94
|
glTF is authored **Y-up, right-handed**; melonJS is **Y-down, +Z forward**.
|
|
@@ -226,16 +252,33 @@ const mesh = new Mesh(400, 300, {
|
|
|
226
252
|
world.addChild(mesh);
|
|
227
253
|
```
|
|
228
254
|
|
|
229
|
-
**The MTL loader fetches the textures it references itself** — `map_Kd
|
|
230
|
-
`map_d` are resolved relative to the `.mtl` and preloaded for
|
|
231
|
-
no image entry in the manifest above. Passing `texture:`
|
|
232
|
-
that and pins *one* binding over the whole model, which on
|
|
233
|
-
model suppresses the per-material texture split; leave it out
|
|
234
|
-
that.
|
|
255
|
+
**The MTL loader fetches the textures it references itself** — `map_Kd`,
|
|
256
|
+
`map_d` and `map_bump` are resolved relative to the `.mtl` and preloaded for
|
|
257
|
+
you, so there is no image entry in the manifest above. Passing `texture:`
|
|
258
|
+
explicitly overrides that and pins *one* binding over the whole model, which on
|
|
259
|
+
a multi-material model suppresses the per-material texture split; leave it out
|
|
260
|
+
unless you mean that.
|
|
235
261
|
|
|
236
262
|
MTL contributes `Kd` (diffuse tint), `d` / `Tr` (opacity), `Ke` (emissive),
|
|
237
|
-
`Ks` + `Ns` (specular highlight), `map_Kd` (diffuse texture)
|
|
238
|
-
(per-texel opacity)
|
|
263
|
+
`Ks` + `Ns` (specular highlight), `map_Kd` (diffuse texture), `map_d`
|
|
264
|
+
(per-texel opacity) and `map_bump` / `bump` / `norm` (tangent-space normal
|
|
265
|
+
map — needs `lit: true`, and the tangent frame is derived per fragment, so the
|
|
266
|
+
model needs no tangent attribute). All three normal-map spellings are read as
|
|
267
|
+
normal maps even though the format specifies two of them as height maps, which
|
|
268
|
+
is what every exporter actually writes. Specular *maps* (`map_Ks`) and the PBR
|
|
269
|
+
extension's `map_Pr` / `map_Pm` are not supported and warn — the `Pr` / `Pm`
|
|
270
|
+
*scalars* are read and approximated onto the specular terms, the maps would
|
|
271
|
+
need a real PBR model.
|
|
272
|
+
|
|
273
|
+
`Ka` (ambient) and `illum` (illumination model) are read onto the material and
|
|
274
|
+
readable from `loader.getMTL(name)`, but take no part in shading. That is
|
|
275
|
+
deliberate rather than pending: `Ka` predates scene-wide ambient light and would
|
|
276
|
+
fight `Stage.ambientLightingColor`, and `illum` enumerates fixed-function
|
|
277
|
+
behaviours this renderer has no equivalent for. In particular an `illum` of 0 or
|
|
278
|
+
1 nominally means "no specular", and the engine does **not** honour that — `Ns`
|
|
279
|
+
stays the only gate, so a model that renders correctly today is not restyled by
|
|
280
|
+
a field its exporter wrote inconsistently.
|
|
281
|
+
|
|
239
282
|
`loader.getOBJ(name)` and `loader.getMTL(name)` return the parsed data if you
|
|
240
283
|
want it directly. OBJ has no scene graph, no lights, no animation — use glTF for
|
|
241
284
|
anything beyond a single static model.
|
|
@@ -126,6 +126,43 @@ loader.preload([{ name: "ramp", type: "shader", data: myFragmentBody }]);
|
|
|
126
126
|
label.addPostEffect(loader.getShader("ramp"));
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
+
### Declare a level's effects with that level's assets
|
|
130
|
+
|
|
131
|
+
An effect the loader knows about can be prepared before anything draws it; an
|
|
132
|
+
effect built inline cannot, because it does not exist until the code that
|
|
133
|
+
constructs it runs — which is the stage or level you were hoping to speed up.
|
|
134
|
+
That is the practical reason to prefer the asset form even when the source is a
|
|
135
|
+
string in your own module:
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
// with the level's other assets, not in the stage that uses them.
|
|
139
|
+
// `preload()` rather than `load()` — preload is what warms the shaders it
|
|
140
|
+
// brought in, and it can be called again per level, not just at boot
|
|
141
|
+
await loader.preload([
|
|
142
|
+
{ name: "ripples", type: "shader", src: {
|
|
143
|
+
glsl: "assets/level2/ripples.glsl",
|
|
144
|
+
wgsl: "assets/level2/ripples.wgsl",
|
|
145
|
+
}},
|
|
146
|
+
// …that level's textures, maps and audio alongside it
|
|
147
|
+
], undefined, false); // `false`: stay on this stage, no loading screen
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
`src` takes the dual-language pair, so one asset carries both realizations and
|
|
151
|
+
the two backends cannot drift apart. `data` takes inline source the same way.
|
|
152
|
+
|
|
153
|
+
With `prewarm` on (the default since 20.6), `loader.preload()` warms on its way
|
|
154
|
+
through — automatically, on every call — and compiles the GPU-side objects for
|
|
155
|
+
every shader it holds — on WebGPU that is the
|
|
156
|
+
WGSL module, which is otherwise built inside the draw path the first time the
|
|
157
|
+
effect is used. Effects constructed inline are not in the loader, so nothing can
|
|
158
|
+
bring them forward.
|
|
159
|
+
|
|
160
|
+
One caveat if you are moving an inline effect to a file: a template literal can
|
|
161
|
+
interpolate constants into the source (`vec2(${ASPECT}, 1.0)`), and a static
|
|
162
|
+
file cannot. Promote those to uniforms rather than duplicating the numbers
|
|
163
|
+
across the GLSL and WGSL copies — duplicated constants are exactly how the two
|
|
164
|
+
backends drift.
|
|
165
|
+
|
|
129
166
|
Sharing one instance across renderables is safe *because* the loader sets
|
|
130
167
|
`effect.shared`. Without that flag a renderable's teardown destroys its post
|
|
131
168
|
effects, which would free the program out from under everything else still
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: melonjs-lighting
|
|
3
|
-
description: "Use this skill for 2D dynamic lighting in melonJS — Light2d, ambient light on a Stage, multiple lights, and per-pixel normal-mapped sprites authored in SpriteIlluminator. Covers the ambient-cutout model, which parts need a GPU backend, and why Light2d does not survive a Camera3d. Triggers on: Light2d, lighting, ambientLight, ambientLightingColor, normalMap, SpriteIlluminator, per-pixel lighting, drawLight, torch, glow, darkness."
|
|
3
|
+
description: "Use this skill for 2D dynamic lighting in melonJS — Light2d, ambient light on a Stage, multiple lights, and per-pixel normal-mapped sprites authored in SpriteIlluminator. Covers specular highlights via shininess, the ambient-cutout model, which parts need a GPU backend, and why Light2d does not survive a Camera3d. Triggers on: Light2d, specular, shininess, highlight, glint, lighting, ambientLight, ambientLightingColor, normalMap, SpriteIlluminator, per-pixel lighting, drawLight, torch, glow, darkness."
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -83,6 +83,50 @@ atlas can carry one too: `new TextureAtlas(json, image, { normalMap })` pairs a
|
|
|
83
83
|
normal texture sharing the colour texture's UVs, and a `Sprite` built from that
|
|
84
84
|
atlas picks it up in preference to its own `settings.normalMap`.
|
|
85
85
|
|
|
86
|
+
## Specular highlights
|
|
87
|
+
|
|
88
|
+
A normal map gives a sprite **shape**: the light knows which way each texel
|
|
89
|
+
faces, so a torch reveals bumps and crevices. `shininess` decides whether it
|
|
90
|
+
also **shines**:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
const sword = new Sprite(x, y, {
|
|
94
|
+
image: "sword",
|
|
95
|
+
normalMap: "sword_n",
|
|
96
|
+
shininess: 64, // 0 (the default) is matte
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The difference is what the highlight *does*. Diffuse brightness depends only on
|
|
101
|
+
the angle between the surface and the light, so a torch moving past just makes
|
|
102
|
+
the sprite brighter. A specular highlight only appears where a texel reflects
|
|
103
|
+
the light **toward the screen**, so it slides across the surface as the light
|
|
104
|
+
moves: armour that glints as you walk by, rather than armour that is merely lit.
|
|
105
|
+
|
|
106
|
+
Low values give a broad sheen (worn metal, wet stone); high values a tight glint
|
|
107
|
+
(polished steel, glass). It is gated on the exponent exactly as MTL `Ns` is on
|
|
108
|
+
the 3D path, so `0` means matte however bright the scene, and a sprite that
|
|
109
|
+
never sets it renders exactly as it always did.
|
|
110
|
+
|
|
111
|
+
Three things worth knowing:
|
|
112
|
+
|
|
113
|
+
- **It needs a `normalMap`.** With no surface directions there is nothing to
|
|
114
|
+
reflect, and the sprite stays matte whatever `shininess` says.
|
|
115
|
+
- **The normal map's alpha channel masks it per texel.** 255 is fully
|
|
116
|
+
reflective, 0 is dead matte, so one sprite can be a shiny blade with a matte
|
|
117
|
+
leather grip. A normal map with no alpha detail (the usual case) shines
|
|
118
|
+
uniformly. Note the corollary: if your normal map already uses alpha for
|
|
119
|
+
something, that channel now also decides gloss.
|
|
120
|
+
- **It accumulates per light.** Each light contributes its own highlight in its
|
|
121
|
+
own colour, so a sprite between a warm lamp and a cool one carries two
|
|
122
|
+
distinct glints that move independently.
|
|
123
|
+
|
|
124
|
+
The highlight takes the light's own colour and is *added* on top of the lit
|
|
125
|
+
result rather than multiplied into it, which is why a glint blows out toward
|
|
126
|
+
white on a dark sprite instead of tinting with it.
|
|
127
|
+
|
|
128
|
+
See it running: [Normal Map example](https://melonjs.github.io/melonJS/examples/#/normal-map).
|
|
129
|
+
|
|
86
130
|
Unlit areas of a normal-mapped sprite render pure black unless you raise
|
|
87
131
|
`Stage.ambientLightingColor` (default black) — that is the base level added to
|
|
88
132
|
every lit pixel, and it is a different knob from `Stage.ambientLight`.
|
|
@@ -39,7 +39,7 @@ The type strings are melonJS-specific — this is not a generic loader:
|
|
|
39
39
|
| type | for |
|
|
40
40
|
|---|---|
|
|
41
41
|
| `"image"` | textures, sprite sheets, normal maps |
|
|
42
|
-
| `"json"` | data, texture-atlas descriptors |
|
|
42
|
+
| `"json"` | data, texture-atlas descriptors, collision shapes from a shape editor |
|
|
43
43
|
| `"tmx"` / `"tsx"` | Tiled maps and external tilesets |
|
|
44
44
|
| `"audio"` | sound — **`src` is a directory**, see below |
|
|
45
45
|
| `"video"` | video textures |
|
|
@@ -56,6 +56,12 @@ The type strings are melonJS-specific — this is not a generic loader:
|
|
|
56
56
|
Preloading is not only for things with a URL. Three tiers, and the middle one
|
|
57
57
|
is the one people miss.
|
|
58
58
|
|
|
59
|
+
**After preloading, switch to a stage of your own.** `preload()` puts you in
|
|
60
|
+
`state.LOADING`, and that stage is transitional: build your scene in the
|
|
61
|
+
callback and stay there, and nothing ever destroys it, so the built-in loading
|
|
62
|
+
screen's logo and progress bar remain on top of your game. See
|
|
63
|
+
`melonjs-scenes-and-state`.
|
|
64
|
+
|
|
59
65
|
**1. Assets with a source.** Everything in the type table above. Note `"shader"`
|
|
60
66
|
takes **inline source** as well as a `src`, via the `data` field:
|
|
61
67
|
|
|
@@ -87,14 +93,42 @@ uploads four copies of the same pixels. Build them once after `preload`
|
|
|
87
93
|
resolves and share them, the way the platformer example builds its
|
|
88
94
|
`TextureAtlas` into a module the scenes read from.
|
|
89
95
|
|
|
90
|
-
**3. The engine's own shader
|
|
91
|
-
batcher compiles a program per *feature combination* (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
**3. The engine's own shader programs — warmed for you, since 20.6.** The mesh
|
|
97
|
+
batcher compiles a program per *feature combination* (instance colours, instance
|
|
98
|
+
data, fog — fog joins the key), lazily, on the first draw that needs it.
|
|
99
|
+
`prewarm` builds them during `preload()` instead, behind the loading
|
|
100
|
+
screen:
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
const app = new Application(1280, 720, {
|
|
104
|
+
// on by default since 20.6 — named here only to show where it lives
|
|
105
|
+
prewarm: true,
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**You do not call this yourself.** `preload()` calls `renderer.prewarm()` once
|
|
110
|
+
the assets are in and **before** `LOADER_COMPLETE` fires, so it happens while
|
|
111
|
+
the progress bar is still up. Every `preload()` warms, not just the first, so a
|
|
112
|
+
per-level preload warms whatever that level brought with it.
|
|
113
|
+
|
|
114
|
+
The one precondition: **a game that never calls `loader.preload()` is never
|
|
115
|
+
warmed**, because that is the only hook. If you load assets another way, call
|
|
116
|
+
`await app.renderer.prewarm()` yourself. On
|
|
117
|
+
WebGL that links the mesh batchers' variants, for the unlit tier and the lit
|
|
118
|
+
one that inherits from it; on WebGPU it compiles the
|
|
119
|
+
WGSL module of every shader the loader holds — which is the reason to declare
|
|
120
|
+
effects as assets rather than build them inline (see above).
|
|
121
|
+
|
|
122
|
+
Cost to a game that uses none of it is about 60ms of preload on a desktop GPU.
|
|
123
|
+
Set it to `false` only for a target where linking is slow enough that the
|
|
124
|
+
preload itself would suffer.
|
|
125
|
+
|
|
126
|
+
**What it does not do.** It makes the shaders *ready* earlier. It does not
|
|
127
|
+
remove the hitch on a scene's first frame, because most of that frame is
|
|
128
|
+
first-**submit** work — texture residency, buffer uploads, the driver
|
|
129
|
+
specializing against real bindings — which compiling a program does not touch.
|
|
130
|
+
For that, the lever is still to **draw** the scene once while the loading screen
|
|
131
|
+
is up and then throw it away; the warmed GPU state stays behind.
|
|
98
132
|
|
|
99
133
|
```js
|
|
100
134
|
await loader.preload(resources);
|
|
@@ -172,6 +172,14 @@ fog) and links it on the first draw that needs it — and `compileProgram` calls
|
|
|
172
172
|
`getProgramParameter(LINK_STATUS)` right after `linkProgram`, which blocks until
|
|
173
173
|
the driver finishes. That whole cost lands inside one frame.
|
|
174
174
|
|
|
175
|
+
Since 20.6 the engine's own programs are built during `preload()` instead —
|
|
176
|
+
`loader.preload()` calls `renderer.prewarm()` itself, on every call, when the
|
|
177
|
+
application's `prewarm` setting is on, which is the default. So on a current
|
|
178
|
+
version this is one cause you can rule out before looking further, **unless the
|
|
179
|
+
game does not use the preloader at all**, which is the one way to miss it — see `melonjs-loading-assets`. It does not
|
|
180
|
+
cover effects you construct inline, and it does not cover the rest of what a
|
|
181
|
+
first frame pays for, below.
|
|
182
|
+
|
|
175
183
|
How to tell them apart, all from the page:
|
|
176
184
|
|
|
177
185
|
```js
|
|
@@ -191,12 +199,32 @@ gl.linkProgram = function (p) { console.count("linkProgram"); return link.call(t
|
|
|
191
199
|
|
|
192
200
|
The tell is that the second entry into the same scene is cheap: one measured
|
|
193
201
|
case went 852ms of stall (worst frame 479ms) on first entry to 277ms (worst
|
|
194
|
-
102ms) on the second
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
it
|
|
202
|
+
102ms) on the second.
|
|
203
|
+
|
|
204
|
+
**Careful with the conclusion, though — "the programs were cached" is the
|
|
205
|
+
tempting reading and it is wrong.** Prewarming the engine's own programs ahead
|
|
206
|
+
of that first entry moves the worst frame by about 3ms, measured. So the 575ms
|
|
207
|
+
is not program linking: it is everything else the first *submit* pays for —
|
|
208
|
+
texture residency, buffer uploads, and the driver specializing a pipeline
|
|
209
|
+
against real bindings — all of which the second entry finds already done.
|
|
210
|
+
|
|
211
|
+
That distinction decides which lever to reach for. Linking is what `prewarm`
|
|
212
|
+
covers and what shrinking your shader count helps. The rest only goes away if
|
|
213
|
+
the geometry is actually **drawn** once beforehand.
|
|
214
|
+
|
|
215
|
+
Three things follow.
|
|
216
|
+
|
|
217
|
+
- **Cut the number of programs.** Identical `ShaderEffect`s each link their own,
|
|
218
|
+
so preload one as a `"shader"` asset and share it.
|
|
219
|
+
- **Declare effects as assets, not inline**, so the loader can prepare them
|
|
220
|
+
before a scene draws — an inline effect does not exist until the stage that
|
|
221
|
+
builds it runs.
|
|
222
|
+
- **Pay what remains behind the loading screen** by drawing the scene once there
|
|
223
|
+
and discarding it (see `melonjs-loading-assets`). Linking is only part of a
|
|
224
|
+
first frame: texture residency, buffer uploads and the driver specializing
|
|
225
|
+
against real bindings all land on the first *submit*, and only an actual draw
|
|
226
|
+
front-loads those. A measured case on a fast desktop GPU had shader prewarming
|
|
227
|
+
move the worst frame by ~3ms while a warm-up draw moved it by hundreds.
|
|
200
228
|
|
|
201
229
|
Do not profile this on a software rasterizer — headless Chromium falls back to
|
|
202
230
|
SwiftShader, where the absolute numbers are wildly pessimistic and the JS
|