MERCH!
Giant Bomb - a website about video games and the people that make them

Being Dumb

by shinali

It turns out I put way too much effort into mimicking Microsoft's way of using effects when I had the entirely wrong idea in mind. Originally, I thought the process was that you ended your drawing routine after you've ended your effect. This seemed completely backwards from MonoXNA as SpriteBatch flushes all the sprites it has to draw during its End function. It meant I went through all the wor...

It turns out I put way too much effort into mimicking Microsoft's way of using effects when I had the entirely wrong idea in mind. Originally, I thought the process was that you ended your drawing routine after you've ended your effect. This seemed completely backwards from MonoXNA as SpriteBatch flushes all the sprites it has to draw during its End function. It meant I went through all the work of saving the program off in the device to use it just in time during the Ending function of any drawing process. It turned out I was mistaken and you ended the effect before ending the drawing calls. This just let me put the glUseProgram calls back where they belong (in EffectPass.Begin and End), I still kind of kept the infrastructure I developed just in case I needed to know what program was being used.

I've also reworked how setting parameters work (parameters meaning the uniform variables in GLSL shaders). Originally I had them all assigned once some effect pass began through a function in the parameter class that would go through a mess of branches to determine what kind of variable it was, then call the according glUniform function. This system was mostly born out of the need to think up something quickly and apply it. I've had the inkling of using a delegate that would be assigned to the parameter class at its time of creation, but didn't know enough about delegates. I looked it up last night and it was much simpler than I thought, and cut down the huge mess of branches down to several lines of code. The branches moved elsewhere, but they're only called once rather than every time you begin an effect (which would be as many times as the FPS). One thing I'm concerned with is the performance of delegates, but I would imagine it would be treated like any other .NET function just because of the nature of .NET/Mono.

I've had a couple more shaders converted over but most of my time was spent developing the application that tests them, along with the same exact application using Microsoft's XNA libraries. Happy to say most shaders looked exactly the same, except for the whole blooming process which I expected wouldn't look entirely the same. I think it was because I've written the BloomCombine shader a bit differently from Bastion's, as the original starts off with a more saturated picture then works up. The odd thing is that my bloom shader looked hell of a lot better and the original looked pixelated, but this is most likely because I missed some step to set up some texture filtering to the blurred texture. I've also got to set some clamping on my shader's end as I see some parts of the image bleeding off to the opposite side.