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
+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