diff --git a/packages/ludic.render3d/actor.ludic b/packages/ludic.render3d/actor.ludic index f53b821b..3c0c9449 100644 --- a/packages/ludic.render3d/actor.ludic +++ b/packages/ludic.render3d/actor.ludic @@ -152,7 +152,13 @@ function ac_visible(a: Actor, shadow: bool) -> bool { } if not shadow and a.radius != 0 { let r = f_mul(a.radius, a.scale) - if not cam_sphere_visible(a.x, f_add(a.y, r), a.z, f_mul(r, fl(1.5))) { return false } + var cy = f_add(a.y, r) + # In the water reflection what reaches the picture is the actor's mirror image, 2L - y. The pass + # keeps the main camera's frustum planes, so the image is what has to be tested against them: the + # actor itself was, and the town's people - far above the lake, their images far below the frame - + # all drew again into the reflection. + if ter_reflect { cy = f_sub(f_mul(F_TWO, water_level), cy) } + if not cam_sphere_visible(a.x, cy, a.z, f_mul(r, fl(1.5))) { return false } } return true } diff --git a/packages/ludic.render3d/water.ludic b/packages/ludic.render3d/water.ludic index fbb6c657..922908e4 100644 --- a/packages/ludic.render3d/water.ludic +++ b/packages/ludic.render3d/water.ludic @@ -78,9 +78,13 @@ function water_reflection_pass() -> void { let sb = sc_skip_blade sc_skip_blade = true # blades are invisible at this scale in a reflection ter_reflect = true + prof_cpu_mark("reflection setup") terrain_draw() + prof_cpu_mark("reflection terrain") scene_draw() + prof_cpu_mark("reflection scene") r3d_draw_sky() + prof_cpu_mark("reflection sky") ter_reflect = false sc_skip_blade = sb sc_freeze = false