render3d: a grass kind - the GPU blades' per-kind numbers are a GrassKind record the game hands over (grass_kind_set), not constants
GrassKind (grass_kind.ludic) carries what grass.ludic, grass_gpu.ludic, grass.vert, grass_cull.comp and model.frag's BLADE path held as constants: the cell, s0 / d0 / radius, the row bands and rows, the blade profile (neck, root, swell, tip, bend), the heights, clumps, widths and arch, where it grows (slope, snow, the photograph's test), the root / tip / gone-to-seed colours, the far tufts, the root occlusion, the roughness, the sheen and the wind. Its defaults are those constants exactly, so a game that sets nothing draws as before. The shaders read them as u_gk_* (the cull as five more Params vec4s, 288 bytes); grass_reset.comp writes each band's index count so a kind of other rows reaches the draw in order. grass_quality holds the kind to a settings tier (never denser, never farther); R3D_GRASS_* still win. grass_profile_w / _bend are the one profile, for the meshes and a game's preview. grass.mesh takes only the cell: the rest of it is an older copy that already differs from grass.vert, left as it draws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
d9a73d63bd
commit
e908672034
25 changed files with 335 additions and 75 deletions
|
|
@ -226,8 +226,10 @@ function scatter_init(render3d_st: mut Render3dState) -> void {
|
|||
render3d_st.sc_prog_card_shadow = r3d_program(render3d_st, "model.vert", "model.frag", "#define SHADOW_PASS\n#define WIND\n#define CARD\n")
|
||||
render3d_st.sc_prog_card_cheap = r3d_program(render3d_st, "model.vert", "model.frag", "#define CARD\n#define CHEAP\n")
|
||||
# a dry alpine meadow: brown-olive roots, straw with a little green at the tips
|
||||
render3d_st.sc_blade_base = v3_new(0.045, 0.06, 0.025)
|
||||
render3d_st.sc_blade_tip = v3_new(0.22, 0.27, 0.13)
|
||||
# (the default GrassKind's base and tip, grass_kind.ludic)
|
||||
render3d_st.sc_blade_base = v3_new(0.0, 0.0, 0.0)
|
||||
render3d_st.sc_blade_tip = v3_new(0.0, 0.0, 0.0)
|
||||
grass_kind_colours(render3d_st)
|
||||
render3d_st.sc_blade_tint = v3_new(1.0, 1.0, 1.0)
|
||||
render3d_st.sc_prog_shadow = r3d_program(render3d_st, "model.vert", "shadow.frag", "#define SHADOW_PASS\n")
|
||||
render3d_st.sc_prog_shadow_wind = r3d_program(render3d_st, "model.vert", "shadow.frag", "#define SHADOW_PASS\n#define WIND\n")
|
||||
|
|
@ -951,6 +953,7 @@ function layer_draw_model(render3d_st: mut Render3dState, l: Layer, model: Model
|
|||
}
|
||||
u_f(render3d_st, gpu_uniform(render3d_st, p, "u_rough_scale"), l.rough)
|
||||
if l.blade { u_v3(render3d_st, gpu_uniform(render3d_st, p, "u_blade_base"), render3d_st.sc_blade_base); u_v3(render3d_st, gpu_uniform(render3d_st, p, "u_blade_tip"), render3d_st.sc_blade_tip) }
|
||||
if l.blade { grass_bind_look(render3d_st, p) }
|
||||
u_f(render3d_st, gpu_uniform(render3d_st, p, "u_cull"), r3d_reach(render3d_st, l.cull))
|
||||
sky_bind_lighting(render3d_st, p)
|
||||
shadow_bind(render3d_st, p)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue