Part of #41: the comments of `benilla-world`, Rust and WGSL, are rewritten to the rule in `docs/METHOD.md`, which is what the code does and the reference fact behind it, in a line. 24,226 comment lines become 8,863. - **The mechanical strip.** The citations that were only a private record number go first, and each edit is shown to be a pure removal. - **Wrong facts corrected.** The rewrite corrects the comments that stated wrong facts. Among them: - `0x6b62e0` is the WMO group's liquid renderer, not a doodad drawer. - The reference creates a WMO's props once, when a group enters its streaming window (`0x698720` → `0x695aa0`). It then admits them each frame the portal walk visits the group (`0x685d70` → `0x6838f0`). The old text had them created per visible group. - The liquid query's comments now state the reference's order: the map-object leg first, then the ADT (`0x69b6d0`). They no longer call the Outdoors/Inside split a match. - The interior probe runs from the character, not the camera. - The reference lights ground clutter. The old comment said it draws unlit. - The model-particle "pool order" deviation was wrong. Each instance is its own mesh, depth-sorted every frame. - The reference's vertical field of view follows the aspect ratio (44.1° at 16:9). The comment now gives it beside our fixed 45°. - The effect shader's far wall is the live `farclip`, 177 to 777 yd, not a fixed 777 yd. - Dozens more turned up on the way: renamed or deleted items, docs sitting on the wrong item, stale counts and links. - **Deviation labels.** "Deviation:" now marks only a choice with a reason. An unbuilt behaviour says so plainly. - **Verification.** Every file strips to identical code, and `cargo fmt --check` is clean. Five second readers compared every file old against new, restored the facts the rewrite had dropped, and checked each new citation against the reference. Defects the rewrite surfaced outside the comments are filed as their own issues (#106, #114, #115, #116). The comments here state what the code does. String literals are untouched; they are #92. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
75 lines
3.3 KiB
Rust
75 lines
3.3 KiB
Rust
//! Where a colour lane's final pass lands, for the FFXGlow combine ([`crate::ffx_glow`]) and the UI
|
|
//! gamma decode (`benilla_app::ui_gamma`). A [`CameraOutputMode::Write`] camera keeps bevy's
|
|
//! ping-pong and `upscaling` blit, which honours a bake's clear colour and viewport; a
|
|
//! [`CameraOutputMode::Skip`] camera's final pass renders straight into the target, in its format,
|
|
//! clearing it rather than loading it, since the fullscreen triangle covers the viewport either
|
|
//! way. A world view the UI camera claims (`ffx_glow::FfxBackdrop`) resolves none: its combine is
|
|
//! the first draw of that camera's main pass. A `Skip` camera whose final pass never ran presents
|
|
//! a target nothing wrote, which is why `$WOW_NO_FFX` keeps the combine.
|
|
|
|
use bevy::camera::{CameraOutputMode, Viewport};
|
|
use bevy::color::LinearRgba;
|
|
use bevy::render::camera::ExtractedCamera;
|
|
use bevy::render::render_resource::{
|
|
Operations, RenderPassColorAttachment, TextureFormat, TextureView,
|
|
};
|
|
use bevy::render::view::ViewTarget;
|
|
|
|
/// One final pass's source and destination for one view: [`Self::format`] at prepare for the
|
|
/// pipeline, [`Self::resolve`] in the node for the pass.
|
|
pub struct FinalPassTarget<'a> {
|
|
/// The finished main texture the pass reads.
|
|
pub source: &'a TextureView,
|
|
/// The output texture (`Skip`) or the other main texture (`Write`).
|
|
pub destination: RenderPassColorAttachment<'a>,
|
|
/// A `Skip` camera's viewport, as the pass's scissor; `None` covers the whole target.
|
|
pub scissor: Option<&'a Viewport>,
|
|
}
|
|
|
|
impl<'a> FinalPassTarget<'a> {
|
|
/// The format the final pass renders in, which its pipeline is specialised on.
|
|
pub fn format(output_mode: &CameraOutputMode, target: &ViewTarget) -> TextureFormat {
|
|
match output_mode {
|
|
CameraOutputMode::Skip => target.out_texture_view_format(),
|
|
CameraOutputMode::Write { .. } => target.main_texture_format(),
|
|
}
|
|
}
|
|
|
|
/// Resolve a view's final pass target. Call once per view per frame: the `Write` arm takes the
|
|
/// view's post-process write, which flips the main texture.
|
|
pub fn resolve(camera: &'a ExtractedCamera, target: &'a ViewTarget) -> Self {
|
|
match camera.output_mode {
|
|
CameraOutputMode::Skip => Self {
|
|
source: target.main_texture_view(),
|
|
destination: target.out_texture_color_attachment(Some(LinearRgba::NONE)),
|
|
scissor: camera.viewport.as_ref(),
|
|
},
|
|
CameraOutputMode::Write { .. } => {
|
|
let post = target.post_process_write();
|
|
Self {
|
|
source: post.source,
|
|
destination: RenderPassColorAttachment {
|
|
view: post.destination,
|
|
depth_slice: None,
|
|
resolve_target: None,
|
|
ops: Operations::default(),
|
|
},
|
|
scissor: None,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// The pass's scissor rect, `(x, y, width, height)` in physical pixels.
|
|
pub fn scissor_rect(&self) -> Option<(u32, u32, u32, u32)> {
|
|
self.scissor.map(|viewport| {
|
|
(
|
|
viewport.physical_position.x,
|
|
viewport.physical_position.y,
|
|
viewport.physical_size.x,
|
|
viewport.physical_size.y,
|
|
)
|
|
})
|
|
}
|
|
}
|