# Doing the FizzleFade effect using a Feistel network

DevFeed: [Doing the FizzleFade effect using a Feistel network](<https://devfeed.tech/articles/doing-the-fizzlefade-effect-using-a-feistel-network-20604.md>)

Original publisher: [Read original article](<http://antirez.com/news/113>)

Published: 2017-08-29T14:35:14Z

Content type: article

Language: en

Sources: [Antirez](<https://devfeed.tech/sources/antirez.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [Provable security](<https://devfeed.tech/topics/provable-security.md>), [GPU](<https://devfeed.tech/topics/gpu.md>), [3D](<https://devfeed.tech/topics/3d.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [code](<https://devfeed.tech/tags/code.md>), [cryptography](<https://devfeed.tech/tags/cryptography.md>), [gpu](<https://devfeed.tech/tags/gpu.md>)

## AI overview

The article discusses reproducing Wolfenstein 3D's fizzlefade effect and proposes using a Feistel network instead of a Linear Feedback Shift Register. It explains that a Feistel network provides an invertible transformation that can produce the same pixel-ordering result across resolutions.

## Source excerpt

Today I read an interesting article about how the Wolfenstein 3D game implemented a fade effect using a Linear Feedback Shift Register. Every pixel of the screen is set red in a pseudo random way, till all the screen turns red (or other colors depending on the event happening in the game). The blog post describing the implementation is here and is a nice read: http://fabiensanglard.net/fizzlefade/index.php You may wonder why the original code used a LFSR or why I'm proposing a different approach, instead of the vanilla setPixel(rand(),rand()): doing this with a pseudo random generator, as noted in the blog post, is slow, but is also visually very unpleasant, since the more red pixels you have on the screen already, the less likely is that you hit a new yet-not-red pixel, so the final pixels take forever to turn red (I *bet* that many readers of this blog post tried it in the old times of the Spectum, C64, or later with QBASIC or GWBasic). In the final part of the blog post the author writes: "Because the effect works by plotting pixels individually, it was hard to replicate when developers tried to port the game to hardware accelerated GPU. None of the ports managed to replicate the fizzlefade except Wolf4SDL, which found a LFSR taps configuration to reach resolution higher than 320x200." While not rocket science, it was possibly hard for other resolutions to find a suitable LFSR. However regardless of the real complexity of finding an appropriate LFSR for other resolutions, the authors of the port could use another technique, called a Feistel Network, to get exactly the same result in a trivial way. What is a Feistel Network? === It's a building block typically used in cryptography: it creates a transformation between a sequence of bits and another sequence of bits, so that the transformation is always invertible, even if you use all the kind of non linear transformations inside the Feistel network. In practical terms the Feistel network can, for example, translate