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(water): the albedo lines of the water shader go back inside its source, where a misplaced edit left them as top-level script that stopped every export from loading

yhh1592e8442d18
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 253b5489e..9b68e7e32 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -31,6 +31,7 @@ env:
test_registry_ondestroy test_view_api_matrix
test_hierarchy_links test_entity_activity test_transform_traversal test_ui_tree test_tween_activity test_springbone
test_shader_device test_draw_params test_per_draw_blocks test_texture_fb test_buffer_device
+ test_frame_pacer test_packaged_config test_mapped_file test_sdf_generator
test_compressed_format test_batch_builder test_skeletal_batch_color test_boundary_span test_webgpu_device
test_clip_depth test_planar_reflection test_sort_key test_retained_text test_sprite_mask_range test_sprite_draw_mode test_shadow_atlas test_particle_shapes test_lod_selection test_billboard_facing test_impostor_frames test_view_shading test_mesh_edges test_hdr_format test_probe_store test_occlusion_view test_reflection_store test_tiled_lights test_light_layers test_shadow_channels
test_text_edit test_render_graph test_device_loss test_physics_interpolation
diff --git a/sdk/src/water/waterShader.ts b/sdk/src/water/waterShader.ts
index daf8f4f1e..b110b40c6 100644
--- a/sdk/src/water/waterShader.ts
+++ b/sdk/src/water/waterShader.ts
@@ -334,6 +334,8 @@ in highp vec3 v_worldXYZ;
#ifdef ES_GBUFFER
layout(location = 0) out vec4 fragColor;
layout(location = 1) out vec4 fragSurface;
+// The surface's diffuse colour, for light an effect adds after this pass (bounce light): alpha 1 is "written".
+layout(location = 2) out vec4 fragAlbedo;
vec2 packNormal(vec3 n) {
n /= (abs(n.x) + abs(n.y) + abs(n.z));
@@ -341,8 +343,6 @@ vec2 packNormal(vec3 n) {
vec2 e = n.z >= 0.0 ? n.xy : (1.0 - abs(n.yx)) * sgn;
return e * 0.5 + 0.5;
}
-// The surface's diffuse colour, for light an effect adds after this pass (bounce light): alpha 1 is "written".
-layout(location = 2) out vec4 fragAlbedo;
#else
out vec4 fragColor;
#endif
@@ -799,6 +799,7 @@ void main() {
#ifdef ES_GBUFFER
// 0.72: a surface, and water (see readSurface): what lands on it is the water's, not a wet floor's.
fragSurface = vec4(packNormal(normalize(N)), roughness, 0.72);
+ fragAlbedo = vec4(0.0);
#endif
}
#pragma end
@@ -808,11 +809,11 @@ void main() {
struct FragOut {
@location(0) color : vec4f,
@location(1) surface : vec4f,
+ @location(2) albedo : vec4f,
};
fn packNormal(n : vec3f) -> vec2f {
let a = n / (abs(n.x) + abs(n.y) + abs(n.z));
- fragAlbedo = vec4(0.0);
let sgn = vec2f(select(-1.0, 1.0, a.x >= 0.0), select(-1.0, 1.0, a.y >= 0.0));
var e = a.xy;
if (a.z < 0.0) { e = (vec2f(1.0) - abs(a.yx)) * sgn; }
@@ -822,7 +823,6 @@ fn packNormal(n : vec3f) -> vec2f {
fn waterHash(p0 : vec2f) -> f32 {
var p = fract(p0 * vec2f(0.1031, 0.1030));
- @location(2) albedo : vec4f,
p = p + dot(p, p.yx + 33.33);
return fract((p.x + p.y) * p.x);
}
@@ -1266,6 +1266,7 @@ fn waterSurface(p : vec2f, time : f32, dist : f32, amp : f32, calm : f32) -> vec
var frag : FragOut;
frag.color = vec4f(color, alpha);
frag.surface = vec4f(packNormal(normalize(N)), roughness, 0.72);
+ frag.albedo = vec4f(0.0);
return frag;
#else
return vec4f(color, alpha);
@@ -1276,4 +1277,3 @@ fn waterSurface(p : vec2f, time : f32, dist : f32, amp : f32, calm : f32) -> vec
export const WATER_SHADER_TEMPLATE = makeBuiltinShaderTemplate('water', 'Water',
'Waves, refraction, reflection, depth absorption and foam for a horizontal body of water.', WATER);
- frag.albedo = vec4f(0.0);
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 92135a1e7..a1ed7d6de 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -3856,4 +3856,6 @@ export const NOTED = {
{"note":"Voxel GI no longer changes with the size of the picture."},
"fix(native): a packaged game's colour space, output transform, MSAA, quality, layers and camera fit reach a native host, so a linear project is no longer far too dark":
{"note":"A linear project on a native build is no longer far too dark."},
+ "fix(water): the albedo lines of the water shader go back inside its source, where a misplaced edit left them as top-level script that stopped every export from loading":
+ {"internal":"broke after 0.98.0 and before any release, so no creator ever had it"},
};