Finding a color in a texture.

I’m going to mark this as answered at least before I ask my next question on the forum. Lol. Here’s the approach I described in more detail.

I made this work with a fairly approximate method. Basically, the shader can run in a couple different phases based on how precise an effect you want to achieve.

The first is the base subviewport resolution. This is the resolution that the screen with the target scene will be rendered with. A shader uses a threshold to create a mask in any one of the color channels.

The next is another viewport of the same size. This seems like a waste, but web renderers don’t screw around. This may be possible with multi-pass shaders, but this approach was the easiest to implement for me. The second viewport employs a box blur shader. The box blur splits the screen up into chunks and counts up the value in the color channel that was filtered for earlier. This effectively reduces the resolution.

Now, we can downsample safely with a third (!!) viewport. This runs surprisingly well, at least for simpler scenes. I didn’t get the parameters quite right, but the effect was still very convincing. I don’t have time to put together a project file, but that’s a pretty good process. It should even work outside of the web renderer, though you may be able to use multi-pass spatial shaders to speed things up.