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.

fix(render): the vertex stage a material inherits takes a vec3 too

esenginedc073595e5db
diff --git a/desktop/public/scenes/mat-builtin-lit/lit.esshader b/desktop/public/scenes/mat-builtin-lit/lit.esshader
index f4fd0903a..7fa74ef53 100644
--- a/desktop/public/scenes/mat-builtin-lit/lit.esshader
+++ b/desktop/public/scenes/mat-builtin-lit/lit.esshader
@@ -55,7 +55,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -71,20 +71,20 @@ var u_normalMap_est: texture_2d<f32>;
var u_normalMap_ess: sampler;
fn main_1() {
- let _e16 = unnamed_1.u_projection;
- let _e17 = a_position_1;
- unnamed.gl_Position = (_e16 * vec4<f32>(_e17.x, _e17.y, 0f, 1f));
+ let _e15 = unnamed_1.u_projection;
+ let _e16 = a_position_1;
+ unnamed.gl_Position = (_e15 * vec4<f32>(_e16.x, _e16.y, _e16.z, 1f));
let _e23 = a_color_1;
v_color = _e23;
let _e24 = a_texCoord_1;
v_texCoord = _e24;
let _e25 = a_position_1;
- v_worldPos = _e25;
+ v_worldPos = _e25.xy;
return;
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
diff --git a/desktop/public/scenes/mat-dissolve/dissolve.esshader b/desktop/public/scenes/mat-dissolve/dissolve.esshader
index 9bc908005..4bff50341 100644
--- a/desktop/public/scenes/mat-dissolve/dissolve.esshader
+++ b/desktop/public/scenes/mat-dissolve/dissolve.esshader
@@ -70,7 +70,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -81,9 +81,9 @@ var<uniform> unnamed_2: TimeConstants;
var<uniform> unnamed_3: MaterialConstants;
fn main_1() {
- let _e13 = unnamed_1.u_projection;
- let _e14 = a_position_1;
- unnamed.gl_Position = (_e13 * vec4<f32>(_e14.x, _e14.y, 0f, 1f));
+ let _e12 = unnamed_1.u_projection;
+ let _e13 = a_position_1;
+ unnamed.gl_Position = (_e12 * vec4<f32>(_e13.x, _e13.y, _e13.z, 1f));
let _e20 = a_color_1;
v_color = _e20;
let _e21 = a_texCoord_1;
@@ -92,7 +92,7 @@ fn main_1() {
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
diff --git a/desktop/public/scenes/mat-graph/graph-tint.esshader b/desktop/public/scenes/mat-graph/graph-tint.esshader
index 10cc80c71..d6bccf5db 100644
--- a/desktop/public/scenes/mat-graph/graph-tint.esshader
+++ b/desktop/public/scenes/mat-graph/graph-tint.esshader
@@ -5,7 +5,7 @@
#pragma param u_tint color default(1,1,1,1)
#pragma vertex
-layout(location = 0) in vec2 a_position;
+layout(location = 0) in vec3 a_position;
layout(location = 1) in vec4 a_color;
layout(location = 2) in vec2 a_texCoord;
layout(location = 3) in float a_texIndex;
@@ -18,7 +18,7 @@ out vec4 v_color;
out vec2 v_texCoord;
void main() {
- gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
+ gl_Position = u_projection * vec4(a_position, 1.0);
v_color = a_color;
v_texCoord = a_texCoord;
}
@@ -42,7 +42,7 @@ void main() {
#pragma vertex wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 17d9cf90b8470378
+// source-hash: 77f2e407b566eb7e
struct gl_PerVertex {
@builtin(position) gl_Position: vec4<f32>,
gl_PointSize: f32,
@@ -70,7 +70,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -86,9 +86,9 @@ var u_albedo_ess: sampler;
var<private> a_texIndex_1: f32;
fn main_1() {
- let _e16 = unnamed_1.u_projection;
- let _e17 = a_position_1;
- unnamed.gl_Position = (_e16 * vec4<f32>(_e17.x, _e17.y, 0f, 1f));
+ let _e15 = unnamed_1.u_projection;
+ let _e16 = a_position_1;
+ unnamed.gl_Position = (_e15 * vec4<f32>(_e16.x, _e16.y, _e16.z, 1f));
let _e23 = a_color_1;
v_color = _e23;
let _e24 = a_texCoord_1;
@@ -97,7 +97,7 @@ fn main_1() {
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
@@ -113,7 +113,7 @@ fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>,
#pragma fragment wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 17d9cf90b8470378
+// source-hash: 77f2e407b566eb7e
struct MaterialConstants {
u_tint: vec4<f32>,
}
diff --git a/desktop/public/scenes/mat-lit-flatnormal/lit-fn.esshader b/desktop/public/scenes/mat-lit-flatnormal/lit-fn.esshader
index 80a3183b9..278e11436 100644
--- a/desktop/public/scenes/mat-lit-flatnormal/lit-fn.esshader
+++ b/desktop/public/scenes/mat-lit-flatnormal/lit-fn.esshader
@@ -4,7 +4,7 @@
#pragma param u_normal texture default(flatnormal)
#pragma vertex
-layout(location = 0) in vec2 a_position;
+layout(location = 0) in vec3 a_position;
layout(location = 1) in vec4 a_color;
layout(location = 2) in vec2 a_texCoord;
layout(location = 3) in float a_texIndex;
@@ -18,10 +18,10 @@ out vec2 v_texCoord;
out highp vec2 v_worldPos;
void main() {
- gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
+ gl_Position = u_projection * vec4(a_position, 1.0);
v_color = a_color;
v_texCoord = a_texCoord;
- v_worldPos = a_position;
+ v_worldPos = a_position.xy;
}
#pragma end
@@ -50,7 +50,7 @@ void main() {
#pragma vertex wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 2109a83ca59fdb20
+// source-hash: 9f6f72d3305a8095
struct gl_PerVertex {
@builtin(position) gl_Position: vec4<f32>,
gl_PointSize: f32,
@@ -75,7 +75,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -90,20 +90,20 @@ var u_normal_ess: sampler;
var<private> a_texIndex_1: f32;
fn main_1() {
- let _e16 = unnamed_1.u_projection;
- let _e17 = a_position_1;
- unnamed.gl_Position = (_e16 * vec4<f32>(_e17.x, _e17.y, 0f, 1f));
+ let _e15 = unnamed_1.u_projection;
+ let _e16 = a_position_1;
+ unnamed.gl_Position = (_e15 * vec4<f32>(_e16.x, _e16.y, _e16.z, 1f));
let _e23 = a_color_1;
v_color = _e23;
let _e24 = a_texCoord_1;
v_texCoord = _e24;
let _e25 = a_position_1;
- v_worldPos = _e25;
+ v_worldPos = _e25.xy;
return;
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
@@ -120,7 +120,7 @@ fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>,
#pragma fragment wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 2109a83ca59fdb20
+// source-hash: 9f6f72d3305a8095
struct Light2D {
posDir: vec4<f32>,
color: vec4<f32>,
diff --git a/desktop/public/scenes/mat-lit-normal/lit-normal.esshader b/desktop/public/scenes/mat-lit-normal/lit-normal.esshader
index 8cab30c0e..d91de9439 100644
--- a/desktop/public/scenes/mat-lit-normal/lit-normal.esshader
+++ b/desktop/public/scenes/mat-lit-normal/lit-normal.esshader
@@ -4,7 +4,7 @@
#pragma param u_normal texture default(white)
#pragma vertex
-layout(location = 0) in vec2 a_position;
+layout(location = 0) in vec3 a_position;
layout(location = 1) in vec4 a_color;
layout(location = 2) in vec2 a_texCoord;
layout(location = 3) in float a_texIndex;
@@ -18,10 +18,10 @@ out vec2 v_texCoord;
out highp vec2 v_worldPos;
void main() {
- gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
+ gl_Position = u_projection * vec4(a_position, 1.0);
v_color = a_color;
v_texCoord = a_texCoord;
- v_worldPos = a_position;
+ v_worldPos = a_position.xy;
}
#pragma end
@@ -50,7 +50,7 @@ void main() {
#pragma vertex wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 60ae4382caf672f0
+// source-hash: f57699ab81142289
struct gl_PerVertex {
@builtin(position) gl_Position: vec4<f32>,
gl_PointSize: f32,
@@ -75,7 +75,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -90,20 +90,20 @@ var u_normal_ess: sampler;
var<private> a_texIndex_1: f32;
fn main_1() {
- let _e16 = unnamed_1.u_projection;
- let _e17 = a_position_1;
- unnamed.gl_Position = (_e16 * vec4<f32>(_e17.x, _e17.y, 0f, 1f));
+ let _e15 = unnamed_1.u_projection;
+ let _e16 = a_position_1;
+ unnamed.gl_Position = (_e15 * vec4<f32>(_e16.x, _e16.y, _e16.z, 1f));
let _e23 = a_color_1;
v_color = _e23;
let _e24 = a_texCoord_1;
v_texCoord = _e24;
let _e25 = a_position_1;
- v_worldPos = _e25;
+ v_worldPos = _e25.xy;
return;
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
@@ -120,7 +120,7 @@ fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>,
#pragma fragment wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 60ae4382caf672f0
+// source-hash: f57699ab81142289
struct Light2D {
posDir: vec4<f32>,
color: vec4<f32>,
diff --git a/desktop/public/scenes/mat-lit/lit.esshader b/desktop/public/scenes/mat-lit/lit.esshader
index 4f37ba460..85b028225 100644
--- a/desktop/public/scenes/mat-lit/lit.esshader
+++ b/desktop/public/scenes/mat-lit/lit.esshader
@@ -3,7 +3,7 @@
#pragma domain Lit2D
#pragma vertex
-layout(location = 0) in vec2 a_position;
+layout(location = 0) in vec3 a_position;
layout(location = 1) in vec4 a_color;
layout(location = 2) in vec2 a_texCoord;
layout(location = 3) in float a_texIndex;
@@ -17,11 +17,11 @@ out vec2 v_texCoord;
out highp vec2 v_worldPos;
void main() {
- gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
+ gl_Position = u_projection * vec4(a_position, 1.0);
v_color = a_color;
v_texCoord = a_texCoord;
// The batch path bakes the transform into the vertices, so a_position is already world-space.
- v_worldPos = a_position;
+ v_worldPos = a_position.xy;
}
#pragma end
@@ -49,7 +49,7 @@ void main() {
#pragma vertex wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 95a1f35f723b831c
+// source-hash: 1c49641c24468584
struct gl_PerVertex {
@builtin(position) gl_Position: vec4<f32>,
gl_PointSize: f32,
@@ -74,7 +74,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -85,20 +85,20 @@ var<uniform> unnamed_2: TimeConstants;
var<private> a_texIndex_1: f32;
fn main_1() {
- let _e14 = unnamed_1.u_projection;
- let _e15 = a_position_1;
- unnamed.gl_Position = (_e14 * vec4<f32>(_e15.x, _e15.y, 0f, 1f));
+ let _e13 = unnamed_1.u_projection;
+ let _e14 = a_position_1;
+ unnamed.gl_Position = (_e13 * vec4<f32>(_e14.x, _e14.y, _e14.z, 1f));
let _e21 = a_color_1;
v_color = _e21;
let _e22 = a_texCoord_1;
v_texCoord = _e22;
let _e23 = a_position_1;
- v_worldPos = _e23;
+ v_worldPos = _e23.xy;
return;
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
@@ -115,7 +115,7 @@ fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>,
#pragma fragment wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 95a1f35f723b831c
+// source-hash: 1c49641c24468584
struct Light2D {
posDir: vec4<f32>,
color: vec4<f32>,
diff --git a/desktop/public/scenes/mat-sw/switched.esshader b/desktop/public/scenes/mat-sw/switched.esshader
index ac02454e8..fdb9607f7 100644
--- a/desktop/public/scenes/mat-sw/switched.esshader
+++ b/desktop/public/scenes/mat-sw/switched.esshader
@@ -4,7 +4,7 @@
#pragma switch USE_GREEN default(off)
#pragma vertex
-layout(location = 0) in vec2 a_position;
+layout(location = 0) in vec3 a_position;
layout(location = 1) in vec4 a_color;
layout(location = 2) in vec2 a_texCoord;
layout(location = 3) in float a_texIndex;
@@ -16,7 +16,7 @@ layout(std140) uniform FrameConstants {
out vec4 v_color;
void main() {
- gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
+ gl_Position = u_projection * vec4(a_position, 1.0);
v_color = a_color;
}
#pragma end
diff --git a/desktop/public/scenes/mat-tex/masked.esshader b/desktop/public/scenes/mat-tex/masked.esshader
index 06fd9d42c..f7562f88f 100644
--- a/desktop/public/scenes/mat-tex/masked.esshader
+++ b/desktop/public/scenes/mat-tex/masked.esshader
@@ -4,7 +4,7 @@
#pragma param u_mask texture default(white)
#pragma vertex
-layout(location = 0) in vec2 a_position;
+layout(location = 0) in vec3 a_position;
layout(location = 1) in vec4 a_color;
layout(location = 2) in vec2 a_texCoord;
layout(location = 3) in float a_texIndex;
@@ -17,7 +17,7 @@ out vec4 v_color;
out vec2 v_texCoord;
void main() {
- gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
+ gl_Position = u_projection * vec4(a_position, 1.0);
v_color = a_color;
v_texCoord = a_texCoord;
}
@@ -41,7 +41,7 @@ void main() {
#pragma vertex wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 70fc4540fdcdb04a
+// source-hash: c6e15c575aa314cc
struct gl_PerVertex {
@builtin(position) gl_Position: vec4<f32>,
gl_PointSize: f32,
@@ -65,7 +65,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -79,9 +79,9 @@ var u_mask_ess: sampler;
var<private> a_texIndex_1: f32;
fn main_1() {
- let _e15 = unnamed_1.u_projection;
- let _e16 = a_position_1;
- unnamed.gl_Position = (_e15 * vec4<f32>(_e16.x, _e16.y, 0f, 1f));
+ let _e14 = unnamed_1.u_projection;
+ let _e15 = a_position_1;
+ unnamed.gl_Position = (_e14 * vec4<f32>(_e15.x, _e15.y, _e15.z, 1f));
let _e22 = a_color_1;
v_color = _e22;
let _e23 = a_texCoord_1;
@@ -90,7 +90,7 @@ fn main_1() {
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
@@ -106,7 +106,7 @@ fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>,
#pragma fragment wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 70fc4540fdcdb04a
+// source-hash: c6e15c575aa314cc
struct TimeConstants {
u_time: vec4<f32>,
u_viewport: vec4<f32>,
diff --git a/desktop/public/scenes/mat-tint/tint.esshader b/desktop/public/scenes/mat-tint/tint.esshader
index f8d67a899..a44463eb8 100644
--- a/desktop/public/scenes/mat-tint/tint.esshader
+++ b/desktop/public/scenes/mat-tint/tint.esshader
@@ -4,7 +4,7 @@
#pragma param u_tint color default(1,1,1,1)
#pragma vertex
-layout(location = 0) in vec2 a_position;
+layout(location = 0) in vec3 a_position;
layout(location = 1) in vec4 a_color;
layout(location = 2) in vec2 a_texCoord;
layout(location = 3) in float a_texIndex;
@@ -17,7 +17,7 @@ out vec4 v_color;
out vec2 v_texCoord;
void main() {
- gl_Position = u_projection * vec4(a_position, 0.0, 1.0);
+ gl_Position = u_projection * vec4(a_position, 1.0);
v_color = a_color;
v_texCoord = a_texCoord;
}
@@ -45,7 +45,7 @@ struct FrameConstants { projection : mat4x4f };
@group(0) @binding(0) var<uniform> frame : FrameConstants;
struct VSIn {
- @location(0) a_position : vec2f,
+ @location(0) a_position : vec3f,
@location(1) a_color : vec4f,
@location(2) a_texCoord : vec2f,
@location(3) a_texIndex : f32,
@@ -58,7 +58,7 @@ struct VSOut {
@vertex fn vs_main(v : VSIn) -> VSOut {
var out : VSOut;
- out.pos = frame.projection * vec4f(v.a_position, 0.0, 1.0);
+ out.pos = frame.projection * vec4f(v.a_position, 1.0);
out.v_color = v.a_color;
out.v_texCoord = v.a_texCoord;
return out;
@@ -84,7 +84,7 @@ struct VSOut {
#pragma vertex wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 56ecfb04e09e8ec6
+// source-hash: 3d59104832a24e44
struct gl_PerVertex {
@builtin(position) gl_Position: vec4<f32>,
gl_PointSize: f32,
@@ -112,7 +112,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -124,9 +124,9 @@ var<uniform> unnamed_3: MaterialConstants;
var<private> a_texIndex_1: f32;
fn main_1() {
- let _e14 = unnamed_1.u_projection;
- let _e15 = a_position_1;
- unnamed.gl_Position = (_e14 * vec4<f32>(_e15.x, _e15.y, 0f, 1f));
+ let _e13 = unnamed_1.u_projection;
+ let _e14 = a_position_1;
+ unnamed.gl_Position = (_e13 * vec4<f32>(_e14.x, _e14.y, _e14.z, 1f));
let _e21 = a_color_1;
v_color = _e21;
let _e22 = a_texCoord_1;
@@ -135,7 +135,7 @@ fn main_1() {
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>, @location(3) a_texIndex: f32) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
@@ -151,7 +151,7 @@ fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>,
#pragma fragment wgsl full
// GENERATED by tools/gen-shader-twins.mjs (glslang + naga) - do not edit.
// Regenerate after changing the GLSL stages above.
-// source-hash: 56ecfb04e09e8ec6
+// source-hash: 3d59104832a24e44
struct MaterialConstants {
u_tint: vec4<f32>,
}
diff --git a/examples/effects-gallery/assets/materials/dissolve.esshader b/examples/effects-gallery/assets/materials/dissolve.esshader
index 9bc908005..4bff50341 100644
--- a/examples/effects-gallery/assets/materials/dissolve.esshader
+++ b/examples/effects-gallery/assets/materials/dissolve.esshader
@@ -70,7 +70,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -81,9 +81,9 @@ var<uniform> unnamed_2: TimeConstants;
var<uniform> unnamed_3: MaterialConstants;
fn main_1() {
- let _e13 = unnamed_1.u_projection;
- let _e14 = a_position_1;
- unnamed.gl_Position = (_e13 * vec4<f32>(_e14.x, _e14.y, 0f, 1f));
+ let _e12 = unnamed_1.u_projection;
+ let _e13 = a_position_1;
+ unnamed.gl_Position = (_e12 * vec4<f32>(_e13.x, _e13.y, _e13.z, 1f));
let _e20 = a_color_1;
v_color = _e20;
let _e21 = a_texCoord_1;
@@ -92,7 +92,7 @@ fn main_1() {
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
diff --git a/examples/effects-gallery/assets/materials/hit-flash.esshader b/examples/effects-gallery/assets/materials/hit-flash.esshader
index ac5fbde90..8ffc53785 100644
--- a/examples/effects-gallery/assets/materials/hit-flash.esshader
+++ b/examples/effects-gallery/assets/materials/hit-flash.esshader
@@ -53,7 +53,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -64,9 +64,9 @@ var<uniform> unnamed_2: TimeConstants;
var<uniform> unnamed_3: MaterialConstants;
fn main_1() {
- let _e13 = unnamed_1.u_projection;
- let _e14 = a_position_1;
- unnamed.gl_Position = (_e13 * vec4<f32>(_e14.x, _e14.y, 0f, 1f));
+ let _e12 = unnamed_1.u_projection;
+ let _e13 = a_position_1;
+ unnamed.gl_Position = (_e12 * vec4<f32>(_e13.x, _e13.y, _e13.z, 1f));
let _e20 = a_color_1;
v_color = _e20;
let _e21 = a_texCoord_1;
@@ -75,7 +75,7 @@ fn main_1() {
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
diff --git a/examples/effects-gallery/assets/materials/outline.esshader b/examples/effects-gallery/assets/materials/outline.esshader
index 98e4d1366..ca9e41027 100644
--- a/examples/effects-gallery/assets/materials/outline.esshader
+++ b/examples/effects-gallery/assets/materials/outline.esshader
@@ -62,7 +62,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -73,9 +73,9 @@ var<uniform> unnamed_2: TimeConstants;
var<uniform> unnamed_3: MaterialConstants;
fn main_1() {
- let _e13 = unnamed_1.u_projection;
- let _e14 = a_position_1;
- unnamed.gl_Position = (_e13 * vec4<f32>(_e14.x, _e14.y, 0f, 1f));
+ let _e12 = unnamed_1.u_projection;
+ let _e13 = a_position_1;
+ unnamed.gl_Position = (_e12 * vec4<f32>(_e13.x, _e13.y, _e13.z, 1f));
let _e20 = a_color_1;
v_color = _e20;
let _e21 = a_texCoord_1;
@@ -84,7 +84,7 @@ fn main_1() {
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
diff --git a/examples/effects-gallery/assets/materials/pixelate.esshader b/examples/effects-gallery/assets/materials/pixelate.esshader
index 537419ce9..1520dd112 100644
--- a/examples/effects-gallery/assets/materials/pixelate.esshader
+++ b/examples/effects-gallery/assets/materials/pixelate.esshader
@@ -50,7 +50,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -61,9 +61,9 @@ var<uniform> unnamed_2: TimeConstants;
var<uniform> unnamed_3: MaterialConstants;
fn main_1() {
- let _e13 = unnamed_1.u_projection;
- let _e14 = a_position_1;
- unnamed.gl_Position = (_e13 * vec4<f32>(_e14.x, _e14.y, 0f, 1f));
+ let _e12 = unnamed_1.u_projection;
+ let _e13 = a_position_1;
+ unnamed.gl_Position = (_e12 * vec4<f32>(_e13.x, _e13.y, _e13.z, 1f));
let _e20 = a_color_1;
v_color = _e20;
let _e21 = a_texCoord_1;
@@ -72,7 +72,7 @@ fn main_1() {
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
diff --git a/examples/effects-gallery/assets/materials/uv-scroll.esshader b/examples/effects-gallery/assets/materials/uv-scroll.esshader
index 91d7e065c..ed6fb7682 100644
--- a/examples/effects-gallery/assets/materials/uv-scroll.esshader
+++ b/examples/effects-gallery/assets/materials/uv-scroll.esshader
@@ -51,7 +51,7 @@ struct VertexOutput {
var<private> unnamed: gl_PerVertex = gl_PerVertex(vec4<f32>(0f, 0f, 0f, 1f), 1f);
@group(0) @binding(0)
var<uniform> unnamed_1: FrameConstants;
-var<private> a_position_1: vec2<f32>;
+var<private> a_position_1: vec3<f32>;
var<private> v_color: vec4<f32>;
var<private> a_color_1: vec4<f32>;
var<private> v_texCoord: vec2<f32>;
@@ -62,9 +62,9 @@ var<uniform> unnamed_2: TimeConstants;
var<uniform> unnamed_3: MaterialConstants;
fn main_1() {
- let _e13 = unnamed_1.u_projection;
- let _e14 = a_position_1;
- unnamed.gl_Position = (_e13 * vec4<f32>(_e14.x, _e14.y, 0f, 1f));
+ let _e12 = unnamed_1.u_projection;
+ let _e13 = a_position_1;
+ unnamed.gl_Position = (_e12 * vec4<f32>(_e13.x, _e13.y, _e13.z, 1f));
let _e20 = a_color_1;
v_color = _e20;
let _e21 = a_texCoord_1;
@@ -73,7 +73,7 @@ fn main_1() {
}
@vertex
-fn vs_main(@location(0) a_position: vec2<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
+fn vs_main(@location(0) a_position: vec3<f32>, @location(1) a_color: vec4<f32>, @location(2) a_texCoord: vec2<f32>) -> VertexOutput {
a_position_1 = a_position;
a_color_1 = a_color;
a_texCoord_1 = a_texCoord;
diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cpp
index f0bab1c31..84f90af84 100644
--- a/src/esengine/resource/ShaderParser.cpp
+++ b/src/esengine/resource/ShaderParser.cpp
@@ -121,18 +121,18 @@ std::string canonical2DVertexStageWGSL(bool lit) {
src +=
"\n"
"struct VSIn {\n"
- " @location(0) a_position : vec2f,\n"
+ " @location(0) a_position : vec3f,\n"
" @location(1) a_color : vec4f,\n"
" @location(2) a_texCoord : vec2f,\n"
"};\n"
"\n"
"@vertex fn vs_main(v : VSIn) -> VSOut {\n"
" var out : VSOut;\n"
- " out.pos = frame.projection * vec4f(v.a_position, 0.0, 1.0);\n"
+ " out.pos = frame.projection * vec4f(v.a_position, 1.0);\n"
" out.v_color = v.a_color;\n"
" out.v_texCoord = v.a_texCoord;\n";
if (lit) {
- src += " out.v_worldPos = v.a_position;\n";
+ src += " out.v_worldPos = v.a_position.xy;\n";
}
src +=
" return out;\n"
@@ -189,7 +189,7 @@ std::string canonicalPPVertexStage() {
// world transform into the vertices, so all 2D shaders share this pass-through.
std::string canonical2DVertexStage(bool lit) {
std::string src =
- "layout(location = 0) in vec2 a_position;\n"
+ "layout(location = 0) in vec3 a_position;\n"
"layout(location = 1) in vec4 a_color;\n"
"layout(location = 2) in vec2 a_texCoord;\n"
"\n"
@@ -205,11 +205,11 @@ std::string canonical2DVertexStage(bool lit) {
src +=
"\n"
"void main() {\n"
- " gl_Position = u_projection * vec4(a_position, 0.0, 1.0);\n"
+ " gl_Position = u_projection * vec4(a_position, 1.0);\n"
" v_color = a_color;\n"
" v_texCoord = a_texCoord;\n";
if (lit) {
- src += " v_worldPos = a_position;\n";
+ src += " v_worldPos = a_position.xy;\n";
}
src += "}\n";
return src;