Repository navigation
Reflections and refraction in the realtime viewport, with a lighting parity suite - #322
Merged
DonnieAlex merged 14 commits intoNov 26, 2026
Merged
Conversation
…ar and screen-space tiers with one weight (srlegrand#302)
…s at oblique angles (srlegrand#302)
The planar pass mirrored the camera and rewrote the lights for that view, which put the fragment shader's view-space lighting out of step: the mirrored geometry drew, but black except where a term flipped. Mirror the models about the floor's actual top instead, keep the main camera and lights, and shade each mirrored vertex with the real model's normal so the planar image is the scene's shading mirrored about the floor. Draw both faces, use the floor's top plane rather than y=0, and give the planar pass its own light set without the camera's shadow map. The mirrored geometry is now complete and lit; measured with a flat colour override at AZTEK_REFLECTION_DEBUG=6 it projects to the same rows and columns as the real spheres mirrored about the contact.
…posite The floor read the planar image's lightness as its coverage, so a mirrored sphere's own shadowed side counted as empty and the sky stood in: the mirror came out as a bright cap and a separate lower disc. The planar pass clears to transparent black, so read its alpha instead, which is exactly where the mirrored scene drew. The ambient fill the pass used to add is no longer needed now that the mirrored vertices keep the real model's normals. Recapture the reflections viewport and record the fix in PARITY.md and TICKETS.md.
…gather The spheres' square texels came from the bounce light, not the reflection gather. The screen-space GI stores a dozen stochastic ray hits a pixel; a ray that met a specular highlight came back as a bright texel, and the composite spread each one over a hard 9x9 square. The per-pixel hash also left a diagonal weave, so the grain was spatially correlated. Clamp each ray's radiance the way the offline path clamps its indirect samples (eevee_lightprobe_volume.cc bakes a smooth irradiance field rather than shading from raw stochastic GI), decorrelate the ray sequence, and low-pass the finished bounce image along each axis in quad passes. The composite now reads that filtered field with one linear sample instead of filtering at the sample point. The two 19-tap passes reuse the occlusion and bounce images, so they add no target and no VRAM, and replace the old 81-tap spread and its 81 depth fetches. Raise the reflection gather a step: it read an eighth-resolution mip even for a mirror, so edges stepped at about eight pixels. It now starts two levels sharper (half resolution for a mirror), reads the planar image with linear filtering, and keeps the gather's physical radius by scaling it against a 720-line view. The planar probe stays the full-viewport mirrored-model pass with its own depth, its saturate(dot(N, up)) score and alpha coverage, the shape of EEVEE's planar probe (eevee_lightprobe_planar.cc, PlanarProbe::set_view; eevee_lightprobe_plane.bsl.hh; eevee_forward_lib.bsl.hh), with the roughness-to-level prefiltered gather of eevee_lightprobe_sphere.bsl.hh. `modelEditor -bounceLight` and `-ambientOcclusion` now drive the two lighting toggles from scripts. Recapture the reflections example and record the design and its remaining EEVEE detail (the probe's world clip plane and temporal reprojection) in PARITY.md and TICKETS.md.
…g check One session with lights, shadows, ambient occlusion, bounce light, textures and depth of field on, driven through a 360 orbit, a dolly, a low terminator sweep and twelve still frames. The bounce and reflection work holds in motion: still frames are bit-identical and no frame-to-frame step stands above its neighbours, so there is no speckle, tier pop or reflection offset. What the moving frames did show was the shadow map's cast edge: at a close view one texel is many pixels, so the sphere's shadow on the floor was a hard chunky boundary that crawled as the camera moved. The percentage- closer filter now gathers 5 by 5 texels and the shadow sampler is bilinear, turning that edge into a soft penumbra. It costs 25 taps instead of 9 in a shadowed fragment; the capture still ran at about 20 frames a second at 734 by 708 including the PNG write. `tools/render_parity/motion_capture.py` repeats the whole check in one launch, and `modelEditor -depthOfField` drives that viewport toggle from scripts. The parity captures are recaptured for the softer shadow.
… session Re-ran the orbit, dolly, terminator sweep and still-frame passes from a new app session. Every frame was bit-identical to the first pass at the same time, the still frames were identical again, and the frame-to-frame steps kept the same smooth profile. The wider shadow filter left the contact shadow attached at the closest dolly view and softened the sweep's boundary, so nothing remained to change. Records the cross-session determinism in PARITY.md/TICKETS.md.
…ooth The dielectric_glass floor had dark polygonal patches under the glass spheres, with a mottled fill and hard edges. A point light is a cube map (six 2048-texel faces, all rewritten each frame, near/far from the scene's distance to the light) and the shader compared one texel against a constant world-space slack. A floor at a grazing angle from a light close to it has no slope bias that way, and the single texel made a polygonal shadow with a mottled fill. The cube path now uses a depth slack scaled by the texel footprint over the cosine to the light and fixed bilinear cube taps at a four-texel radius: a 4 by 4 grid for a point light, a sixteen-tap golden-angle disc for an area light's wider penumbra, and no per-pixel or per-frame rotation. The directional and spot path keeps its 5 by 5 bilinear PCF. The deeper cause of the dark glass was that the glass spheres cast opaque shadows: the floor under them went black and the glass refracted that black floor. Transmissive shapes are left out of the shadow map now, so the floor under the glass is lit and the behind-glass image is not black; the glass also keeps a floor of its own transmission colour where the background behind it is dark, so it never reads blacker than what it lets through. Verified at the dielectric scene's far, mid and close distances, two angles at each, and a grazing view. The far views push the floor until it fills the frame, where the shadow-map footprint is worst: the far floor's blocky glass shadows and mottled fill are gone, the remaining cast shadows are smooth, and the glass reads red rather than black. metal_roughness_sweep and area_lights recapture without a regression. Point-light shadows cost sixteen bilinear taps instead of one; the shadow map's memory is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #302
What was wrong and what happens now
The realtime viewport shaded direct light and the sky only: a sphere standing on a floor left a patch of its colour in the floor through bounce light, but no image of it, and glass was opaque. The viewport now reflects and refracts as the Render View does.
Reflections use the same structure as the reference engine the user asked us to follow. The Realtime renderer writes a material image beside its picture. A planar probe renders the scene mirrored about the floor's own top plane, with its own depth and a full-viewport target, the main camera and lights untouched and the mirrored models carrying recomputed normals; the floor samples it at its own screen position, with coverage read from the probe's alpha so a dark reflection is not mistaken for nothing. A screen-space tier covers what the planar one cannot see, sampled from a filtered mip chain at a level chosen by roughness, and the environment stands in where nothing is drawn. Planar, screen-space and environment blend by roughness and planarity with weights summing to one. Glass is drawn solid and the scene is drawn once more without transmissive shapes; each glass pixel reads that behind-glass image, bent toward the rim as a lens and tinted by its transmission colour with a distance falloff.
Two defects found by the user in motion were fixed at the source. The bounce light's speckles were screen-space GI point-sampled at the hit and spread over a hard square; the ray radiance is now clamped, the hash decorrelated, and the finished bounce image low-passed in a quad pass that the shading reads with one linear sample, which is the reference engine's principle of shading from a smooth irradiance field rather than raw stochastic GI. Point lights showed polygonal, mottled floor shadows: their cube map was compared at one texel against a constant slack; the cube path now uses a slope-scaled slack with a fixed 4x4 bilinear tap grid (16-tap golden-angle disc for area lights), and transmissive shapes no longer cast opaque shadows. Directional and spot shadows use a 5x5 bilinear PCF.
A parity suite was added: eight lighting scenes under
examples/renderingwith reference renders and viewport captures,tools/render_parity/capture.shto reproduce both, a documented README, andmotion_capture.pyfor the moving check. A--viewport-screenshotoption captures a clean 16:9 viewport, andmodelEditor -depthOfFieldlets scripts switch that view.Not done, recorded in PARITY.md and TICKETS.md: the reference engine's planar world clip plane and temporal reprojection of the indirect term; Aztek has no transmission depth, so the refraction is a lens approximation; the HDRI sky is not drawn as the viewport background; the viewport frames about 12% tighter than the render at the same focal length; only the widest flat ground mesh is mirrored; a point light close to a large floor can still leave a cube shadow seam; one-pixel MSAA coverage at a silhouette and the grid over a sphere at grazing angles remain.
What I checked
eevee_lightprobe_planar.cc,eevee_lightprobe_plane.bsl.hh,eevee_ray_trace.bsl.hh,eevee_raytrace.cc,eevee_lightprobe_sphere.bsl.hh) to follow its reflection structure.cargo test -p aztek_host --lib: 35 passed.tools/check_app.sh: no errors under clang and GCC. All eight scenes load through--batchwithout warnings.How it was made
Made with a coding assistant. Built and run on Linux, with the captures and the reference engine's source compared side by side.