render3d: the deterministic work as bytes a bake keeps, and the textures made from them
Each pair runs the work as the renderer always has and reads the result back, or makes the same textures and fills them from bytes instead: impostor_bytes / impostor_from_bytes (and impostor_fill, for a fog that opens past a layer's cards), terrain_shadow_bytes / terrain_shadow_from_bytes, sky_ibl_bytes / sky_ibl_from_bytes (sky_precompute split into sky_ibl_make and the convolutions). A bundle is a word count, a word length per part and the parts (bake_pack / bake_unpack), checked against the textures' shapes before any byte is used. gpu_vk_readback.ludic reads a texture's level 0, every layer, as stored; r3d_baked_read reads a bake's file (ludic.base's LBAK header: key and version must match) since render3d cannot import ludic.base. Nothing calls them yet: behaviour unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7ffa0ecf6d
commit
883ea8d48a
4 changed files with 211 additions and 12 deletions
|
|
@ -92,20 +92,31 @@ function sky_set_quality(render3d_st: mut Render3dState, w: int) -> void {
|
|||
|
||||
function sky_precompute(render3d_st: mut Render3dState) -> void {
|
||||
gpu_depth_test(render3d_st, false)
|
||||
sky_ibl_make(render3d_st)
|
||||
if render3d_st.sky_p_irr == 0 { render3d_st.sky_p_irr = r3d_program(render3d_st, "fullscreen.vert", "ibl_irradiance.frag", ""); render3d_st.sky_p_pre = r3d_program(render3d_st, "fullscreen.vert", "ibl_prefilter.frag", ""); render3d_st.sky_p_brdf = r3d_program(render3d_st, "fullscreen.vert", "ibl_brdf.frag", "") }
|
||||
sky_convolve(render3d_st, render3d_st.sky_p_irr, render3d_st.sky_irradiance, -1, 128, 64, 0.0)
|
||||
for l in 0 .. SKY_PREFILTER_LEVELS {
|
||||
sky_convolve(render3d_st, render3d_st.sky_p_pre, render3d_st.sky_prefilter, l, render3d_st.sky_prefilter_w, render3d_st.sky_prefilter_w / 2, float(l) / float(SKY_PREFILTER_LEVELS - 1))
|
||||
}
|
||||
sky_convolve(render3d_st, render3d_st.sky_p_brdf, render3d_st.sky_brdf, -1, 256, 256, 0.0)
|
||||
render3d_st.sky_baked = true
|
||||
render3d_st.sky_baked_yaw = render3d_st.sky_yaw
|
||||
gpu_check(render3d_st, "sky precompute")
|
||||
}
|
||||
|
||||
# the IBL set's textures, made empty (the last ones let go): what sky_precompute convolves into, and
|
||||
# what sky_ibl_from_bytes fills from a bake
|
||||
function sky_ibl_make(render3d_st: mut Render3dState) -> void {
|
||||
if render3d_st.sky_irradiance != 0 {
|
||||
gpu_tex_free(render3d_st, render3d_st.sky_irradiance)
|
||||
gpu_tex_free(render3d_st, render3d_st.sky_prefilter)
|
||||
gpu_tex_free(render3d_st, render3d_st.sky_brdf)
|
||||
}
|
||||
# irradiance: 128 x 64 equirect
|
||||
if render3d_st.sky_p_irr == 0 { render3d_st.sky_p_irr = r3d_program(render3d_st, "fullscreen.vert", "ibl_irradiance.frag", ""); render3d_st.sky_p_pre = r3d_program(render3d_st, "fullscreen.vert", "ibl_prefilter.frag", ""); render3d_st.sky_p_brdf = r3d_program(render3d_st, "fullscreen.vert", "ibl_brdf.frag", "") }
|
||||
let p_irr = render3d_st.sky_p_irr
|
||||
render3d_st.sky_irradiance = tex_target(render3d_st, 128, 64, GL_RGB16F, GL_RGB, GL_FLOAT, GL_LINEAR)
|
||||
gpu_tex_bind(render3d_st, GPU_TEX2D, render3d_st.sky_irradiance)
|
||||
gpu_tex_param(render3d_st, GPU_TEX2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
|
||||
sky_convolve(render3d_st, p_irr, render3d_st.sky_irradiance, -1, 128, 64, 0.0)
|
||||
# prefiltered specular: 6 roughness levels, sky_prefilter_w x half each, as a 2D array
|
||||
let p_pre = render3d_st.sky_p_pre
|
||||
render3d_st.sky_prefilter = gpu_tex_new(render3d_st)
|
||||
gpu_tex_bind(render3d_st, GPU_TEX2D_ARRAY, render3d_st.sky_prefilter)
|
||||
gpu_tex_image3d(render3d_st, GL_RGB16F, render3d_st.sky_prefilter_w, render3d_st.sky_prefilter_w / 2, SKY_PREFILTER_LEVELS, GL_RGB, GL_FLOAT, null)
|
||||
|
|
@ -113,16 +124,8 @@ function sky_precompute(render3d_st: mut Render3dState) -> void {
|
|||
gpu_tex_param(render3d_st, GPU_TEX2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
|
||||
gpu_tex_param(render3d_st, GPU_TEX2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
|
||||
gpu_tex_param(render3d_st, GPU_TEX2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
|
||||
for l in 0 .. SKY_PREFILTER_LEVELS {
|
||||
sky_convolve(render3d_st, p_pre, render3d_st.sky_prefilter, l, render3d_st.sky_prefilter_w, render3d_st.sky_prefilter_w / 2, float(l) / float(SKY_PREFILTER_LEVELS - 1))
|
||||
}
|
||||
# BRDF LUT
|
||||
let p_brdf = render3d_st.sky_p_brdf
|
||||
render3d_st.sky_brdf = tex_target(render3d_st, 256, 256, GL_RG16F, GL_RG, GL_FLOAT, GL_LINEAR)
|
||||
sky_convolve(render3d_st, p_brdf, render3d_st.sky_brdf, -1, 256, 256, 0.0)
|
||||
render3d_st.sky_baked = true
|
||||
render3d_st.sky_baked_yaw = render3d_st.sky_yaw
|
||||
gpu_check(render3d_st, "sky precompute")
|
||||
}
|
||||
|
||||
# bind the IBL set + sun for a lit program (units 12..14)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue