Re:Perspective-Correct Interpolation
by magicalhippo on Wednesday June 12, 2024 @12:25PM
(#40659887)
Reminded me of Quake's trick[1] of calculating the perspective correction every 16 pixels, as you then effectively got it for free on a Pentium processor.
Re:Perspective-Correct Interpolation
by atilimcetin on Wednesday June 12, 2024 @01:16PM
(#40660560)
I remembered the same. Perspective correction needs a division operation for each pixel and while drawing a scanline, calculating it every 16 pixels and linearly interpolating between them make a huge speed difference.
Re:Perspective-Correct Interpolation
by groby_b on Thursday June 13, 2024 @10:08PM
(#40676895)
It turns out we all could count cycles.
Seriously, this keeps getting overhyped as some gigantic insight when it was really just a consequence of the Pentium having been released in 1993. And with the Pentium, you got both reliable FPU availability (none of the 486SX pain), and the cycle count for FDIV dropped by almost 50% (73->39 IIRC)
Everybody doing 3d gfx knew you needed a perspective divide and was looking at ways to do that cheaply. Interpolation + a long-latency instruction that doesn't block the main pipelines is a fairly straightforward answer.
Re:Perspective-Correct Interpolation
by magicalhippo on Thursday June 13, 2024 @10:35PM
(#40677046)
I seem to recall reading about it in one of the demo code articles floating about at the time, similar to this one[1]. But Quake is the one that stuck with me for some reason, and it's easy to link to.
Re:Perspective-Correct Interpolation
by groby_b on Friday June 14, 2024 @05:25PM
(#40685296)
Abrash was a prominent and prolific writer at the time (in addition to be an excellent coder). That might have helped enough to make that example stick for folks.
But also worth noting that that article is dated one year after quake, two years after descent.
Also, lysator... there's a name I haven't heard in a while! Thanks for reminding me.
Re:Perspective-Correct Interpolation
by sylefeb on Thursday June 13, 2024 @03:45PM
(#40673779)
This is a fascinating topic, especially when considering how this was achieved back in the days. We now take it for granted, but this was not a simple feature to have in your game in 199x ( x<6 ;) ).
Re:Perspective-Correct Interpolation
by nmeofthestate on Thursday June 13, 2024 @03:55PM
(#40673924)
The funny thing about this was that by the time you'd finished a 10 hour session of Tomb Raider you got used to the effect, so reality looked weirdly distorted for a while after.
Re:Perspective-Correct Interpolation
by reasonableklout on Friday June 14, 2024 @04:44PM
(#40684927)
[author] Thanks for reposting this! It was a small but cool learning that all perspective correction needs is dividing screen-space barycentrics by vertex depths and normalizing. I wanted to share my understanding of the math.
3D graphics is a rich and old field with lots of tricks like this. It's cool to see faster algorithms and alternative explanations in the comments!
The proper solution is this: https://gamedev.stackexchange.com/a/63203
[1]: https://www.bluesnews.com/abrash/chap68.shtml
Seriously, this keeps getting overhyped as some gigantic insight when it was really just a consequence of the Pentium having been released in 1993. And with the Pentium, you got both reliable FPU availability (none of the 486SX pain), and the cycle count for FDIV dropped by almost 50% (73->39 IIRC)
Everybody doing 3d gfx knew you needed a perspective divide and was looking at ways to do that cheaply. Interpolation + a long-latency instruction that doesn't block the main pipelines is a fairly straightforward answer.
[1]: https://www.lysator.liu.se/~mikaelk/doc/perspectivetexture/
But also worth noting that that article is dated one year after quake, two years after descent.
Also, lysator... there's a name I haven't heard in a while! Thanks for reminding me.
For anyone interested: I have a detailed write up on the topic here in the context of 1990s renderers https://github.com/sylefeb/tinygpus/tree/main?tab=readme-ov-... ; a video discussing texture mapping with a hardware twist https://youtu.be/2ZAIIDXoBis?si=MvQXH2ltqWmvFMdt&t=1072 ; and have a shadertoy to compare perspective correct texture mapping on/off https://www.shadertoy.com/view/ftKSzR
3D graphics is a rich and old field with lots of tricks like this. It's cool to see faster algorithms and alternative explanations in the comments!