| … | … | @@ -0,0 +1,68 @@ |
| 1 | """ |
| 2 | Proves the viewport overlay actually reaches 1:1. |
| 3 | |
| 4 | The internal render resolution is divided down while the camera moves, because every |
| 5 | frame throws its samples away and one dispatch has to cover the whole image. The |
| 6 | comment said full resolution returned once the view settled. It did not: the settled |
| 7 | tier was DIVISOR 2, so the overlay was permanently half resolution per axis - a |
| 8 | quarter of the pixels - scaled up. That was the ceiling on how sharp it could look, |
| 9 | and it coarsened the depth texture too, which is why occlusion edges were blocky. |
| 10 | |
| 11 | Nothing caught it because the code was self-consistent and only the comment was |
| 12 | wrong, and a permanently soft overlay looks like a design choice rather than a bug. |
| 13 | So this asserts the property the comment claims, not the constants themselves. |
| 14 | |
| 15 | Runs inside Blender (ifs_viewport imports bpy and gpu): |
| 16 | blender -b --factory-startup -noaudio --python blender/test_viewport_resolution.py |
| 17 | """ |
| 18 | |
| 19 | import os |
| 20 | import sys |
| 21 | import unittest |
| 22 | |
| 23 | sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) |
| 24 | |
| 25 | |
| 26 | class ViewportResolution(unittest.TestCase): |
| 27 | @classmethod |
| 28 | def setUpClass(cls): |
| 29 | try: |
| 30 | import ifs_viewport |
| 31 | except ImportError as ex: |
| 32 | raise unittest.SkipTest(f"needs Blender's bpy/gpu modules ({ex})") |
| 33 | cls.Session = ifs_viewport.Session |
| 34 | |
| 35 | def test_a_settled_view_eventually_renders_at_full_resolution(self): |
| 36 | """The whole point: without this the overlay can never be sharper than half.""" |
| 37 | self.assertEqual(1, self.Session.divisor_for(10_000), |
| 38 | "a long-settled view still renders below 1:1, so the overlay " |
| 39 | "is permanently softer than the screen") |
| 40 | |
| 41 | def test_motion_is_coarser_than_rest(self): |
| 42 | """The coarse tier is what keeps mouselook readable; losing it is also a bug.""" |
| 43 | moving = self.Session.divisor_for(0) |
| 44 | settled = self.Session.divisor_for(10_000) |
| 45 | self.assertGreater(moving, settled) |
| 46 | |
| 47 | def test_resolution_never_gets_coarser_as_the_view_settles(self): |
| 48 | """ |
| 49 | Monotonic by frame count. A non-monotonic schedule would resize - and so throw |
| 50 | away the accumulation - repeatedly while the user sits still. |
| 51 | """ |
| 52 | divisors = [self.Session.divisor_for(n) for n in range(0, 200)] |
| 53 | for earlier, later in zip(divisors, divisors[1:]): |
| 54 | self.assertLessEqual(later, earlier, |
| 55 | "the divisor increased as the view settled") |
| 56 | |
| 57 | def test_it_steps_rather_than_jumping_straight_to_full(self): |
| 58 | """ |
| 59 | The middle tier gives a readable image within a few frames of stopping; |
| 60 | jumping straight to 1:1 leaves a long noisy period instead. |
| 61 | """ |
| 62 | seen = {self.Session.divisor_for(n) for n in range(0, 200)} |
| 63 | self.assertGreaterEqual(len(seen), 3, |
| 64 | f"expected a stepped schedule, got tiers {sorted(seen)}") |
| 65 | |
| 66 | |
| 67 | if __name__ == "__main__": |
| 68 | unittest.main(argv=sys.argv[:1], exit=False, verbosity=2) |