feat: 更新 IntoHole 的球体、滑槽和环境资产

- 为铁球、陶瓷球和木球制作风格化材质,归档 CC0 原始参考
- 更新方形球洞和实心滑槽,统一 90° 弯槽并兼容旧存档
- 用顺流泡沫表示水流方向,为冰块制作三种交错的裂纹
- 同步 Blender 源资产、Godot 加载、工坊和试玩预览
This commit is contained in:
Yanchen
2026-11-19 16:18:41 +08:00
parent 39ff1fd7b4
commit d1141b04c7
467 changed files with 67228 additions and 44624 deletions
+27
View File
@@ -0,0 +1,27 @@
extends RefCounted
const ALTERNATE_TEXTURES := [
preload("res://assets/blocks/ice/textures/top_albedo_diagonal.png"),
preload("res://assets/blocks/ice/textures/top_albedo_forked.png"),
]
const TOP_MATERIAL := "Storybook / ice top"
static var overrides: Dictionary[Texture2D, StandardMaterial3D] = {}
static func apply(visual: Node3D, location: Vector3) -> void:
# X/Z grid neighbors differ by one or two steps in the three-pattern cycle.
var pattern := posmod(roundi(location.x) + 2 * roundi(location.z), 3)
if pattern == 0:
return
var texture: Texture2D = ALTERNATE_TEXTURES[pattern - 1]
for node in visual.find_children("*", "MeshInstance3D", true, false):
var mesh_view := node as MeshInstance3D
for index in range(mesh_view.mesh.get_surface_count()):
var source := mesh_view.mesh.surface_get_material(index) as StandardMaterial3D
if source != null and source.resource_name == TOP_MATERIAL:
if not overrides.has(texture):
var material := source.duplicate() as StandardMaterial3D
material.albedo_texture = texture
overrides[texture] = material
mesh_view.set_surface_override_material(index, overrides[texture])
return
+1
View File
@@ -0,0 +1 @@
uid://cceffvenadusk
+35
View File
@@ -0,0 +1,35 @@
extends Node3D
# One collision event, measured in N*s; do not sum resting support over time.
const BREAK_IMPULSE := 1000.0
const MIN_APPROACH_SPEED := 0.5
var broken := false
var events: Array=[]
var peak_impulse := 0.0
var pending_break := false
func receive_impact(ball_id: String, impulse: float, approach: float) -> void:
if broken or pending_break or approach<MIN_APPROACH_SPEED:return
peak_impulse=maxf(peak_impulse,impulse)
var should_break:=impulse>=BREAK_IMPULSE
events.append({"ballId":ball_id,"normalImpulseNs":impulse,"approachSpeedMps":approach,
"thresholdNs":BREAK_IMPULSE,"breaks":should_break,"tick":Engine.get_physics_frames()})
if should_break:
pending_break=true
call_deferred("break_block")
func set_solids(node: Node, enabled: bool) -> void:
if node is StaticBody3D:
node.collision_layer=1 if enabled else 0
node.collision_mask=2 if enabled else 0
for child in node.get_children():set_solids(child,enabled)
func break_block() -> void:
broken=true;pending_break=false
set_solids(self,false)
# Visual shards are deliberately not additional dynamic physics objects.
hide()
func reset_block() -> void:
broken=false;pending_break=false;events.clear();peak_impulse=0
set_solids(self,true);show()
+1
View File
@@ -0,0 +1 @@
uid://gikvxj5eoy8f
Binary file not shown.
+45
View File
@@ -0,0 +1,45 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://cealspaapi3wr"
path="res://.godot/imported/model.glb-c7b9a7e8048912184e349a28d0afc078.scn"
[deps]
source_file="res://assets/blocks/ice/model.glb"
dest_files=["res://.godot/imported/model.glb-c7b9a7e8048912184e349a28d0afc078.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
mesh_library/use_node_names_as_mesh_names=false
array_mesh/deduplicate_surfaces=true
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
gltf/texture_map_mode=1
Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

@@ -0,0 +1,43 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b333t84ol1tjc"
path="res://.godot/imported/model_side_albedo.png-cc8d99ee30be1453a467ecd7ec028299.ctex"
metadata={
"vram_texture": false
}
generator_parameters={
"md5": "675ed44edaeb3797b77307376a3fc7d8"
}
[deps]
source_file="res://assets/blocks/ice/model_side_albedo.png"
dest_files=["res://.godot/imported/model_side_albedo.png-cc8d99ee30be1453a467ecd7ec028299.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

@@ -0,0 +1,43 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ca1pi33ncjm7j"
path="res://.godot/imported/model_top_albedo.png-8462eb5c935926c77ff3218b3b220b3f.ctex"
metadata={
"vram_texture": false
}
generator_parameters={
"md5": "d9b2c32e4399609dfc75440a7284ed56"
}
[deps]
source_file="res://assets/blocks/ice/model_top_albedo.png"
dest_files=["res://.godot/imported/model_top_albedo.png-8462eb5c935926c77ff3218b3b220b3f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
View File
+6
View File
@@ -0,0 +1,6 @@
"""Build only this block through the shared asset authoring code."""
from pathlib import Path
import runpy
ROOT = Path(__file__).resolve().parents[4]
runpy.run_path(str(ROOT / "assets/collections/storybook/source/build.py"),
init_globals={"ONLY_ASSET": "ice"}, run_name="__main__")
+143
View File
@@ -0,0 +1,143 @@
"""Bake the storybook ice color maps and bind them to the existing cube."""
import struct
import zlib
from pathlib import Path
import bpy
import numpy as np
ASSET = Path(__file__).resolve().parents[1]
REFERENCES = ASSET.parents[2] / 'references/materials/ice/textures'
SIZE = 512
CRACK_PATTERNS = {
'top_albedo.png': (
([(0.0, .34), (.26, .42), (.40, .60), (.68, .54), (.92, .73)], .019),
([(.40, .60), (.44, .77), (.35, .94)], .011),
([(.68, .54), (.74, .32), (.89, .21)], .012),
),
'top_albedo_diagonal.png': (
([(.10, .86), (.28, .68), (.34, .49), (.57, .36), (.64, .16), (.79, .08)], .018),
([(.34, .49), (.21, .40), (.08, .39)], .011),
([(.57, .36), (.73, .48), (.92, .46)], .012),
),
'top_albedo_forked.png': (
([(.63, .04), (.57, .23), (.65, .39), (.49, .57), (.54, .76), (.44, .93)], .018),
([(.57, .23), (.39, .28), (.29, .18)], .011),
([(.65, .39), (.80, .40), (.92, .52)], .012),
([(.49, .57), (.30, .61), (.23, .79)], .010),
),
}
def mix(image, color, weight):
return image + (np.asarray(color) - image) * np.expand_dims(weight, -1)
def ramp(low, high, value):
t = np.clip((value - low) / (high - low), 0, 1)
return t * t * (3 - 2 * t)
def stroke(u, v, points, width):
distance = np.full_like(u, np.inf)
for (ax, ay), (bx, by) in zip(points, points[1:]):
dx, dy = bx - ax, by - ay
along = np.clip(((u - ax) * dx + (v - ay) * dy) / (dx * dx + dy * dy), 0, 1)
distance = np.minimum(distance, np.hypot(u - ax - along * dx, v - ay - along * dy))
return 1 - ramp(width * 0.48, width, distance)
def reference_tone(path):
resolution = 16
image = bpy.data.images.load(str(REFERENCES / path), check_existing=False)
image.scale(resolution, resolution)
pixels = np.empty(resolution * resolution * 4, dtype=np.float32)
image.pixels.foreach_get(pixels)
bpy.data.images.remove(image)
tone = pixels.reshape(resolution, resolution, 4)[:, :, :3].mean(axis=2)
tone = (tone - tone.mean()) / max(tone.std(), 0.001)
grid = np.arange(resolution)
coordinates = np.linspace(0, resolution - 1, SIZE)
rows = [np.interp(coordinates, grid, row) for row in tone]
return np.stack([np.interp(coordinates, grid, column) for column in np.asarray(rows).T], axis=1)
def save_color(name, color):
path = ASSET / 'textures' / name
path.parent.mkdir(parents=True, exist_ok=True)
# PNG scanlines run top-down, whereas UV V starts at the bottom.
rgb = np.clip(np.rint(color[::-1] * 255), 0, 255).astype(np.uint8)
scanlines = b''.join(b'\x00' + row.tobytes() for row in rgb)
def chunk(kind, payload):
return (struct.pack('!I', len(payload)) + kind + payload
+ struct.pack('!I', zlib.crc32(kind + payload)))
header = struct.pack('!IIBBBBB', SIZE, SIZE, 8, 2, 0, 0, 0)
path.write_bytes(b'\x89PNG\r\n\x1a\n' + chunk(b'IHDR', header)
+ chunk(b'IDAT', zlib.compress(scanlines, 9)) + chunk(b'IEND', b''))
def bake_color_maps():
samples = (np.arange(SIZE) + 0.5) / SIZE
u, v = np.meshgrid(samples, samples)
lake = reference_tone('ambientcg-ice003/Ice003_1K-JPG_Color.jpg')
frost = reference_tone('ambientcg-ice002/Ice002_1K-JPG_Color.jpg')
blue = reference_tone('oga-y2k/y2k_ice_texture.png')
top = mix((.44, .65, .75), (.54, .73, .81), ramp(-1.5, 1.6, lake))
facet = ramp(.42, .45, u * .55 + v * .82) * (1 - ramp(.76, .80, u * .55 + v * .82))
top = mix(top, (.67, .81, .87), facet * .33)
edge = np.minimum(np.minimum(u, 1 - u), np.minimum(v, 1 - v))
top = mix(top, (.86, .95, .94), (1 - ramp(.025, .14, edge + frost * .022)) * .73)
# Broken, angular highlight strokes hint at cracks just below the surface.
for filename, pattern in CRACK_PATTERNS.items():
painted_top = top
for points, width in pattern:
dark_lip = [(x, y - .019) for x, y in points]
painted_top = mix(painted_top, (.27, .55, .69), stroke(u, v, dark_lip, width) * .37)
painted_top = mix(painted_top, (.85, .94, .97), stroke(u, v, points, width) * .72)
save_color(filename, painted_top)
side = mix((.31, .49, .64), (.51, .69, .78), ramp(.05, 1.05, v + blue * .10))
icy_band = np.exp(-((v - (.82 + .05 * np.sin(7 * u))) / .064) ** 2)
side = mix(side, (.79, .92, .94), icy_band * .72)
streak = stroke(u, v, [(.07, .42), (.32, .59), (.58, .51), (.94, .67)], .019)
side = mix(side, (.74, .90, .94), streak * .64)
for x, y, size in [(.18, .65, .029), (.37, .31, .016), (.72, .42, .024), (.81, .25, .013)]:
bubble = np.hypot(u - x, (v - y) * .82) / size
edge = ramp(.49, .77, bubble) * (1 - ramp(.81, 1.1, bubble))
side = mix(side, (.77, .92, .95), edge * .62)
save_color('side_albedo.png', side)
def apply_ice_surface(obj, side, top):
uv = obj.data.uv_layers.new(name='Ice faces')
for polygon in obj.data.polygons:
for loop_index in polygon.loop_indices:
point = obj.data.vertices[obj.data.loops[loop_index].vertex_index].co
if abs(polygon.normal.z) > 0.5:
uv.uv[loop_index].vector = (point.x + 0.5, point.y + 0.5)
elif abs(polygon.normal.x) > 0.5:
uv.uv[loop_index].vector = (0.5 + point.y * polygon.normal.x, point.z)
else:
uv.uv[loop_index].vector = (0.5 - point.x * polygon.normal.y, point.z)
for material, file, roughness in ((side, 'side_albedo.png', .27), (top, 'top_albedo.png', .28)):
image = bpy.data.images.load(str(ASSET / 'textures' / file), check_existing=False)
image.colorspace_settings.name = 'sRGB'
image.pack()
texture = material.node_tree.nodes.new('ShaderNodeTexImage')
texture.image = image
texture.label = "Baked ice color"
texture.extension = 'EXTEND'
texture.location = (-420, 240)
shader = material.node_tree.nodes.get('Principled BSDF')
shader.inputs['Roughness'].default_value = roughness
material.node_tree.links.new(texture.outputs['Color'], shader.inputs['Base Color'])
if __name__ == '__main__':
bake_color_maps()
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b54o021h5utjc"
path="res://.godot/imported/side_albedo.png-963130ae016ca2c9fdacec22c8083a03.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/blocks/ice/textures/side_albedo.png"
dest_files=["res://.godot/imported/side_albedo.png-963130ae016ca2c9fdacec22c8083a03.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c5doqepwm5lq8"
path="res://.godot/imported/top_albedo.png-a33d5a5f3176baa32409ae18b5406d5f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/blocks/ice/textures/top_albedo.png"
dest_files=["res://.godot/imported/top_albedo.png-a33d5a5f3176baa32409ae18b5406d5f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dad3qnhp5gnew"
path="res://.godot/imported/top_albedo_diagonal.png-9f83c91038a8a31954116876f1728b1c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/blocks/ice/textures/top_albedo_diagonal.png"
dest_files=["res://.godot/imported/top_albedo_diagonal.png-9f83c91038a8a31954116876f1728b1c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b8g0ndalcro1s"
path="res://.godot/imported/top_albedo_forked.png-5e11afae8b5f5dbcd695da011563d83f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/blocks/ice/textures/top_albedo_forked.png"
dest_files=["res://.godot/imported/top_albedo_forked.png-5e11afae8b5f5dbcd695da011563d83f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
+62
View File
@@ -0,0 +1,62 @@
extends Node3D
# Fixed game rule. No exported/per-instance speed or level override.
const FLOW_SPEED := 5.0
const DENSITY := 1000.0
const DRAG_COEFFICIENT := 0.47
var bounds := AABB()
var local_direction := Vector3.RIGHT
func _ready() -> void:
add_to_group("water_blocks")
func flow_velocity() -> Vector3:
return (global_basis * local_direction).normalized() * FLOW_SPEED
func world_bounds() -> AABB:
return global_transform * bounds
# Integrate vertical sphere columns against the UNION of nearby water cells.
# Exact vertical intervals, normalized horizontal quadrature: no seam collision,
# no doubled buoyancy in overlapping cells, and continuous partial immersion.
static func sample(center: Vector3, radius: float, blocks: Array) -> Dictionary:
var nearby: Array=[]
for block in blocks:
var box: AABB=block.world_bounds()
if box.grow(radius).has_point(center):nearby.append({"box":box,"velocity":block.flow_velocity()})
if nearby.is_empty():return {"fraction":0.0,"velocity":Vector3.ZERO}
var total:=0.0
var immersed:=0.0
var flow:=Vector3.ZERO
const SAMPLES := 12
for x in range(SAMPLES):
for z in range(SAMPLES):
var dx:=radius*((x+.5)*2/SAMPLES-1)
var dz:=radius*((z+.5)*2/SAMPLES-1)
var square:=radius*radius-dx*dx-dz*dz
if square<=0:continue
var half:=sqrt(square)
total+=2*half
var intervals: Array=[]
var edges: Array=[]
for water in nearby:
var box: AABB=water.box
var px:=center.x+dx;var pz:=center.z+dz
if px<box.position.x or px>=box.end.x or pz<box.position.z or pz>=box.end.z:continue
var low:=maxf(center.y-half,box.position.y)
var high:=minf(center.y+half,box.end.y)
if high<=low:continue
intervals.append({"low":low,"high":high,"velocity":water.velocity})
edges.append(low);edges.append(high)
edges.sort()
for i in range(edges.size()-1):
var length: float=edges[i+1]-edges[i]
if length<=0:continue
var midpoint: float=(edges[i+1]+edges[i])*.5
var velocity:=Vector3.ZERO;var count:=0
for interval in intervals:
if midpoint>=interval.low and midpoint<interval.high:
velocity+=interval.velocity;count+=1
if count>0:
immersed+=length;flow+=velocity/count*length
return {"fraction":clampf(immersed/total,0,1),"velocity":flow/immersed if immersed>0 else Vector3.ZERO}
+1
View File
@@ -0,0 +1 @@
uid://bey2xn6l6l4n0
Binary file not shown.
+45
View File
@@ -0,0 +1,45 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://i0s5sv81yqmg"
path="res://.godot/imported/model.glb-1c09ff60726251c5b1b0129f9ed81873.scn"
[deps]
source_file="res://assets/blocks/water/model.glb"
dest_files=["res://.godot/imported/model.glb-1c09ff60726251c5b1b0129f9ed81873.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/root_script=null
mesh_library/use_node_names_as_mesh_names=false
array_mesh/deduplicate_surfaces=true
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_name_suffixes=true
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
materials/extract=0
materials/extract_format=0
materials/extract_path=""
_subresources={}
gltf/naming_version=2
gltf/embedded_image_handling=1
gltf/texture_map_mode=1
+6
View File
@@ -0,0 +1,6 @@
"""Build only this block through the shared asset authoring code."""
from pathlib import Path
import runpy
ROOT = Path(__file__).resolve().parents[4]
runpy.run_path(str(ROOT / "assets/collections/storybook/source/build.py"),
init_globals={"ONLY_ASSET": "water"}, run_name="__main__")
Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
extends RefCounted
const SHADER := preload("res://assets/blocks/water/surface.gdshader")
static var materials_by_direction: Dictionary[Vector3, ShaderMaterial] = {}
static func apply(visual: Node3D, local_direction: Vector3) -> void:
if not materials_by_direction.has(local_direction):
var material := ShaderMaterial.new()
material.shader = SHADER
material.set_shader_parameter("local_flow_direction", local_direction)
materials_by_direction[local_direction] = material
var surface := materials_by_direction[local_direction]
for node in visual.find_children("*", "MeshInstance3D", true, false):
var mesh_view := node as MeshInstance3D
for index in range(mesh_view.mesh.get_surface_count()):
var source := mesh_view.mesh.surface_get_material(index)
if source != null and source.resource_name.ends_with("water_surface"):
mesh_view.set_surface_override_material(index, surface)
+1
View File
@@ -0,0 +1 @@
uid://bvuxde78w5evh
+56
View File
@@ -0,0 +1,56 @@
shader_type spatial;
render_mode unshaded, shadows_disabled;
uniform vec3 local_flow_direction = vec3(1.0, 0.0, 0.0);
uniform vec4 water_tint : source_color = vec4(0.25, 0.68, 0.75, 0.55);
uniform vec4 foam_tint : source_color = vec4(0.88, 0.98, 0.95, 0.93);
varying vec2 world_xz;
varying vec2 downstream;
void vertex() {
world_xz = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xz;
downstream = normalize((MODEL_MATRIX * vec4(local_flow_direction, 0.0)).xz);
}
float cell_random(vec2 cell) {
vec3 p = fract(cell.xyx * vec3(0.1031, 0.1030, 0.0973));
p += dot(p, p.yzx + 33.33);
return fract((p.x + p.y) * p.z);
}
float foam_strokes(vec2 stream) {
// World-space lanes carry irregular strokes across same-direction tiles.
// The lateral offset between lanes keeps them from forming rows of dots.
vec2 cell_size = vec2(0.52, 0.25);
vec2 grid = stream / cell_size;
grid.x += cell_random(vec2(floor(grid.y), 4.8));
vec2 cell = floor(grid);
vec2 center = vec2(
mix(0.32, 0.68, cell_random(cell + vec2(1.4, 0.0))),
mix(0.3, 0.7, cell_random(cell + vec2(0.0, 6.2)))
);
vec2 offset = (fract(grid) - center) * cell_size;
float half_length = mix(0.062, 0.147, cell_random(cell + vec2(7.3, 3.2)));
float width = mix(0.015, 0.032, cell_random(cell + vec2(4.7, 8.2)));
float along = offset.x / half_length;
float curve = 0.013 * (along * along - 0.5);
float taper = mix(0.5, 1.0, smoothstep(-0.85, 0.48, along));
float dist = length(vec2(along, (offset.y - curve) / (width * taper)));
float edge = clamp(fwidth(dist), 0.11, 0.5);
float brightness = mix(0.52, 1.0, cell_random(cell + vec2(3.5, 0.0)));
return (1.0 - smoothstep(0.92 - edge, 0.92 + edge, dist)) * brightness;
}
void fragment() {
vec2 across = vec2(-downstream.y, downstream.x);
vec2 stream = vec2(dot(world_xz, downstream), dot(world_xz, across));
// Presentation speed gives the eye time to follow one stroke across a tile.
// Water contact forces are defined independently in behavior.gd.
float foam = foam_strokes(stream - vec2(TIME * 0.94, 0.0));
float ripple = sin(stream.x * 14.0 + sin(stream.y * 15.0) - TIME * 2.3);
float ripple_highlight = smoothstep(0.4, 0.97, ripple) * 0.11;
vec3 water_color = mix(water_tint.rgb, foam_tint.rgb, ripple_highlight);
ALBEDO = mix(water_color, foam_tint.rgb, foam);
ALPHA = mix(water_tint.a, foam_tint.a, foam);
}
+1
View File
@@ -0,0 +1 @@
uid://bbhuaekghhu6