feat(render3d): the grass knows a body is standing in it
You walked through a meadow and every blade ignored you, which is the most noticeable thing missing from every step the game asks you to take. u_push (x, z, radius) bends blades away from a body and DOWN - a trodden stem is shorter as well as leaning, and leaving the height alone made them splay outward like a fan instead of being walked through. Applied after the blade's own yaw has put it into world axes and before it is tipped onto the ground normal, so the push is a world direction rather than something in the blade's private frame. Radius 0 means nobody is there, so nothing is paid for when it does not apply. Measured: GL 6.9 s, VK 7.3 s over 400 frames, unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
9dff8f21bd
commit
6169cd05b9
5 changed files with 45 additions and 17 deletions
|
|
@ -15,6 +15,13 @@ var grass_prog: int = 0
|
|||
var grass_mesh: Mesh = null
|
||||
var grass_on: bool = true
|
||||
var grass_wind: int = 0
|
||||
# Where a body is standing, and how wide it pushes. The grass has never known the player was
|
||||
# in it: you walked through a meadow and every blade ignored you, which is the single most
|
||||
# noticeable thing missing from every step the game asks you to take. The game sets this each
|
||||
# frame; radius 0 means nobody is there.
|
||||
var grass_push_x: int = 0
|
||||
var grass_push_z: int = 0
|
||||
var grass_push_r: int = 0
|
||||
var grass_s0: int = 0 # float bits: blade spacing at the camera (m)
|
||||
var grass_d0: int = 0 # the distance at which the spacing has doubled (m)
|
||||
var grass_radius: int = 0 # no blades past this (m)
|
||||
|
|
@ -174,6 +181,7 @@ function grass_draw() -> void {
|
|||
u_mat4(gpu_uniform(p, "u_proj"), cam_proj)
|
||||
u_mat4(gpu_uniform(p, "u_vp"), cam_vp_clean)
|
||||
u_f(gpu_uniform(p, "u_wind"), grass_wind)
|
||||
u_f3(gpu_uniform(p, "u_push"), grass_push_x, grass_push_z, grass_push_r)
|
||||
u_f(gpu_uniform(p, "u_rough_scale"), F_ONE)
|
||||
u_v3(gpu_uniform(p, "u_tint"), sc_blade_tint)
|
||||
u_v3(gpu_uniform(p, "u_blade_base"), sc_blade_base)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue