A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(render): auto exposure meters a spot, and depth of field auto-focuses and shapes its bokeh by the aperture
yhh53022511c0eb
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 102e7e834..ebef6d8af 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,7 +20,7 @@ published separately; it ships inside the editor.- **Quality levels are edited in Settings.** Settings → Project → Rendering edits each quality level, including which effects it runs. **Editing level** picks Low, Medium or High and the groups below — Rendering (render scale, minimum scale, MSAA), Shadows, Reflections and particles, Post-processing — show and change that level, so a level is read the way Unity's Quality page reads: a level, then its settings by subsystem. Post-processing lists every effect the engine has, ticked where the level runs it; an unticked one is skipped at that level wherever a camera's volume asks for it, with all of its passes. Device rules — the model, GPU, memory and core conditions Auto chooses a level by — are a table, shown when the mode is Auto, that says so on a row with no condition instead of dropping it while it is typed. Only what you change is saved to `project.esproject`, as a difference to that level, so an engine default that improves later still reaches a project that never touched it; a row's "changed" mark and reset follow the default of the level it is showing. The old per-level shadow distance rows are the Shadows group's Distance now. The effects a level leaves out had been matched by the prefix of a pass's name, which found none of Auto Exposure's passes; they are now matched by effect type. A new Quality Levels page in the performance docs describes it.- **A G-buffer, and reflections that read it.** Reflections now know how rough and how metal each surface is, from a G-buffer the frame draws on request. A post-process shader that says `#pragma gbuffer` makes the scene target carry a second RGBA8 colour attachment, written in the same pass by the scene's own shaders — octahedral normal in `r`/`g`, roughness in `b`, metalness in `a` (0 where nothing wrote) — and finds it at `u_gbuffer`. A frame whose chain has no such effect makes none and compiles no variant. The render device grew multiple colour attachments for it on both backends: WebGL2 attaches and resolves a second target and sets the draw buffers per pipeline, and WebGPU declares the second target on every pipeline of the pass (written by the ones that write it, an empty write mask for the rest), clears it to zero and resolves it with the colour. Pipelines say whether they write it (`PipelineDesc::gbuffer`), a blended draw never does, and the second output is its own shader variant (`ES_GBUFFER`), so no pass pays for what it did not ask for. The built-in Model shader — what an imported glTF material becomes — writes it from the material's roughness, metalness and normal map. `ssr` reads it: it takes the surface's own normal (normal-map detail that depth cannot see), weighs and blurs the reflection by roughness, reflects a metal at nearly full strength where a dielectric reflects 4%, skips a surface rougher than `maxRoughness` before marching the ray, and takes the Rain effect's `wetness` as a film that smooths the ground. Where nothing wrote a record, it falls back to depth and the dielectric it has always assumed. Verified in the editor on both backends: of two floors that differ only in their material's roughness, the glossy one changes ten times the pixels the rough one does. Quality levels can also leave out expensive effects now: quality levels can now skip expensive post-process effects by name. A level's `skipEffects` lists the effects it leaves out, each named by its effect type (`ssr`, `taa`, `depthOfField`, `lightShafts`, `autoExposure`, …), and an effect leaves with all of its passes however they are named; a project's own list in its quality profile replaces the level's. By default low leaves out reflections, temporal anti-aliasing, depth of field and light shafts, and medium leaves out reflections and depth of field; high leaves out nothing. These defaults come from the work each effect does per pixel, not from a weak device: the editor's new `fx-cost` check measured every effect on Bistro at 2560×1600 on a fast desktop GPU, and none added more than about 6 ms (reflections ~5, bloom ~4, the example's whole eight-effect chain ~11, the rest within the ±3 ms the run drifts by), so the levels have not been checked against the hardware they are for. Screen-space reflections leave a surface that recorded nothing alone, plain meshes now record a rough dielectric, and a puddle reflects the sky and what lies off screen.- **Rain, wet ground and puddles.** A Rain post-process effect adds falling rain, wet ground, puddles and ripples. `rain` draws three layers of slanted streaks, each at its own distance so a nearer surface hides them and the sky does not; darkens the ground that faces up by `wetness`; lays ripples and splashes where drops land on a grid in the world, so they stay on the ground as the camera moves (ripples need `intensity` above 0: wet ground under no rain is still); and, by `puddles` and `puddleScale`, covers part of the flat ground with standing water that is darker and takes denser, clearer ripples. `ssr` takes the same two numbers and treats those pools as mirrors — flat, far more reflective than dry ground, and sharp — so the pools the rain darkens are the pools that reflect. The clock is `u_time * timeScale + phase`, so a capture can pin it. The rain is a screen-space layer, not particles that collide with the world, and a puddle is flat ground whatever it lies on. Verified in the editor on both backends: streaks light a dark sky and move between two moments, wet ground reads darker, standing water darker still, and puddles change the reflection. Puddles gather in the low places of the ground and thin on its rises, read from the depth buffer. Three rings of depth taps measure the ground around a pixel, so pools gather against a kerb, in a dip and at the foot of a slope instead of lying on the world-space noise alone.-- **Auto Exposure and Depth of Field.** Auto Exposure and Depth of Field post-process effects are available. `autoExposure` measures the average log luminance of the picture (leaving out pixels darker than 2^-8, so a black backdrop does not open the exposure to its limit), turns it into the exposure that puts it at middle grey, and moves toward that over time from where the last frame left it — brighter faster than darker, per second, within `minEV` and `maxEV`, with a `bias` in stops. To keep the settled value between frames a post-process shader can now declare a `u_feedback` texture: the engine keeps that pass's last output, at the pass's own size, and binds it there, without shifting the picture the way `u_history` does. `depthOfField` blurs by distance from `focusDistance`, with a sharp slab of `focusRange`, a blur radius that grows with how far a surface is from focus up to `maxBlur`, and a gather that counts a neighbour only where its own blur reaches back, so a sharp object does not bleed into a blurred background. Verified in the editor on both backends: a dim scene brightens (mean 6.9 to 16.5) and a bright one darkens (30.7 to 20.4), a drop in light is first dark and then recovered over real time (5.2 then 15.8), and focusing close takes the squared edge energy down to 21% of the sharp frame.+- **Auto Exposure and Depth of Field.** Auto Exposure and Depth of Field post-process effects are available. `autoExposure` measures the average log luminance of the picture (leaving out pixels darker than 2^-8, so a black backdrop does not open the exposure to its limit), turns it into the exposure that puts it at middle grey, and moves toward that over time from where the last frame left it — brighter faster than darker, per second, within `minEV` and `maxEV`, with a `bias` in stops. To keep the settled value between frames a post-process shader can now declare a `u_feedback` texture: the engine keeps that pass's last output, at the pass's own size, and binds it there, without shifting the picture the way `u_history` does. `depthOfField` blurs by distance from `focusDistance`, with a sharp slab of `focusRange`, a blur radius that grows with how far a surface is from focus up to `maxBlur`, and a gather that counts a neighbour only where its own blur reaches back, so a sharp object does not bleed into a blurred background. Verified in the editor on both backends: a dim scene brightens (mean 6.9 to 16.5) and a bright one darkens (30.7 to 20.4), a drop in light is first dark and then recovered over real time (5.2 then 15.8), and focusing close takes the squared edge energy down to 21% of the sharp frame. Auto Exposure can meter the middle of the picture or a spot, and Depth of Field focuses by itself and blurs a light into the shape of its aperture. Auto Exposure gains `metering` (average, centre-weighted, spot) and `meterSize`, and keeps its measurement in float targets so it behaves the same in an 8-bit chain. Depth of Field becomes three passes — focus, circle of confusion, gather — with `autoFocus` (a point on the screen, a glide at `focusSpeed`), `blades` and `bladeRotation` for the aperture's shape, and `highlight` for bright points; a post-process shader can ask for a float target with `#pragma highprecision`.- **Height Fog and Light Shafts.** Height Fog and Light Shafts post-process effects add atmosphere. `heightFog` is exponential height fog with a closed-form integral — no marching — so a valley fills and a hilltop clears, the horizon turns hazy while the zenith stays clear, and looking toward the sun the haze takes the sun's colour; sky pixels run through the same formula with a very long ray, and `skyFog` sets how much haze the sky keeps. `lightShafts` marches each pixel toward the sun's place on screen and counts how much of the way is open sky, leaving rays through whatever stands in front of the sun. The sun's direction is set on the effects (azimuth and elevation), not read from a light. Neither is a shadowed volume: fog is lit evenly. Both run on WebGL2 and WebGPU; with an output transform of None, a floor fully taken by the fog reads exactly the authored colour on both. Height Fog and Light Shafts follow the scene's own sun, and Height Fog can carry the sun's shadows as volumetric light. `followSun` (on by default) takes the sun from the first directional light that shines; `volumetric` walks the air in 24 steps against the sun's shadow map, so shadows are dark fog and gaps between them beams. A post-process shader can ask for the light block and shadow atlas with `#pragma lights`.- **Screen Space Reflections.** A Screen Space Reflections post-process effect mirrors props in floors. Add `ssr` to a `PostProcessVolume`: with no G-buffer, the surface normal is rebuilt from the depth buffer, the reflected ray is marched through the world and projected back to the screen at every step, and a step landing just behind the visible surface is a hit, refined by bisection. The reflection is blended over the pixel by a Schlick Fresnel term — faint face-on, strong at a grazing angle — and blurred by how far the ray travelled, which stands in for roughness. `intensity`, `maxDistance`, `thickness` and `floorBias` are the settings; `floorBias` at 1 lets only up-facing surfaces reflect, since the chain does not know a material's roughness. What is off screen or in the sky is not reflected; the pixel is left as it was. It reads the same depth buffer as ambient occlusion, runs on WebGL2 and WebGPU alike, and its per-pixel start offset is meant to be averaged away by `taa`. Verified in the editor on a lit scene with both backends: the props appear in the floor they stand on and nothing else on screen changes.- **Temporal Anti-Aliasing.** A Temporal Anti-Aliasing post-process effect smooths edges across frames. Add `taa` to a `PostProcessVolume` and the engine shifts the scene's picture by a different sub-pixel amount each frame (eight positions, repeating), keeps the effect's last output as its history, and blends the two — reaching what multisampling cannot: shader aliasing and thin geometry. Where a pixel was last frame comes from the depth buffer and the previous camera, so a moving camera keeps its history; the history is clipped to the colours around it, so what no longer matches is dropped rather than smeared, and each camera keeps a history of its own. One `blend` setting says how much of each frame is new. Measured in the editor on a lit scene with multisampling off, in-between edge pixels went from 2% of edge pixels to 43% on WebGL2 and 44% on WebGPU, still frames held still, and a picture taken mid-slide of the camera matched the plain one to within a fraction of a level. Objects that move by themselves are not tracked — they are handled by the clip, so fast movers can look slightly soft. Temporal Anti-Aliasing now follows meshes that move by themselves, from a motion pass that draws only what moved, so a thin fast object keeps its contrast. Moving meshes are drawn a second time into a target of their own that records how far each pixel travelled (an RGBA32F target, only on devices with float render targets), and the effect follows that where it is the surface the scene shows; `Object Motion` at 0 trusts the camera alone. Skinned meshes are followed by their bones, from the palette they were last drawn with.diff --git a/desktop b/desktopindex 3dca8913c..4fec511e7 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 3dca8913ca033b3a5153319df7fa615ce5a385c9+Subproject commit 4fec511e79b37f6bc88cb3a08f1eb1811e4abc25diff --git a/docs/astro/src/content/docs/graphics/post-processing.mdx b/docs/astro/src/content/docs/graphics/post-processing.mdxindex 4274a81ca..a03adacdf 100644--- a/docs/astro/src/content/docs/graphics/post-processing.mdx+++ b/docs/astro/src/content/docs/graphics/post-processing.mdx@@ -77,18 +77,33 @@ is judged by ratio and a raw average is decided by whatever lamp is in view; pixare left out, because a black backdrop is not a dark scene. The result moves toward its target over timefrom where the last frame left it — brighter faster (`speedUp`) than darker (`speedDown`), per second, so it does notdepend on the frame rate — and `minEV` / `maxEV` bound how far it may go. `bias` adds stops to the result for a-scene that should sit darker or brighter than grey. It works in the HDR chain; in an 8-bit chain the-measurement is coarse and the adaptation steps are visible. Put it before the output transform and-before `bloom`, so the glow sees the exposure the eye settled on.+scene that should sit darker or brighter than grey. `metering` chooses where the picture is measured: 0 all of it, 1+weighted toward the middle (a soft falloff of radius `meterSize`), 2 a spot — a disc of that radius at the middle and+nothing else, so a bright window behind a dark face stops deciding the face's exposure. The measurement and the settled+exposure are kept in float targets of their own wherever the device can render to one, so it works the same in an+8-bit chain, where the picture it exposes is still clamped. Put it before the output transform and before `bloom`,+so the glow sees the exposure the eye settled on.### Depth of field-`depthOfField` blurs what is not at `focusDistance` (a world length from the camera), leaving a slab `focusRange` deep-sharp. The blur radius, in pixels, grows with how far a surface is from the focus as a share of its distance, up to `maxBlur`;+`depthOfField` blurs what is not at the focus, leaving a slab `focusRange` deep sharp. It is three passes: the first settles+where the lens is focused, the second measures how blurred each pixel is (stored beside the colour, in a float target),+the third gathers the blur.++**Focus** is `focusDistance`, a world length from the camera — or, with `autoFocus` on, the distance of the surface under+the point `focusX`, `focusY` (shares of the screen's width from the left and height from the top, nine taps around it so one+pixel does not decide). It moves toward that distance at `focusSpeed`, in the log of the distance, so a rack focus is a+glide; a point with nothing but sky under it leaves the lens where it was.++**The blur** radius, in pixels, grows with how far a surface is from the focus as a share of its distance, up to `maxBlur`;`aperture` is the radius of something infinitely far, and the sky counts as that. Each pixel gathers its neighbours over its owncircle, counting a neighbour only to the extent that neighbour's own blur reaches back: a sharp object in front of a-blurred background does not bleed into it, while a blurred foreground spreads over what is behind it. The gather is-rotated per pixel, so it leaves a fine grain that `taa` averages away.+blurred background does not bleed into it, while a blurred foreground spreads over what is behind it. The sixty-four taps+shift along their spiral by a different fraction at each pixel, which leaves a fine grain that `taa` averages away.++**The bokeh** is the shape of the lens: `blades` of 3 or more makes the aperture a polygon of that many sides (0 is round), turned+by `bladeRotation`, and a bright point out of focus becomes that shape. `highlight` makes bright taps count for more, so a lamp+out of focus is a bright shape and not a dim smear.### The G-bufferdiff --git a/docs/astro/src/content/docs/zh-cn/graphics/post-processing.mdx b/docs/astro/src/content/docs/zh-cn/graphics/post-processing.mdxindex b891aac17..cac8a6e69 100644--- a/docs/astro/src/content/docs/zh-cn/graphics/post-processing.mdx+++ b/docs/astro/src/content/docs/zh-cn/graphics/post-processing.mdx@@ -61,15 +61,26 @@ Estella 通过 ping-pong 帧缓冲运行全屏后处理。加一个 `PostProcess`autoExposure` 就是眼睛:它测量画面有多亮,并稳定到把画面放在中灰的曝光上。测量的是亮度**对数**的平均,因为亮度是按比例判断的,而原始平均会被画面里的某盏灯决定;暗于 2^-8 的像素不计入,因为黑色背景不等于暗场景。结果从上一帧的位置随时间趋近目标——变亮比变暗快(`speedUp` / `speedDown`,按秒计,与帧率无关)——-`minEV` / `maxEV` 限定范围,`bias` 给结果加几档,用于想比中灰更暗或更亮的场景。它在 HDR 链路里工作;-8 位链路里测量粗糙、适应的台阶可见。放在输出变换之前、`bloom` 之前,让辉光看到眼睛稳定后的曝光。+`minEV` / `maxEV` 限定范围,`bias` 给结果加几档,用于想比中灰更暗或更亮的场景。`metering` 选择在画面哪里测量:0 整个画面,+1 偏向中间(半径为 `meterSize` 的柔和衰减),2 点测光——中间一个这么大的圆盘,其余都不算,这样明亮的窗户就不再决定窗前暗处人脸的曝光。+测量值和稳定下来的曝光只要设备能渲染到浮点目标就存在各自的浮点目标里,所以 8 位链路里表现相同(被曝光的画面仍然是被截断的)。+放在输出变换之前、`bloom` 之前,让辉光看到眼睛稳定后的曝光。### 景深-`depthOfField` 模糊不在 `focusDistance`(到相机的世界长度)的东西,`focusRange` 深的一片保持清晰。模糊半径(像素)随表面-离焦点的距离占其自身距离的比例增长,封顶 `maxBlur`;`aperture` 是无限远处东西的半径,天空算作这样。每个像素在自己的圆里-收集邻居,只在邻居自己的模糊够得着这里时才计入:清晰的前景物体不会渗进模糊的背景,而模糊的前景会铺到它后面的东西上。-收集按像素旋转,留下一层细颗粒,由 `taa` 平均掉。+`depthOfField` 模糊不在焦点上的东西,`focusRange` 深的一片保持清晰。它分三遍:第一遍定下镜头对焦在哪里,第二遍量出每个像素+有多模糊(和颜色存在一起,在浮点目标里),第三遍做模糊的收集。++**对焦**是 `focusDistance`(到相机的世界长度);开了 `autoFocus` 则是 `focusX`、`focusY`(屏幕宽度从左、高度从上的比例)那一点下的表面距离,+周围取九个点,不让某一个像素说了算。它以 `focusSpeed` 向那个距离靠拢,在距离的对数上走,所以拉焦是一次滑动;+那一点下只有天空时镜头留在原处。++**模糊**半径(像素)随表面离焦点的距离占其自身距离的比例增长,封顶 `maxBlur`;`aperture` 是无限远处东西的半径,天空算作这样。+每个像素在自己的圆里收集邻居,只在邻居自己的模糊够得着这里时才计入:清晰的前景物体不会渗进模糊的背景,而模糊的前景会铺到它后面的东西上。+六十四个采样沿螺旋按像素不同的小数偏移,留下一层细颗粒,由 `taa` 平均掉。++**散景**就是镜头的形状:`blades` 为 3 或更大时光圈是那么多边的多边形(0 为圆形),按 `bladeRotation` 转动,失焦的亮点就成了那个形状。+`highlight` 让亮的采样权重更大,所以失焦的灯是一个明亮的形状而不是暗淡的一团。### G-bufferdiff --git a/sdk/src/postprocess/effects.ts b/sdk/src/postprocess/effects.tsindex 3c09fca2f..795b71e6c 100644--- a/sdk/src/postprocess/effects.ts+++ b/sdk/src/postprocess/effects.ts@@ -302,6 +302,11 @@ registerEffect({{ name: 'u_speedDown', label: 'Darken Speed', min: 0.1, max: 20, step: 0.1, defaultValue: 1 },{ name: 'u_minEV', label: 'Min EV', min: -10, max: 0, step: 0.5, defaultValue: -4 },{ name: 'u_maxEV', label: 'Max EV', min: 0, max: 10, step: 0.5, defaultValue: 4 },+ // Where the picture is measured: 0 the whole of it, 1 weighted toward the middle (a soft falloff), 2 a disc at the+ // middle and nothing else — a bright window behind a dark face stops deciding the exposure of the face.+ { name: 'u_metering', label: 'Metering (0 avg, 1 centre, 2 spot)', min: 0, max: 2, step: 1, defaultValue: 0 },+ // How far the centre-weighted falloff, or the spot, reaches: a share of the picture's height... of its width from the centre.+ { name: 'u_meterSize', label: 'Meter Size', min: 0.02, max: 1, step: 0.01, defaultValue: 0.35 },],// A few texels measure the picture, one pass keeps the settled exposure from frame to frame,// and the last applies it. The first two are small; the engine keeps the second's output.@@ -315,15 +320,33 @@ registerEffect({registerEffect({type: 'depthOfField',label: 'Depth of Field',- factory: () => postProcessEffects.createDepthOfField(),+ factory: () => postProcessEffects.createDofGather(),uniforms: [- // A WORLD length from the camera to what is in focus.+ // A WORLD length from the camera to what is in focus (what the lens rests on when Auto Focus is off).{ name: 'u_focusDistance', label: 'Focus Distance', min: 1, max: 5000, step: 1, defaultValue: 600 },+ // 1: the lens focuses on the surface under the focus point, and glides there at Focus Speed.+ { name: 'u_autoFocus', label: 'Auto Focus', min: 0, max: 1, step: 1, defaultValue: 0, neutralValue: 0 },+ // Where on the screen the auto-focus looks, as a share of its width from the left and of its height from the top.+ { name: 'u_focusX', label: 'Focus Point X', min: 0, max: 1, step: 0.01, defaultValue: 0.5 },+ { name: 'u_focusY', label: 'Focus Point Y', min: 0, max: 1, step: 0.01, defaultValue: 0.5 },+ { name: 'u_focusSpeed', label: 'Focus Speed', min: 0.1, max: 40, step: 0.1, defaultValue: 5 },// How deep a slab around it stays sharp, before the blur starts.{ name: 'u_focusRange', label: 'Focus Range', min: 0, max: 2000, step: 1, defaultValue: 100 },// The blur, in pixels, of something infinitely far: a bigger lens blurs sooner and harder.{ name: 'u_aperture', label: 'Aperture (px)', min: 0, max: 64, step: 0.5, defaultValue: 24, neutralValue: 0 },{ name: 'u_maxBlur', label: 'Max Blur (px)', min: 1, max: 32, step: 0.5, defaultValue: 14 },+ // The shape of the aperture: 0 a circle, 3 or more the number of blades of a polygon.+ { name: 'u_blades', label: 'Aperture Blades (0 = round)', min: 0, max: 9, step: 1, defaultValue: 0 },+ { name: 'u_bokehRotation', label: 'Blade Rotation', min: 0, max: 360, step: 1, defaultValue: 0 },+ // How much more a bright point counts in the blur: a lamp out of focus is a bright shape, not a smear.+ { name: 'u_highlight', label: 'Highlight Boost', min: 0, max: 8, step: 0.1, defaultValue: 0 },+ ],+ // Where the lens is focused, how blurred each pixel is, and the blur: the first is a few texels and the+ // engine keeps it from frame to frame, so an auto-focus glides.+ multiPass: [+ { name: 'dof_focus', factory: () => postProcessEffects.createDofFocus(), scale: 0.01 },+ { name: 'dof_coc', factory: () => postProcessEffects.createDofCoc() },+ { name: 'dof_gather', factory: () => postProcessEffects.createDofGather() },],});diff --git a/sdk/src/postprocess/postProcessEffects.ts b/sdk/src/postprocess/postProcessEffects.tsindex 399e5af96..d9e422c5a 100644--- a/sdk/src/postprocess/postProcessEffects.ts+++ b/sdk/src/postprocess/postProcessEffects.ts@@ -1869,6 +1869,7 @@ fn ign(p : vec2f) -> f32 {const source = `#pragma shader "PP Auto Exposure Measure"#pragma version 300 es#pragma domain PostProcess+#pragma highprecision#pragma fragmentprecision highp float;@@ -1933,8 +1934,11 @@ void main() {#pragma param u_speedDown float default(1) range(0.1,20)#pragma param u_minEV float default(-4) range(-10,0)#pragma param u_maxEV float default(4) range(0,10)+#pragma param u_metering float default(0) range(0,2)+#pragma param u_meterSize float default(0.35) range(0.02,1)#pragma param u_historyValid float default(0) range(0,1)#pragma param u_feedback texture default(black)+#pragma highprecision#pragma fragmentprecision highp float;@@ -1943,14 +1947,27 @@ in vec2 v_texCoord;uniform sampler2D u_texture;out vec4 fragColor;+/// How much a place on the screen counts: everywhere equally, a soft bright-centre bias, or a disc and nothing else.+float meterWeight(vec2 uv) {+ if (u_metering < 0.5) return 1.0;+ float r = length(uv - 0.5) / max(u_meterSize, 0.02);+ if (u_metering < 1.5) return exp(-2.0 * r * r) + 0.04;+ return r < 1.0 ? 1.0 : 0.0;+}+void main() {float sum = 0.0;float weight = 0.0;+ // The taps spread over the part of the picture that counts: all of it for an average, a region around the centre+ // for the other two, so a small spot still has taps in it.+ float extent = u_metering < 0.5 ? 1.0 : clamp(u_meterSize * 2.4, 0.1, 1.0);for (int j = 0; j < 8; ++j) {for (int i = 0; i < 8; ++i) {- vec2 m = texture(u_texture, (vec2(float(i), float(j)) + 0.5) / 8.0).rg;- sum += m.r * m.g;- weight += m.g;+ vec2 at = 0.5 + ((vec2(float(i), float(j)) + 0.5) / 8.0 - 0.5) * extent;+ vec2 m = texture(u_texture, at).rg;+ float w = meterWeight(at);+ sum += m.r * m.g * w;+ weight += m.g * w;}}// Weighted by how much of each block counted; a picture with nothing to measure@@ -1970,14 +1987,25 @@ void main() {#pragma end#pragma fragment wgsl+fn meterWeight(uv : vec2f) -> f32 {+ if (mc.u_metering < 0.5) { return 1.0; }+ let r = length(uv - vec2f(0.5)) / max(mc.u_meterSize, 0.02);+ if (mc.u_metering < 1.5) { return exp(-2.0 * r * r) + 0.04; }+ return select(0.0, 1.0, r < 1.0);+}+@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {var sum = 0.0;var weight = 0.0;+ var extent = 1.0;+ if (mc.u_metering >= 0.5) { extent = clamp(mc.u_meterSize * 2.4, 0.1, 1.0); }for (var j : i32 = 0; j < 8; j = j + 1) {for (var i : i32 = 0; i < 8; i = i + 1) {- let m = textureSampleLevel(t0, s0, (vec2f(f32(i), f32(j)) + 0.5) / 8.0, 0.0).rg;- sum = sum + m.r * m.g;- weight = weight + m.g;+ let at = vec2f(0.5) + ((vec2f(f32(i), f32(j)) + 0.5) / 8.0 - vec2f(0.5)) * extent;+ let m = textureSampleLevel(t0, s0, at, 0.0).rg;+ let w = meterWeight(at);+ sum = sum + m.r * m.g * w;+ weight = weight + m.g * w;}}var meanLog = log2(0.18);@@ -2031,105 +2059,272 @@ void main() {},/**- * Depth of field. Each pixel's circle of confusion comes from how far its surface is from the- * focus distance, and a pixel outside focus is blurred by gathering its neighbours over that- * circle. A neighbour counts only to the extent its OWN circle reaches this pixel: a sharp- * object in front of a blurred background does not bleed into it, and a blurred foreground- * does spread over what is behind. The sky counts as infinitely far.+ * Depth of field, pass 1 of 3: where the lens is focused. A few texels hold one number, the focus distance —+ * the one the author wrote, or with `u_autoFocus` on, the distance of the surface under the focus point,+ * which moves toward its target a little each frame so a rack focus is a glide and not a cut. A float+ * target, because a distance in metres is not a share of 255.*/- createDepthOfField(): ShaderHandle {+ createDofFocus(): ShaderHandle {+ const source = `#pragma shader "PP DoF Focus"+#pragma version 300 es+#pragma domain PostProcess+#pragma param u_focusDistance float default(600) range(1,5000)+#pragma param u_autoFocus float default(0) range(0,1)+#pragma param u_focusX float default(0.5) range(0,1)+#pragma param u_focusY float default(0.5) range(0,1)+#pragma param u_focusSpeed float default(5) range(0.1,40)+#pragma param u_historyValid float default(0) range(0,1)+#pragma param u_feedback texture default(black)+#pragma highprecision++#pragma fragment+precision highp float;++in vec2 v_texCoord;+uniform sampler2D u_texture;+uniform highp sampler2D u_sceneDepth;+out vec4 fragColor;++${SSAO_GLSL}++void main() {+ float prev = texture(u_feedback, vec2(0.5)).r;+ float target = u_focusDistance;+ if (u_autoFocus > 0.5) {+ ivec2 size = textureSize(u_sceneDepth, 0);+ vec3 eye = worldFromDepth(vec2(u_focusX, 1.0 - u_focusY), 0.0);+ // Nine taps a little apart: what is under the point, not whatever one pixel of it happens to be.+ float sum = 0.0;+ float n = 0.0;+ for (int j = -1; j <= 1; ++j) {+ for (int i = -1; i <= 1; ++i) {+ vec2 uv = vec2(u_focusX, 1.0 - u_focusY) + vec2(float(i), float(j)) * 0.012;+ float d = depthAt(screenTexel(uv, size), size);+ if (d >= 1.0) continue;+ sum += length(worldFromDepth(uv, d) - eye);+ n += 1.0;+ }+ }+ // Nothing but sky under the point: the lens stays where it was.+ target = n > 0.5 ? sum / n : (u_historyValid > 0.5 ? prev : u_focusDistance);+ }+ float focus = target;+ if (u_historyValid > 0.5 && prev > 0.0) {+ // In the log of the distance: the same share of a near thing and a far one per second.+ float k = 1.0 - exp(-clamp(u_time.y, 0.0, 0.25) * u_focusSpeed);+ focus = exp(mix(log(prev), log(max(target, 1e-3)), k));+ }+ fragColor = vec4(focus, 0.0, 0.0, 1.0);+}+#pragma end++#pragma fragment wgsl+${SSAO_WGSL}++@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {+ let prev = textureSampleLevel(u_feedback, u_feedback_s, vec2f(0.5), 0.0).r;+ var target_d = mc.u_focusDistance;+ if (mc.u_autoFocus > 0.5) {+ let size = vec2i(textureDimensions(t7, 0));+ let eye = worldFromDepth(vec2f(mc.u_focusX, mc.u_focusY), 0.0);+ var sum = 0.0;+ var n = 0.0;+ for (var j : i32 = -1; j <= 1; j = j + 1) {+ for (var i : i32 = -1; i <= 1; i = i + 1) {+ let uv = vec2f(mc.u_focusX, mc.u_focusY) + vec2f(f32(i), f32(j)) * 0.012;+ let d = depthAt(screenTexel(uv, size), size);+ if (d >= 1.0) { continue; }+ sum = sum + length(worldFromDepth(uv, d) - eye);+ n = n + 1.0;+ }+ }+ if (n > 0.5) { target_d = sum / n; }+ else if (mc.u_historyValid > 0.5) { target_d = prev; }+ }+ var focus = target_d;+ if (mc.u_historyValid > 0.5 && prev > 0.0) {+ let k = 1.0 - exp(-clamp(tc.u_time.y, 0.0, 0.25) * mc.u_focusSpeed);+ focus = exp(mix(log(prev), log(max(target_d, 1e-3)), k));+ }+ return vec4f(focus, 0.0, 0.0, 1.0);+}+#pragma end+`;+ return Material.compileShader(source);+ },++ /**+ * Depth of field, pass 2 of 3: how blurred each pixel is. The circle of confusion comes from how far the surface is+ * from the focus the first pass settled on (at unit 0), past the slab that stays sharp, as a share of its distance — the+ * thin-lens ratio, capped — and travels in the alpha of the scene (unit 1), so the pass that gathers does not have to find+ * a depth for every tap. A float target: a blur of 11.4 pixels is not a share of 255.+ */+ createDofCoc(): ShaderHandle {+ const source = `#pragma shader "PP DoF Circle"+#pragma version 300 es+#pragma domain PostProcess+#pragma param u_focusRange float default(100) range(0,2000)+#pragma param u_aperture float default(24) range(0,64)+#pragma param u_maxBlur float default(14) range(1,32)+#pragma highprecision++#pragma fragment+precision highp float;++in vec2 v_texCoord;+uniform sampler2D u_texture;+uniform sampler2D u_sceneTexture;+uniform highp sampler2D u_sceneDepth;+out vec4 fragColor;++${SSAO_GLSL}++void main() {+ vec4 src = texture(u_sceneTexture, v_texCoord);+ float focus = texture(u_texture, vec2(0.5)).r;+ ivec2 size = textureSize(u_sceneDepth, 0);+ float depth = depthAt(screenTexel(v_texCoord, size), size);+ float coc = min(u_aperture, u_maxBlur);+ if (depth < 1.0) {+ vec3 eye = u_camera.w > 0.5 ? u_camera.xyz : worldFromDepth(v_texCoord, 0.0);+ float dist = length(worldFromDepth(v_texCoord, depth) - eye);+ coc = min(u_aperture * max(abs(dist - focus) - u_focusRange, 0.0) / max(dist, 1e-3), u_maxBlur);+ }+ fragColor = vec4(src.rgb, coc);+}+#pragma end++#pragma fragment wgsl+${SSAO_WGSL}++@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {+ let src = textureSampleLevel(t1, s1, v.v_texCoord, 0.0);+ let focus = textureSampleLevel(t0, s0, vec2f(0.5), 0.0).r;+ let size = vec2i(textureDimensions(t7, 0));+ let depth = depthAt(screenTexel(v.v_texCoord, size), size);+ var coc = min(mc.u_aperture, mc.u_maxBlur);+ if (depth < 1.0) {+ var eye = worldFromDepth(v.v_texCoord, 0.0);+ if (frame.camera.w > 0.5) { eye = frame.camera.xyz; }+ let dist = length(worldFromDepth(v.v_texCoord, depth) - eye);+ coc = min(mc.u_aperture * max(abs(dist - focus) - mc.u_focusRange, 0.0) / max(dist, 1e-3), mc.u_maxBlur);+ }+ return vec4f(src.rgb, coc);+}+#pragma end+`;+ return Material.compileShader(source);+ },++ /**+ * Depth of field, pass 3 of 3: the blur. A pixel gathers its neighbours over its own circle, counting a neighbour+ * only to the extent that neighbour's own circle reaches back (read from the previous pass's alpha, so a sharp object in+ * front of a blurred background does not bleed into it while a blurred foreground spreads over what is behind). The taps+ * lie on a spiral inside a disc, or inside an n-sided polygon when `u_blades` is 3 or more — the shape of the lens's+ * aperture, which is what a point of light becomes out of focus — and `u_highlight` makes bright taps count for more, so+ * a lamp out of focus is a bright shape and not a dim smear.+ */+ createDofGather(): ShaderHandle {const GLSL = `-const int TAPS = 32;+const int TAPS = 64;+const float TAU = 6.2831853;float ign(vec2 p) {return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));}-/// The blur radius in pixels at a uv: how far the surface is from the focus, past the slab-/// that stays sharp, as a share of its distance — the thin-lens ratio, capped.-float cocAt(vec2 uv, float depth, vec3 eye) {- if (depth >= 1.0) return min(u_aperture, u_maxBlur);- float dist = length(worldFromDepth(uv, depth) - eye);- return min(u_aperture * max(abs(dist - u_focusDistance) - u_focusRange, 0.0) / max(dist, 1e-3), u_maxBlur);+/// A point of the unit disc pushed out to the n-gon that has the disc as its circumscribing circle.+vec2 shapeTap(vec2 p, float blades, float turn) {+ if (blades < 2.5) return p;+ float a = atan(p.y, p.x) - turn;+ float sector = TAU / blades;+ float within = mod(a + sector * 0.5, sector) - sector * 0.5;+ return p * (cos(sector * 0.5) / cos(within));}`;const WGSL = `-const TAPS : i32 = 32;+const TAPS : i32 = 64;+const TAU : f32 = 6.2831853;fn ign(p : vec2f) -> f32 {return fract(52.9829189 * fract(dot(p, vec2f(0.06711056, 0.00583715))));}-fn cocAt(uv : vec2f, depth : f32, eye : vec3f) -> f32 {- if (depth >= 1.0) { return min(mc.u_aperture, mc.u_maxBlur); }- let dist = length(worldFromDepth(uv, depth) - eye);- return min(mc.u_aperture * max(abs(dist - mc.u_focusDistance) - mc.u_focusRange, 0.0) / max(dist, 1e-3), mc.u_maxBlur);+fn shapeTap(p : vec2f, blades : f32, turn : f32) -> vec2f {+ if (blades < 2.5) { return p; }+ let a = atan2(p.y, p.x) - turn;+ let sector = TAU / blades;+ let within = (a + sector * 0.5) - sector * floor((a + sector * 0.5) / sector) - sector * 0.5;+ return p * (cos(sector * 0.5) / cos(within));}`;- const source = `#pragma shader "PP Depth of Field"+ const source = `#pragma shader "PP DoF Gather"#pragma version 300 es#pragma domain PostProcess-#pragma param u_focusDistance float default(600) range(1,5000)-#pragma param u_focusRange float default(100) range(0,2000)-#pragma param u_aperture float default(24) range(0,64)-#pragma param u_maxBlur float default(14) range(1,32)+#pragma param u_blades float default(0) range(0,9)+#pragma param u_bokehRotation float default(0) range(0,360)+#pragma param u_highlight float default(0) range(0,8)#pragma fragmentprecision highp float;in vec2 v_texCoord;uniform sampler2D u_texture;-uniform highp sampler2D u_sceneDepth;out vec4 fragColor;-${SSAO_GLSL}${GLSL}void main() {vec4 src = texture(u_texture, v_texCoord);- ivec2 size = textureSize(u_sceneDepth, 0);- vec3 eye = u_camera.w > 0.5 ? u_camera.xyz : worldFromDepth(v_texCoord, 0.0);- float coc = cocAt(v_texCoord, depthAt(screenTexel(v_texCoord, size), size), eye);- if (coc < 0.5) { fragColor = src; return; }+ float coc = src.a;+ if (coc < 0.5) { fragColor = vec4(src.rgb, 1.0); return; }vec2 texel = 1.0 / vec2(textureSize(u_texture, 0));- float rot = ign(gl_FragCoord.xy) * 6.2831853;- vec3 sum = src.rgb;- float wsum = 1.0;+ // The taps shift along their spiral by a fraction of one, a different one at each pixel: the pattern stays whole and+ // what is left of the jitter is grain a temporal pass averages away, instead of a disc turned about at random.+ float jitter = ign(gl_FragCoord.xy);+ float turn = radians(u_bokehRotation);+ float centre = 1.0 + u_highlight * smoothstep(1.0, 6.0, dot(src.rgb, vec3(0.2126, 0.7152, 0.0722)));+ vec3 sum = src.rgb * centre;+ float wsum = centre;for (int i = 0; i < TAPS; ++i) {- float r = coc * sqrt((float(i) + 0.5) / float(TAPS));- float a = float(i) * 2.39996323 + rot;- vec2 uv = v_texCoord + vec2(cos(a), sin(a)) * r * texel;- float tapCoc = cocAt(uv, depthAt(screenTexel(uv, size), size), eye);+ float k = float(i) + jitter;+ float r = sqrt((k + 0.5) / float(TAPS));+ float a = k * 2.39996323;+ vec2 disc = shapeTap(vec2(cos(a), sin(a)) * r, u_blades, turn);+ vec2 uv = v_texCoord + disc * coc * texel;+ vec4 tap = texture(u_texture, uv);// Gathered only to the extent that tap's own blur reaches back here.- float w = clamp(tapCoc / max(r, 0.5), 0.0, 1.0);- sum += texture(u_texture, uv).rgb * w;+ float w = clamp(tap.a / max(length(disc) * coc, 0.5), 0.0, 1.0);+ w *= 1.0 + u_highlight * smoothstep(1.0, 6.0, dot(tap.rgb, vec3(0.2126, 0.7152, 0.0722)));+ sum += tap.rgb * w;wsum += w;}- fragColor = vec4(sum / wsum, src.a);+ fragColor = vec4(sum / wsum, 1.0);}#pragma end#pragma fragment wgsl-${SSAO_WGSL}${WGSL}@fragment fn fs_main(v : VSOut) -> @location(0) vec4f {let src = textureSampleLevel(t0, s0, v.v_texCoord, 0.0);- let size = vec2i(textureDimensions(t7, 0));- var eye = worldFromDepth(v.v_texCoord, 0.0);- if (frame.camera.w > 0.5) { eye = frame.camera.xyz; }- let coc = cocAt(v.v_texCoord, depthAt(screenTexel(v.v_texCoord, size), size), eye);- if (coc < 0.5) { return src; }+ let coc = src.a;+ if (coc < 0.5) { return vec4f(src.rgb, 1.0); }let texel = 1.0 / vec2f(vec2i(textureDimensions(t0, 0)));- let rot = ign(v.pos.xy) * 6.2831853;- var sum = src.rgb;- var wsum = 1.0;+ let jitter = ign(v.pos.xy);+ let turn = radians(mc.u_bokehRotation);+ let centre = 1.0 + mc.u_highlight * smoothstep(1.0, 6.0, dot(src.rgb, vec3f(0.2126, 0.7152, 0.0722)));+ var sum = src.rgb * centre;+ var wsum = centre;for (var i : i32 = 0; i < TAPS; i = i + 1) {- let r = coc * sqrt((f32(i) + 0.5) / f32(TAPS));- let a = f32(i) * 2.39996323 + rot;- let uv = v.v_texCoord + vec2f(cos(a), sin(a)) * r * texel;- let tapCoc = cocAt(uv, depthAt(screenTexel(uv, size), size), eye);- let w = clamp(tapCoc / max(r, 0.5), 0.0, 1.0);- sum = sum + textureSampleLevel(t0, s0, uv, 0.0).rgb * w;+ let k = f32(i) + jitter;+ let r = sqrt((k + 0.5) / f32(TAPS));+ let a = k * 2.39996323;+ let disc = shapeTap(vec2f(cos(a), sin(a)) * r, mc.u_blades, turn);+ let uv = v.v_texCoord + disc * coc * texel;+ let tap = textureSampleLevel(t0, s0, uv, 0.0);+ var w = clamp(tap.a / max(length(disc) * coc, 0.5), 0.0, 1.0);+ w = w * (1.0 + mc.u_highlight * smoothstep(1.0, 6.0, dot(tap.rgb, vec3f(0.2126, 0.7152, 0.0722))));+ sum = sum + tap.rgb * w;wsum = wsum + w;}- return vec4f(sum / wsum, src.a);+ return vec4f(sum / wsum, 1.0);}#pragma end`;diff --git a/sdk/tests/quality.test.ts b/sdk/tests/quality.test.tsindex 025fc8f36..16a0531c4 100644--- a/sdk/tests/quality.test.ts+++ b/sdk/tests/quality.test.ts@@ -140,6 +140,9 @@ describe('what a quality level lets the chain run', () => {it('names the effects a level leaves out by type, ignoring case', async () => {const { qualityPassAllowed } = await import('../src/postprocess/qualityFilter');- expect(qualityPassAllowed(level(['DepthOfField']), 'depthOfField')).toBe(false);+ // Depth of field is three passes now, and a level that leaves it out leaves out all of them.+ for (const pass of ['dof_focus', 'dof_coc', 'dof_gather']) {+ expect(qualityPassAllowed(level(['DepthOfField']), pass), pass).toBe(false);+ }});});diff --git a/sdk/tests/shader-twins.test.ts b/sdk/tests/shader-twins.test.tsindex 26e5eedea..d871d868d 100644--- a/sdk/tests/shader-twins.test.ts+++ b/sdk/tests/shader-twins.test.ts@@ -53,7 +53,7 @@ describe('embedded .esshader structure', () => {it('found the filter, effect and grid sources', () => {expect(CASES.filter((c) => c.name.startsWith('filters.ts')).length).toBe(1);expect(CASES.filter((c) => c.name.startsWith('spriteFilter.ts')).length).toBe(2);- expect(CASES.filter((c) => c.name.startsWith('postProcessEffects.ts')).length).toBe(28);+ expect(CASES.filter((c) => c.name.startsWith('postProcessEffects.ts')).length).toBe(30);expect(CASES.filter((c) => c.name.startsWith('editorGridRenderer.ts')).length).toBe(1);});diff --git a/src/esengine/bindings/MaterialBindings.cpp b/src/esengine/bindings/MaterialBindings.cppindex 0415319ec..114f9be1d 100644--- a/src/esengine/bindings/MaterialBindings.cpp+++ b/src/esengine/bindings/MaterialBindings.cpp@@ -49,6 +49,7 @@ static MaterialUniformLayout buildMaterialLayout(const resource::ParsedShader& playout.coverageParam = parsed.coverageParam;layout.usesGBuffer = parsed.usesGBuffer;layout.usesLights = parsed.usesLights;+ layout.highPrecision = parsed.highPrecision;layout.vertexBounds = parsed.vertexBounds;layout.vertexHook = !parsed.vertexHook.empty();for (const auto& p : parsed.properties) {diff --git a/src/esengine/renderer/frame/PostProcessPipeline.cpp b/src/esengine/renderer/frame/PostProcessPipeline.cppindex 0c53e8108..9d2549d1e 100644--- a/src/esengine/renderer/frame/PostProcessPipeline.cpp+++ b/src/esengine/renderer/frame/PostProcessPipeline.cpp@@ -405,17 +405,23 @@ rg::ResourceId PostProcessPipeline::declareVelocity() {return velocity_resource_;}+bool PostProcessPipeline::passIsHighPrecision(const PostProcessPass& pass) {+ const MaterialUniformLayout* layout = context_.materials().layoutFor(pass.shader);+ return layout && layout->highPrecision && device_.supportsFloatTargets();+}+PostProcessPipeline::TemporalState* PostProcessPipeline::prepareHistory(TemporalState& state,- u32 w, u32 h) {+ u32 w, u32 h,+ GfxPixelFormat format) {w = std::max(w, 1u);h = std::max(h, 1u);if (state.history[0] && state.width == w && state.height == h- && state.format == interFormat()) {+ && state.format == format) {return &state;}for (auto& fbo : state.history) {FramebufferSpec spec;- spec.colorFormat = interFormat();+ spec.colorFormat = format;spec.width = w;spec.height = h;spec.depthStencil = false;@@ -431,7 +437,7 @@ PostProcessPipeline::TemporalState* PostProcessPipeline::prepareHistory(Temporal}state.width = w;state.height = h;- state.format = interFormat();+ state.format = format;state.valid = false;return &state;}@@ -853,6 +859,7 @@ void PostProcessPipeline::runChain(std::vector<PostProcessPass>& passes, rg::Res// chain's size — so it draws full-size whatever fraction it asked for.rg::TargetDesc writeDesc = (i == lastEnabled) ? blitDesc : desc;if (i != lastEnabled) writeDesc.scale = pass.scale;+ if (passIsHighPrecision(pass)) writeDesc.format = GfxPixelFormat::RGBA16F;// A temporal pass writes the history target itself, so that what it wrote is// still there next frame, and the passes after it read it from there.TemporalState* temporal = nullptr;@@ -862,7 +869,7 @@ void PostProcessPipeline::runChain(std::vector<PostProcessPass>& passes, rg::Resif (passIsTemporal(pass)) {// Never begun: nothing shifted this frame's picture, and nothing is remembered.if (auto it = temporal_.find(temporalKey_); it != temporal_.end() && it->second.frame > 0) {- temporal = prepareHistory(it->second, width_, height_);+ temporal = prepareHistory(it->second, width_, height_, interFormat());pass.temporal = temporal != nullptr;}} else if (passHasTexture(pass, "u_feedback")) {@@ -870,7 +877,9 @@ void PostProcessPipeline::runChain(std::vector<PostProcessPass>& passes, rg::Respass.historyKey = feedbackKey(pass.name);const u32 fw = static_cast<u32>(static_cast<f32>(width_) * pass.scale);const u32 fh = static_cast<u32>(static_cast<f32>(height_) * pass.scale);- temporal = prepareHistory(feedback_[pass.historyKey], fw, fh);+ // What it remembers is a measurement: kept in a float even where the picture is 8 bits a channel.+ temporal = prepareHistory(feedback_[pass.historyKey], fw, fh,+ passIsHighPrecision(pass) ? GfxPixelFormat::RGBA16F : interFormat());pass.feedback = temporal != nullptr;}}diff --git a/src/esengine/renderer/frame/PostProcessPipeline.hpp b/src/esengine/renderer/frame/PostProcessPipeline.hppindex 5374a26ac..b5005f8a6 100644--- a/src/esengine/renderer/frame/PostProcessPipeline.hpp+++ b/src/esengine/renderer/frame/PostProcessPipeline.hpp@@ -572,7 +572,9 @@ private:bool velocity_active_ = false;bool passHasTexture(const PostProcessPass& pass, const char* name);/// A history made (or kept) at @p w x @p h, or null when it cannot be.- TemporalState* prepareHistory(TemporalState& state, u32 w, u32 h);+ TemporalState* prepareHistory(TemporalState& state, u32 w, u32 h, GfxPixelFormat format);+ /// The pass writes a measurement, so its target is a float one where the device has them.+ bool passIsHighPrecision(const PostProcessPass& pass);/// Per pass, per view: what a `u_feedback` pass remembers.std::unordered_map<u64, TemporalState> feedback_;u64 feedbackKey(const std::string& passName) const;diff --git a/src/esengine/renderer/store/MaterialStore.hpp b/src/esengine/renderer/store/MaterialStore.hppindex 50e0be80f..1989cd137 100644--- a/src/esengine/renderer/store/MaterialStore.hpp+++ b/src/esengine/renderer/store/MaterialStore.hpp@@ -96,6 +96,8 @@ struct MaterialUniformLayout {bool usesGBuffer = false;/// The shader reads the frame's light block and shadow atlas (ParsedShader::usesLights).bool usesLights = false;+ /// The shader writes a measurement and wants a float target (ParsedShader::highPrecision).+ bool highPrecision = false;/// What the shader's vertex hook can move a vertex by (ParsedShader::vertexBounds), and whether it/// has a hook at all — culling grows a mesh's box by the first, and the shadow pass builds a/// program of its own for the second.diff --git a/src/esengine/resource/ShaderParser.cpp b/src/esengine/resource/ShaderParser.cppindex 378cefee8..aa86868d1 100644--- a/src/esengine/resource/ShaderParser.cpp+++ b/src/esengine/resource/ShaderParser.cpp@@ -704,6 +704,11 @@ ParsedShader ShaderParser::parse(const std::string& source, const ShaderIncludeRcontinue;}+ if (directive == "highprecision") {+ result.highPrecision = true;+ continue;+ }+if (directive == "vertexbounds") {// How far the vertex hook may move a vertex, in the mesh's local units.result.vertexBounds = std::strtof(argument.c_str(), nullptr);diff --git a/src/esengine/resource/ShaderParser.hpp b/src/esengine/resource/ShaderParser.hppindex 75481ea41..37d9a4093 100644--- a/src/esengine/resource/ShaderParser.hpp+++ b/src/esengine/resource/ShaderParser.hpp@@ -159,6 +159,9 @@ struct ParsedShader {/// stands, and (through `sunVisibility`) whether the shadow map says a point of air is lit — so the pipeline/// binds the block and the shadow atlas for it.bool usesLights = false;+ /// `#pragma highprecision`: what this post-process shader writes is a measurement, not a picture, so its target is+ /// a float one whenever the device can render to one — even in a chain of 8-bit pictures.+ bool highPrecision = false;/// `#pragma vertexoffset`: the body of `esMaterialVertex(inout local, inout localNormal, uv)`,/// run on a resident mesh's local-space vertex before it is posed and placed. It is the/// material's own, so the canonical mesh vertex stage calls it and a material without onediff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 3b283aea7..cba130c7c 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -2499,6 +2499,8 @@ export const NOTED = {{"note":"Reflection probes follow the weather: the ambient light scales what baked probes show and how much colour they keep."},"feat(render): puddles gather in the low places of the ground and thin on its rises":{"note":"Puddles gather in the low places of the ground and thin on its rises, read from the depth buffer."},+ "feat(render): auto exposure meters a spot, and depth of field auto-focuses and shapes its bokeh by the aperture":+ {"note":"Auto Exposure can meter the middle of the picture or a spot, and Depth of Field focuses by itself and blurs a light into the shape of its aperture."},"feat(render): reflections no longer guess a surface, plain meshes record themselves, and what the ray never finds is the sky":{"note":"Screen-space reflections leave a surface that recorded nothing alone, plain meshes now record a rough dielectric, and a puddle reflects the sky and what lies off screen."},};