feat: carve Jajce river into terrain
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
class_name JajceWatercourse
|
||||
extends RefCounted
|
||||
|
||||
const WATERFALL_CENTER := Vector2(25.0, -24.0)
|
||||
const SHELF_TOP_HEIGHT := 12.4
|
||||
const UPPER_STREAM_START_Z := -58.0
|
||||
const UPPER_STREAM_END_Z := -25.0
|
||||
const PLUNGE_POOL_CENTER := Vector2(25.0, -19.5)
|
||||
const PLUNGE_POOL_BED_HEIGHT := -0.65
|
||||
const DOWNSTREAM_START_Z := -20.0
|
||||
const DOWNSTREAM_END_Z := 42.0
|
||||
const WATER_SURFACE_OFFSET := 0.32
|
||||
|
||||
|
||||
static func downstream_progress(world_z: float) -> float:
|
||||
return clampf(inverse_lerp(DOWNSTREAM_START_Z, DOWNSTREAM_END_Z, world_z), 0.0, 1.0)
|
||||
|
||||
|
||||
static func downstream_center_x(world_z: float) -> float:
|
||||
var progress := downstream_progress(world_z)
|
||||
var downstream_curve := smoothstep(0.58, 1.0, progress) * 12.0
|
||||
return WATERFALL_CENTER.x + sin(progress * TAU) * 1.4 + downstream_curve
|
||||
|
||||
|
||||
static func downstream_half_width(world_z: float) -> float:
|
||||
var progress := downstream_progress(world_z)
|
||||
var base_width := lerpf(4.8, 3.8, smoothstep(0.0, 0.62, progress))
|
||||
return base_width + smoothstep(0.78, 1.0, progress) * 0.8
|
||||
|
||||
|
||||
static func downstream_bed_height(world_z: float) -> float:
|
||||
return lerpf(-0.55, -1.3, downstream_progress(world_z))
|
||||
|
||||
|
||||
static func upper_stream_progress(world_z: float) -> float:
|
||||
return clampf(inverse_lerp(UPPER_STREAM_START_Z, UPPER_STREAM_END_Z, world_z), 0.0, 1.0)
|
||||
|
||||
|
||||
static func upper_stream_center_x(world_z: float) -> float:
|
||||
var progress := upper_stream_progress(world_z)
|
||||
return WATERFALL_CENTER.x + sin(progress * PI * 1.6) * 0.9
|
||||
|
||||
|
||||
static func upper_stream_half_width(world_z: float) -> float:
|
||||
return lerpf(2.8, 4.4, smoothstep(0.55, 1.0, upper_stream_progress(world_z)))
|
||||
|
||||
|
||||
static func upper_stream_bed_height(world_z: float) -> float:
|
||||
return lerpf(11.55, 11.15, upper_stream_progress(world_z))
|
||||
Reference in New Issue
Block a user