Skip to content

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.

refactor(render): single-source .esshader pipeline; delete dead shaders — REARCH_RENDER RC7-6

esenginee850e421cc07
diff --git a/src/esengine/data/shaders/axis.esshader b/src/esengine/data/shaders/axis.esshader
deleted file mode 100644
index e4d1e18de..000000000
--- a/src/esengine/data/shaders/axis.esshader
+++ /dev/null
@@ -1,25 +0,0 @@
-#pragma shader "Axis"
-
-#pragma vertex
-attribute vec3 a_position;
-attribute vec4 a_color;
-
-uniform mat4 u_viewProj;
-
-varying vec4 v_color;
-
-void main() {
- gl_Position = u_viewProj * vec4(a_position, 1.0);
- v_color = a_color;
-}
-#pragma end
-
-#pragma fragment
-precision mediump float;
-
-varying vec4 v_color;
-
-void main() {
- gl_FragColor = v_color;
-}
-#pragma end
diff --git a/src/esengine/data/shaders/batch.esshader b/src/esengine/data/shaders/batch.esshader
index 0d0dfc06e..9969ae161 100644
--- a/src/esengine/data/shaders/batch.esshader
+++ b/src/esengine/data/shaders/batch.esshader
@@ -1,14 +1,17 @@
#pragma shader "Batch"
+#pragma version 300 es
#pragma vertex
-attribute vec2 a_position;
-attribute vec4 a_color;
-attribute vec2 a_texCoord;
+layout(location = 0) in vec2 a_position;
+layout(location = 1) in vec4 a_color;
+layout(location = 2) in vec2 a_texCoord;
-uniform mat4 u_projection;
+layout(std140) uniform FrameConstants {
+ mat4 u_projection;
+};
-varying vec4 v_color;
-varying vec2 v_texCoord;
+out vec4 v_color;
+out vec2 v_texCoord;
void main() {
gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
@@ -20,13 +23,15 @@ void main() {
#pragma fragment
precision mediump float;
-varying vec4 v_color;
-varying vec2 v_texCoord;
+in vec4 v_color;
+in vec2 v_texCoord;
uniform sampler2D u_texture;
+out vec4 fragColor;
+
void main() {
- vec4 texColor = texture2D(u_texture, v_texCoord);
- gl_FragColor = texColor * v_color;
+ vec4 texColor = texture(u_texture, v_texCoord);
+ fragColor = texColor * v_color;
}
#pragma end
diff --git a/src/esengine/data/shaders/color.esshader b/src/esengine/data/shaders/color.esshader
deleted file mode 100644
index 94fc17aca..000000000
--- a/src/esengine/data/shaders/color.esshader
+++ /dev/null
@@ -1,22 +0,0 @@
-#pragma shader "Color"
-
-#pragma vertex
-attribute vec2 a_position;
-
-uniform mat4 u_projection;
-uniform mat4 u_model;
-
-void main() {
- gl_Position = u_projection * u_model * vec4(a_position, 0.0, 1.0);
-}
-#pragma end
-
-#pragma fragment
-precision mediump float;
-
-uniform vec4 u_color;
-
-void main() {
- gl_FragColor = u_color;
-}
-#pragma end
diff --git a/src/esengine/data/shaders/gizmo.esshader b/src/esengine/data/shaders/gizmo.esshader
deleted file mode 100644
index fc9b8b535..000000000
--- a/src/esengine/data/shaders/gizmo.esshader
+++ /dev/null
@@ -1,26 +0,0 @@
-#pragma shader "Gizmo"
-
-#pragma vertex
-attribute vec3 a_position;
-attribute vec4 a_color;
-
-uniform mat4 u_viewProj;
-uniform mat4 u_model;
-
-varying vec4 v_color;
-
-void main() {
- gl_Position = u_viewProj * u_model * vec4(a_position, 1.0);
- v_color = a_color;
-}
-#pragma end
-
-#pragma fragment
-precision mediump float;
-
-varying vec4 v_color;
-
-void main() {
- gl_FragColor = v_color;
-}
-#pragma end
diff --git a/src/esengine/data/shaders/grid.esshader b/src/esengine/data/shaders/grid.esshader
deleted file mode 100644
index b97efd9e5..000000000
--- a/src/esengine/data/shaders/grid.esshader
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma shader "Grid"
-
-#pragma vertex
-attribute vec3 a_position;
-
-uniform mat4 u_viewProj;
-
-void main() {
- gl_Position = u_viewProj * vec4(a_position, 1.0);
-}
-#pragma end
-
-#pragma fragment
-precision mediump float;
-
-uniform vec4 u_color;
-
-void main() {
- gl_FragColor = u_color;
-}
-#pragma end
diff --git a/src/esengine/data/shaders/particle.esshader b/src/esengine/data/shaders/particle.esshader
new file mode 100644
index 000000000..3b12da956
--- /dev/null
+++ b/src/esengine/data/shaders/particle.esshader
@@ -0,0 +1,54 @@
+#pragma shader "ParticleInstance"
+#pragma version 300 es
+
+#pragma vertex
+layout(location = 0) in vec2 a_position;
+layout(location = 1) in vec2 a_texCoord;
+
+layout(location = 2) in vec2 a_inst_position;
+layout(location = 3) in vec2 a_inst_size;
+layout(location = 4) in float a_inst_rotation;
+layout(location = 5) in vec4 a_inst_color;
+layout(location = 6) in vec2 a_inst_uv_offset;
+layout(location = 7) in vec2 a_inst_uv_scale;
+
+layout(std140) uniform FrameConstants {
+ mat4 u_projection;
+};
+
+out vec2 v_texCoord;
+out vec4 v_color;
+
+void main() {
+ vec2 scaled = a_position * a_inst_size;
+
+ float cosR = cos(a_inst_rotation);
+ float sinR = sin(a_inst_rotation);
+ vec2 rotated = vec2(
+ scaled.x * cosR - scaled.y * sinR,
+ scaled.x * sinR + scaled.y * cosR
+ );
+
+ vec2 worldPos = rotated + a_inst_position;
+ gl_Position = u_projection * vec4(worldPos, 0.0, 1.0);
+
+ v_texCoord = a_texCoord * a_inst_uv_scale + a_inst_uv_offset;
+ v_color = a_inst_color;
+}
+#pragma end
+
+#pragma fragment
+precision mediump float;
+
+in vec2 v_texCoord;
+in vec4 v_color;
+
+uniform sampler2D u_texture;
+
+out vec4 fragColor;
+
+void main() {
+ vec4 texColor = texture(u_texture, v_texCoord);
+ fragColor = texColor * v_color;
+}
+#pragma end
diff --git a/src/esengine/data/shaders/sprite.esshader b/src/esengine/data/shaders/sprite.esshader
deleted file mode 100644
index ad82cb755..000000000
--- a/src/esengine/data/shaders/sprite.esshader
+++ /dev/null
@@ -1,30 +0,0 @@
-#pragma shader "Sprite"
-
-#pragma vertex
-attribute vec2 a_position;
-attribute vec2 a_texCoord;
-
-uniform mat4 u_projection;
-uniform mat4 u_model;
-
-varying vec2 v_texCoord;
-
-void main() {
- gl_Position = u_projection * u_model * vec4(a_position, 0.0, 1.0);
- v_texCoord = a_texCoord;
-}
-#pragma end
-
-#pragma fragment
-precision mediump float;
-
-uniform sampler2D u_texture;
-uniform vec4 u_color;
-
-varying vec2 v_texCoord;
-
-void main() {
- vec4 texColor = texture2D(u_texture, v_texCoord);
- gl_FragColor = texColor * u_color;
-}
-#pragma end
diff --git a/src/esengine/data/shaders/ui.esshader b/src/esengine/data/shaders/ui.esshader
deleted file mode 100644
index 7b2282dd0..000000000
--- a/src/esengine/data/shaders/ui.esshader
+++ /dev/null
@@ -1,44 +0,0 @@
-#pragma shader "UI"
-
-#pragma vertex
-attribute vec2 a_position;
-attribute vec2 a_texCoord;
-attribute vec4 a_color;
-
-uniform mat4 u_projection;
-
-varying vec2 v_texCoord;
-varying vec4 v_color;
-
-void main() {
- gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
- v_texCoord = a_texCoord;
- v_color = a_color;
-}
-#pragma end
-
-#pragma fragment
-precision mediump float;
-
-uniform sampler2D u_texture;
-uniform int u_useTexture;
-uniform int u_useSDF;
-uniform float u_sdfSmoothing;
-
-varying vec2 v_texCoord;
-varying vec4 v_color;
-
-void main() {
- if (u_useTexture == 1) {
- if (u_useSDF == 1) {
- float dist = texture2D(u_texture, v_texCoord).a;
- float alpha = smoothstep(0.5 - u_sdfSmoothing, 0.5 + u_sdfSmoothing, dist);
- gl_FragColor = vec4(v_color.rgb, v_color.a * alpha);
- } else {
- gl_FragColor = texture2D(u_texture, v_texCoord) * v_color;
- }
- } else {
- gl_FragColor = v_color;
- }
-}
-#pragma end
diff --git a/src/esengine/renderer/ImmediateDraw.cpp b/src/esengine/renderer/ImmediateDraw.cpp
index 505b6a2f6..9c840c866 100644
--- a/src/esengine/renderer/ImmediateDraw.cpp
+++ b/src/esengine/renderer/ImmediateDraw.cpp
@@ -16,7 +16,9 @@
#include "GfxDevice.hpp"
#include "RenderContext.hpp"
#include "Shader.hpp"
+#include "ShaderEmbeds.generated.hpp"
#include "BatchVertex.hpp"
+#include "../resource/ShaderParser.hpp"
#include "../resource/ResourceManager.hpp"
#include "../core/Log.hpp"
@@ -58,9 +60,10 @@ void ImmediateDraw::init() {
pool_.init();
white_texture_id_ = context_.getWhiteTextureId();
+ auto parsed = resource::ShaderParser::parse(ShaderEmbeds::BATCH);
auto handle = resource_manager_.createShaderWithBindings(
- ShaderSources::BATCH_VERTEX,
- ShaderSources::BATCH_FRAGMENT,
+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Vertex),
+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Fragment),
{{0, "a_position"}, {1, "a_color"}, {2, "a_texCoord"}}
);
Shader* shader = resource_manager_.getShader(handle);
diff --git a/src/esengine/renderer/RenderFrame.cpp b/src/esengine/renderer/RenderFrame.cpp
index 85ac611ad..c63722061 100644
--- a/src/esengine/renderer/RenderFrame.cpp
+++ b/src/esengine/renderer/RenderFrame.cpp
@@ -1,5 +1,7 @@
#include "RenderFrame.hpp"
#include "Shader.hpp"
+#include "ShaderEmbeds.generated.hpp"
+#include "../resource/ShaderParser.hpp"
#include "../core/Log.hpp"
#include <glm/gtc/type_ptr.hpp>
@@ -356,12 +358,12 @@ void RenderFrame::collectAll(ecs::Registry& registry, u32 skipFlags) {
}
u32 RenderFrame::initBatchShader() {
- // The batch shader ships embedded as source (ShaderSources::BATCH_*); there is
- // no file-load path on web. WebGL2 guarantees GLSL ES 3.00, so there is no ES 1.0
- // fallback — the batch shader is unconditionally the ES 3.00 source.
+ // The batch shader is authored as a single .esshader, embedded for the web build.
+ // Parse it and assemble the two GLSL ES 3.00 stages (single source of truth).
+ auto parsed = resource::ShaderParser::parse(ShaderEmbeds::BATCH);
resource::ShaderHandle handle = resource_manager_.createShaderWithBindings(
- ShaderSources::BATCH_VERTEX,
- ShaderSources::BATCH_FRAGMENT,
+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Vertex),
+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Fragment),
{{0, "a_position"}, {1, "a_color"}, {2, "a_texCoord"}}
);
diff --git a/src/esengine/renderer/Shader.hpp b/src/esengine/renderer/Shader.hpp
index 42bcc7d28..3c0cfc672 100644
--- a/src/esengine/renderer/Shader.hpp
+++ b/src/esengine/renderer/Shader.hpp
@@ -226,141 +226,4 @@ private:
std::vector<GfxUniformInfo> activeUniforms_;
};
-// =============================================================================
-// Built-in Shader Sources
-// =============================================================================
-
-/**
- * @brief Shader source code for internal renderers (ES 3.0)
- *
- * @details ES 1.0 shaders (sprite, color, batch compat) are now sourced from
- * .esshader files via ShaderEmbeds.generated.hpp + ShaderParser.
- * Only ES 3.0 and internal-only shaders remain here.
- */
-namespace ShaderSources {
-
-inline const char* EXT_MESH_VERTEX = R"(
- attribute vec2 a_position;
- attribute vec2 a_texCoord;
- attribute vec4 a_color;
-
- uniform mat4 u_projection;
- uniform mat4 u_model;
-
- varying vec2 v_texCoord;
- varying vec4 v_color;
-
- void main() {
- gl_Position = u_projection * u_model * vec4(a_position, 0.0, 1.0);
- v_texCoord = a_texCoord;
- v_color = a_color;
- }
-)";
-
-inline const char* EXT_MESH_FRAGMENT = R"(
- precision mediump float;
-
- uniform sampler2D u_texture;
-
- varying vec2 v_texCoord;
- varying vec4 v_color;
-
- void main() {
- vec4 texColor = texture2D(u_texture, v_texCoord);
- gl_FragColor = texColor * v_color;
- }
-)";
-
-inline const char* BATCH_VERTEX = R"(#version 300 es
- layout(location = 0) in vec2 a_position;
- layout(location = 1) in vec4 a_color;
- layout(location = 2) in vec2 a_texCoord;
-
- layout(std140) uniform FrameConstants {
- mat4 u_projection;
- };
-
- out vec4 v_color;
- out vec2 v_texCoord;
-
- void main() {
- gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
- v_color = a_color;
- v_texCoord = a_texCoord;
- }
-)";
-
-/**
- * @brief Fragment shader for batched sprite rendering
- */
-inline const char* BATCH_FRAGMENT = R"(#version 300 es
- precision mediump float;
-
- in vec4 v_color;
- in vec2 v_texCoord;
-
- uniform sampler2D u_texture;
-
- out vec4 fragColor;
-
- void main() {
- vec4 texColor = texture(u_texture, v_texCoord);
- fragColor = texColor * v_color;
- }
-)";
-
-inline const char* PARTICLE_INSTANCE_VERTEX = R"(#version 300 es
- layout(location = 0) in vec2 a_position;
- layout(location = 1) in vec2 a_texCoord;
-
- layout(location = 2) in vec2 a_inst_position;
- layout(location = 3) in vec2 a_inst_size;
- layout(location = 4) in float a_inst_rotation;
- layout(location = 5) in vec4 a_inst_color;
- layout(location = 6) in vec2 a_inst_uv_offset;
- layout(location = 7) in vec2 a_inst_uv_scale;
-
- layout(std140) uniform FrameConstants {
- mat4 u_projection;
- };
-
- out vec2 v_texCoord;
- out vec4 v_color;
-
- void main() {
- vec2 scaled = a_position * a_inst_size;
-
- float cosR = cos(a_inst_rotation);
- float sinR = sin(a_inst_rotation);
- vec2 rotated = vec2(
- scaled.x * cosR - scaled.y * sinR,
- scaled.x * sinR + scaled.y * cosR
- );
-
- vec2 worldPos = rotated + a_inst_position;
- gl_Position = u_projection * vec4(worldPos, 0.0, 1.0);
-
- v_texCoord = a_texCoord * a_inst_uv_scale + a_inst_uv_offset;
- v_color = a_inst_color;
- }
-)";
-
-inline const char* PARTICLE_INSTANCE_FRAGMENT = R"(#version 300 es
- precision mediump float;
-
- in vec2 v_texCoord;
- in vec4 v_color;
-
- uniform sampler2D u_texture;
-
- out vec4 fragColor;
-
- void main() {
- vec4 texColor = texture(u_texture, v_texCoord);
- fragColor = texColor * v_color;
- }
-)";
-
-} // namespace ShaderSources
-
} // namespace esengine
diff --git a/src/esengine/renderer/ShaderEmbeds.generated.hpp b/src/esengine/renderer/ShaderEmbeds.generated.hpp
index 20a6e8bb7..d762038d4 100644
--- a/src/esengine/renderer/ShaderEmbeds.generated.hpp
+++ b/src/esengine/renderer/ShaderEmbeds.generated.hpp
@@ -2,44 +2,20 @@
namespace esengine::ShaderEmbeds {
-inline constexpr const char* AXIS = R"esshader(#pragma shader "Axis"
-
-#pragma vertex
-attribute vec3 a_position;
-attribute vec4 a_color;
-
-uniform mat4 u_viewProj;
-
-varying vec4 v_color;
-
-void main() {
- gl_Position = u_viewProj * vec4(a_position, 1.0);
- v_color = a_color;
-}
-#pragma end
-
-#pragma fragment
-precision mediump float;
-
-varying vec4 v_color;
-
-void main() {
- gl_FragColor = v_color;
-}
-#pragma end
-)esshader";
-
inline constexpr const char* BATCH = R"esshader(#pragma shader "Batch"
+#pragma version 300 es
#pragma vertex
-attribute vec2 a_position;
-attribute vec4 a_color;
-attribute vec2 a_texCoord;
+layout(location = 0) in vec2 a_position;
+layout(location = 1) in vec4 a_color;
+layout(location = 2) in vec2 a_texCoord;
-uniform mat4 u_projection;
+layout(std140) uniform FrameConstants {
+ mat4 u_projection;
+};
-varying vec4 v_color;
-varying vec2 v_texCoord;
+out vec4 v_color;
+out vec2 v_texCoord;
void main() {
gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
@@ -51,89 +27,72 @@ void main() {
#pragma fragment
precision mediump float;
-varying vec4 v_color;
-varying vec2 v_texCoord;
+in vec4 v_color;
+in vec2 v_texCoord;
uniform sampler2D u_texture;
+out vec4 fragColor;
+
void main() {
- vec4 texColor = texture2D(u_texture, v_texCoord);
- gl_FragColor = texColor * v_color;
+ vec4 texColor = texture(u_texture, v_texCoord);
+ fragColor = texColor * v_color;
}
#pragma end
)esshader";
-inline constexpr const char* COLOR = R"esshader(#pragma shader "Color"
+inline constexpr const char* PARTICLE = R"esshader(#pragma shader "ParticleInstance"
+#pragma version 300 es
#pragma vertex
-attribute vec2 a_position;
+layout(location = 0) in vec2 a_position;
+layout(location = 1) in vec2 a_texCoord;
-uniform mat4 u_projection;
-uniform mat4 u_model;
+layout(location = 2) in vec2 a_inst_position;
+layout(location = 3) in vec2 a_inst_size;
+layout(location = 4) in float a_inst_rotation;
+layout(location = 5) in vec4 a_inst_color;
+layout(location = 6) in vec2 a_inst_uv_offset;
+layout(location = 7) in vec2 a_inst_uv_scale;
-void main() {
- gl_Position = u_projection * u_model * vec4(a_position, 0.0, 1.0);
-}
-#pragma end
-
-#pragma fragment
-precision mediump float;
+layout(std140) uniform FrameConstants {
+ mat4 u_projection;
+};
-uniform vec4 u_color;
+out vec2 v_texCoord;
+out vec4 v_color;
void main() {
- gl_FragColor = u_color;
-}
-#pragma end
-)esshader";
-
-inline constexpr const char* GIZMO = R"esshader(#pragma shader "Gizmo"
-
-#pragma vertex
-attribute vec3 a_position;
-attribute vec4 a_color;
+ vec2 scaled = a_position * a_inst_size;
-uniform mat4 u_viewProj;
-uniform mat4 u_model;
+ float cosR = cos(a_inst_rotation);
+ float sinR = sin(a_inst_rotation);
+ vec2 rotated = vec2(
+ scaled.x * cosR - scaled.y * sinR,
+ scaled.x * sinR + scaled.y * cosR
+ );
-varying vec4 v_color;
+ vec2 worldPos = rotated + a_inst_position;
+ gl_Position = u_projection * vec4(worldPos, 0.0, 1.0);
-void main() {
- gl_Position = u_viewProj * u_model * vec4(a_position, 1.0);
- v_color = a_color;
+ v_texCoord = a_texCoord * a_inst_uv_scale + a_inst_uv_offset;
+ v_color = a_inst_color;
}
#pragma end
#pragma fragment
precision mediump float;
-varying vec4 v_color;
-
-void main() {
- gl_FragColor = v_color;
-}
-#pragma end
-)esshader";
-
-inline constexpr const char* GRID = R"esshader(#pragma shader "Grid"
-
-#pragma vertex
-attribute vec3 a_position;
-
-uniform mat4 u_viewProj;
-
-void main() {
- gl_Position = u_viewProj * vec4(a_position, 1.0);
-}
-#pragma end
+in vec2 v_texCoord;
+in vec4 v_color;
-#pragma fragment
-precision mediump float;
+uniform sampler2D u_texture;
-uniform vec4 u_color;
+out vec4 fragColor;
void main() {
- gl_FragColor = u_color;
+ vec4 texColor = texture(u_texture, v_texCoord);
+ fragColor = texColor * v_color;
}
#pragma end
)esshader";
@@ -202,82 +161,4 @@ void main() {
#pragma end
)esshader";
-inline constexpr const char* SPRITE = R"esshader(#pragma shader "Sprite"
-
-#pragma vertex
-attribute vec2 a_position;
-attribute vec2 a_texCoord;
-
-uniform mat4 u_projection;
-uniform mat4 u_model;
-
-varying vec2 v_texCoord;
-
-void main() {
- gl_Position = u_projection * u_model * vec4(a_position, 0.0, 1.0);
- v_texCoord = a_texCoord;
-}
-#pragma end
-
-#pragma fragment
-precision mediump float;
-
-uniform sampler2D u_texture;
-uniform vec4 u_color;
-
-varying vec2 v_texCoord;
-
-void main() {
- vec4 texColor = texture2D(u_texture, v_texCoord);
- gl_FragColor = texColor * u_color;
-}
-#pragma end
-)esshader";
-
-inline constexpr const char* UI = R"esshader(#pragma shader "UI"
-
-#pragma vertex
-attribute vec2 a_position;
-attribute vec2 a_texCoord;
-attribute vec4 a_color;
-
-uniform mat4 u_projection;
-
-varying vec2 v_texCoord;
-varying vec4 v_color;
-
-void main() {
- gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
- v_texCoord = a_texCoord;
- v_color = a_color;
-}
-#pragma end
-
-#pragma fragment
-precision mediump float;
-
-uniform sampler2D u_texture;
-uniform int u_useTexture;
-uniform int u_useSDF;
-uniform float u_sdfSmoothing;
-
-varying vec2 v_texCoord;
-varying vec4 v_color;
-
-void main() {
- if (u_useTexture == 1) {
- if (u_useSDF == 1) {
- float dist = texture2D(u_texture, v_texCoord).a;
- float alpha = smoothstep(0.5 - u_sdfSmoothing, 0.5 + u_sdfSmoothing, dist);
- gl_FragColor = vec4(v_color.rgb, v_color.a * alpha);
- } else {
- gl_FragColor = texture2D(u_texture, v_texCoord) * v_color;
- }
- } else {
- gl_FragColor = v_color;
- }
-}
-#pragma end
-)esshader";
-
} // namespace esengine::ShaderEmbeds
diff --git a/src/esengine/renderer/plugins/ParticlePlugin.cpp b/src/esengine/renderer/plugins/ParticlePlugin.cpp
index 7c2909d2f..4d78257b7 100644
--- a/src/esengine/renderer/plugins/ParticlePlugin.cpp
+++ b/src/esengine/renderer/plugins/ParticlePlugin.cpp
@@ -2,8 +2,10 @@
#include "../RenderContext.hpp"
#include "../RenderFrame.hpp"
#include "../Shader.hpp"
+#include "../ShaderEmbeds.generated.hpp"
#include "../Texture.hpp"
#include "../BatchVertex.hpp" // packColor
+#include "../../resource/ShaderParser.hpp"
#include "../../ecs/components/Transform.hpp"
#include "../../ecs/components/ParticleEmitter.hpp"
#include "../../particle/ParticleSystem.hpp"
@@ -29,11 +31,12 @@ static_assert(sizeof(ParticleInstanceData) == 40, "instance stride must match th
} // namespace
void ParticlePlugin::init(RenderFrameContext& ctx) {
- // Activate the (previously dead) instancing shader. Attribute locations are explicit
- // in the GLSL, so no name bindings are needed.
+ // Particle instancing shader, authored as particle.esshader (single source) and
+ // embedded for the web build. Attribute locations are explicit, so no name bindings.
+ auto parsed = resource::ShaderParser::parse(ShaderEmbeds::PARTICLE);
auto handle = ctx.resources.createShaderWithBindings(
- ShaderSources::PARTICLE_INSTANCE_VERTEX,
- ShaderSources::PARTICLE_INSTANCE_FRAGMENT,
+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Vertex),
+ resource::ShaderParser::assembleStage(parsed, resource::ShaderStage::Fragment),
{});
Shader* shader = ctx.resources.getShader(handle);
if (shader && shader->isValid()) {