SoftCat wrote on 2024-09-27, 23:38:
superfury wrote on 2024-09-27, 22:35:
SoftCat wrote on 2024-09-26, 21:33:
Here I made 80 colors using page switching. 9x9 table, two colors in it are the same. Will work under DOS on: CGA, EGA, VGA and higher. The more the colors differ on the pages, the more noticeable the flickering.
Is there a formula for the results for any framerate? Perhaps for blending images for every n nanoseconds rendered (applied to the last and newly rendered frames to get the effective new frame, based on the time between the frames's start of vertical retrace, although the time varable itself might have been 2 retraces back (instead of last) instead for that to work (so you'd get the time elapsed for the last frame and current frame together and using the current pixel color channel combined with the on-screen color channel (which is effectively the last result of the calculation for said chanenl on said position)))? That might be interesting to implement (although doubling the framebuffer size required, thus the memory requirement for it as well)? Perhaps it's some kind of phosphor effect?
Interestingly, UniPCemu already renders each frame to a new buffer, with the new buffer clearing all rendered pixels to black for a new frame to be written. Perhaps the effect can be written to that cleaning routine combined with the rendering routine of new pixels? But it's probably for the cleaning routine only, since rendering pixels would need to be more optimized due to it's latency (horizontal times vertical, both with hidden rendering etc. vs just the rendered frame resized to the user's screen).
At frame rates up to 96 Hz, you can alternate only two close colors. In general, the formula is as follows: when alternating n arbitrary colors, you need a frame rate of 48 * n Hz. If the frame rate is between 48 * (n - 1) and 48 * n, then you can confidently alternate n - 1 arbitrary colors. And to alternate n colors at such a rate, you need to specially select close colors.
What I mean is, say you've gotten the RGB values of both the old and new color, and the time they each are present on the screen (say frame 1 for 1/48th second and frame 2 for 1/48th second. Those two values (in nanoseconds for example) can vary, depending on the used framerate and when the last frame was rendered).
Is there a way, for example if you take the red channel of the first and second image and include the time it both channel values were on the screen, say, frame 0 (previous result of the calculation frame 0 1234+5678ns ago strength at 33h, frame 1 1234ns present red channel strength at 22h(256 different strengths, 0-based), frame 2 5678ns present red channel strength at 33h. Can you calculate the new channel strength to use? If so, what would said formula be?
That way you'd create some kind of feedback loop (if I'm using the right term) of basically a FIFO with taps or something like that, with the last pixels channel value flowing inside the input with timestamps (how long they were active) and the output being the newly processed pixel output in some way, using the formula? The newly generated pixel would change according to time and the last 2 pixels time on-screen etc. It would effectively be some kind of phosphor effect, lasting for 2 frames?
Edit: Maybe i'm wording it incorrectly:
The last result is in the last rendered frame (this will contain the result as well, when written back from the calculation).
The 2 most recent frames are saved as inputs as well, with their respective time this was on-screen (for the last frame till the current frame).
Is there a way to calculate the newly R/G/B result based on that input? I imagined some kind of FIFO, where the most recent and previous frames are moved in a FIFO-like way (new frame rendered makes previous frame what's currently present, the current frame becomes the new frame rendered. The delta time becomes the time since the last frame. The result frame is made from the data combined (R from frame 1, R from frame 2 and delta time (nanoseconds for example) since frame 1).