This shader sprung from an idea given to solve the problem "How can I implement a XOR effect in MMF using HWA?". Well, obviously, bitwise operators weren't available until Shader Model 4.0, so that was right out of the question. Instead, a friend suggested implementing a XOR lookup table, and converting channel values to integer using the smoothstep() function.
I soon realized that implementing the table as a texture allowed me to use floating point values instead, with an arbitrary channel bit-depth accuracy (!), and furthermore, as a side effect of implementing the lookup table as a texture, any generic texture could be used as a lookup table, essentially making this a generic shader for pretty much any simple expression blend mode.
What does this mean for you? It means that you no longer have to write or use separate shaders to implement a myriad of blend modes into your application; simply use Easy Blend for pretty much everything, and never worry about shader incompatibilities between people again. What's more, anyone can create a blend mode for a shader now -- all they have to do is open up their favorite image editor, and play around. Or, generate a texture algorithmically using the Surface Object, or whatever you want!
In my example, I've included a set of common blends you can try out for yourself. The simple explanation for how the blends work is: the X axis represents the background color on the channel specified, whereas the Y axis represents the foreground. The shader looks at that (x,y) location and retrieves the output intensity from the channel specified. You can have seperate intensities for each color channel for the ultimate tweaking! Or, just stick with grayscale for more traditional blend modes. The choice is up to you; the possibilities are endless! :grin:
Screenshot (using Screen blending):