Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

WIP rename shader registry

Nguyen Xuan An4382d3dda1c5
diff --git a/src/impostor-slots.js b/src/impostor-slots.js
deleted file mode 100644
index 0ad7afa6..00000000
--- a/src/impostor-slots.js
+++ /dev/null
@@ -1,9 +0,0 @@
-// The GLSL slots that the impostor card fills into the vertex shaders. They live apart from shaders.js so that the
-// vegetation addon can register its code without pulling every shader into its bundle.
-
-export const impostorGlsl = { declarations: '', colorHook: '', normalHook: '', depthHook: '' };
-
-/** Register the GLSL of the impostor card: declarations, colorHook and normalHook (colour pass), depthHook (shadow pass). */
-export function registerImpostorShaderCode(slots) {
- Object.assign(impostorGlsl, slots);
-}
diff --git a/src/shader-registry.js b/src/shader-registry.js
new file mode 100644
index 00000000..eb909b8b
--- /dev/null
+++ b/src/shader-registry.js
@@ -0,0 +1,15 @@
+// Tables that addons fill on import, kept apart from shaders.js and renderer.js so an addon can register without
+// pulling either into its bundle, and a scene without the addon pays only for the empty slots.
+
+/** Value of `material.tag` in the instance data; the vegetation addon adds `impostor`. */
+export const materialTags = { armor: 1, floor: 2, water: 3, foliage: 4, terrain: 5, grass: 7, fire: 8, smoke: 9, unlit: 10, liquid: 11, foam: 12 };
+
+/**
+ * GLSL the vegetation addon splices into the shaders: `declarations`, `colorHook` and `normalHook` in the colour vertex
+ * shader, `depthHook` in the shadow vertex shader and `alphaCoverage` in the fragment shader's surfaceAlpha.
+ */
+export const addonGlsl = { declarations: '', colorHook: '', normalHook: '', depthHook: '', alphaCoverage: '' };
+
+export function registerAddonGlsl(slots) {
+ Object.assign(addonGlsl, slots);
+}