Currently most of the Post Processors are handled loosely and internally by the vxRenderer class. This is great for keeping everything in one place, but it causes a lot of redundant information to be sent to the GPU each call. A perfect illustration of this is in this excerpt from the Edge Detection Post Processor code:
As you can see above, there’s a number of redundant calls to items which wouldn’t had changed from the last loop. A more efficient way would be to add these into get/set Properties and to manage the effects from within their own class.
I could’ve put each of these get/set Properties within the vxRenderer class, but then that would only add lines of code to an already very full *.cs file and makes debugging any post processor issues even more complicated.
As you can see above from the interface, There’s a ‘SetResolution()‘ method which holds any and all code that’s required to update everytime the resolution changes. This makes updating Viewport bounds that are required for most post processors to be easily reset.
There’s also a ‘LoadContent()’ method which is essentially for setting up any code outside of the Constructor.
Finally is the ‘Apply()‘ method, where the magic happens. This is a generic method where the actual effect is applied to the scene.
Further to all of this, All of the Post Processors are added to an Effects list in the Renderer. This makes any batch changes very easy to perform by simply just looping through the collection when needed and calling the required method.
In the end, this creates for a very structured way in which to handle all of the post processing effects, allowing not only a more efficient rendering loop by lessening the amount of information sent to the GPU each loop, as well as minimizes on lines of code.