Contributing features to Xen?

Sep 14, 2010 at 3:46 AM

I've been using Xen for about 6 months now, and I find it to be far more manageable than XNA.  Its got the perfect balance between features and customization, and most importantly it doesn't feel bloated like Sunburn.   Have you considered starting a company to develop middleware?  It would be interesting to see what advances can be made to Xen with access to native code. 

Now onto my topic.  I have developed several features that are both a great fit to Xen, and make heavy use of the Xen API.  The most obvious example I can think of is my PostProcessor component.

Its completely self-contained and easy to use.

Eg.

postProcessor = new PostProcessor(drawToTexture); // Pass in the Texture2D that everything gets rendered to

...

postProcessor.Initialise(this.drawToScreen); // Initialize it with the render target

...

postProcessor.Draw(state); // then draw it manually after everything (obviously since its a PostProcessor)

 

Xen.Graphics.ShaderSystem.BaseShader are required to draw the effect.  Ive got a set of about 10 effects that are are defined as StandardFilter's (such as Blur, Noise, GrayScale, Screen Transition Effects, etc) that extend an abstract class PostProcessFilter.  PostProcessFilter defines how the shader parameters should be updated before applying the effect, so these can be easily modified at runtime without directly accessing the shader.

EventHandlers can be registered with individual PostProcessFilters (OnEnabled, OnDisabled, OnTerminated) and with the PostProcessor itself (OnFilterAdded, OnFilterRemoved, OnFilterEnabled, OnFilterDisabled) to watch for changes.

 

Essentially it makes it extremely easy to apply several Post Process effects in a specific order and manage when and how they are applied.  To add new effects, all you need is the shader, and a few lines that define how it is used.

Eg.

public class BlurFilter : PostProcessing.PostProcessFilter    

{

        public const string FILTER_NAME = "Blur Filter";

       public BlurFilter()            : base(FILTER_NAME)

        {

            Initialise(typeof(Shaders.PostProcess.Blur.Effect), Settings.Resolution, HorizontalAlignment.Centre, VerticalAlignment.Centre);

        }

        public override void UpdateShaderParameters(DrawState state)

        {

            Shaders.PostProcess.Blur.Effect blurShader = ((Shaders.PostProcess.Blur.Effect)this.shader);

            blurShader.DisplayTexture = inputTexture.GetTexture();

            blurShader.FScale = 0.003f;

        }

}

 

What do ya think?

Coordinator
Sep 26, 2010 at 12:15 PM

Hi.

Sorry about my slow reply, I've been on holiday for a while :-)

Thank you for feedback :-)
I work in the game industry, and I've worked for a game industry middle ware company - so I'm well aware that it's incredibly difficult business to be successful in. From time to time I've given it some thought, but realistically it's not something I have the finances or resources to do.

As for your code, I'd be very happy to take a look at it. I've wanted to have a 'Xen.Cx' (community extensions :) project for quite a while. Xen already has some minor post processing helper code in Ex.Filters, however some dedicated post processing tools would be quite nice.

I'll have a think how best something like this could be done.

Cheers