Post Process Engine Modification

Ok, a few days ago, i played with the post process engine Mahdi Khodadadi made.
It wasn’t totally fitting my needs, so I “think” i improved it a little bit. (Now, adding an effect is as simple as dropping it in the right folder, and making an advanced one is as simple as derivating the PostProcessEffect)

Today effects are : Color Tone, Combine, Gaussian Blur, Radial Blur, Smart Blur, Simple Blur, Tone Mapping, Bright Extract, Color Inverse, Edge Detection, Embossing, Sharpen, Night Time, Under Water, and differents Greyscale effects.

Here is what’s new :
*-Simples Effects can be loaded automatically, they just need to be in the right path.
*-For more sophisticated effects, just create the right .cs file, according to the ones i already made.
*-For advanced effects, simply define parameters as properties, and override what’s needed.
*-Effects are currently manager through a simple queue/dictionnary list, this will probably change in the future.
*-Viewports are recreated automatically when device lost/reset, RenderTargets too.
*-When drawing, only draw in the current viewport (should work for my splitted screen multiplayer game, although, i haven’t tested it yet) (Different effects for each players)
*-I changed the namespaces to reflect my current game architecture, and to best fit into my UML designer
*-Added some more effects from Glenn Wilson (Mykres)
*-Using a delegate for the drawing (almost all effects are using a delegate from the PostProcessManager, but a few overrides their begin/draw/end functions)
*-Can update needed variables for each effect, just overload the Update methods, default one will set any hlsl parameter whose name contains ‘timer’ to the current total second value.

Here the creation of the post process manager :

PostProcessManager ppm = new PostProcessManager(this, this.graphics.GraphicsDevice, this.content);
this.Components.Add(ppm);

And here the code you need to put in update (the effect queue is flushed every frame)

ppm.AppliedEffects.Enqueue(ppm.EffectDictionary.Keys[currentEffectIndex]);

You can DOWNLOAD the library right here (Use space to change the current effect), change it as you want, but please give credits to Mahdi, Mykres and me.
(I left the .svn folder intentionally in the zip files, so you can update to the last version, I don’t promise the Queue and Dictionnary will last a long time.)

My world map

Today I received kind of spam, but interesting this time, see by yourself, make a worldmap and win a travel where you want.

My world map

Anyway, that’s free to try !

Maybe if I’m motivated next days, i’ll post the source code and a sample for the Post Process Engine modifications I made.

Multiplayer and viewports

Ok, a few weeks ago, i implemented multiplayer views on my race game, and, i have to admit, it was pretty easy. (Thanks to XNA, defining a viewport is only a few lines of code)

so, here is the code i use to set each player it’s part in the screen (for one to four players, you just have to call this function before you draw your player X stuff).

		private void SetupViewport()
		{
			// 1 player
			if (m_raceScreen.InitDatas.TotalPlayerCount == 0) 
				return; // don't touch viewport, we're obviously the only player :)
			
			Viewport v = new Viewport();
			v.X = 0;
			v.Y = 0;
			v.Width = XeGame.Device.PresentationParameters.BackBufferWidth;
			v.Height = XeGame.Device.PresentationParameters.BackBufferHeight;

			#region 2 players
			if (m_raceScreen.InitDatas.TotalPlayerCount == 1) // 2 player
			{
				if (v.Height > v.Width) // cut height in 2
				{
					v.Height = v.Height / 2;

					if (this.m_playerIndex == PlayerIndex.One)
					{
						v.Y = 0;
					}

					if (this.m_playerIndex == PlayerIndex.Two)
					{
						v.Y = v.Height;
					}
				}
				else
				{
					v.Width = v.Width / 2;

					if (this.m_playerIndex == PlayerIndex.One)
					{
						v.X = 0;
					}
					
					if (this.m_playerIndex == PlayerIndex.Two)
					{
						v.X = v.Width;
					}
				}
			}
			#endregion

			#region 3 players
			if (m_raceScreen.InitDatas.TotalPlayerCount == 2) // 3 player
			{
				if (v.Height > v.Width)
				{
					v.Height = v.Height / 3;

					if (this.m_playerIndex == PlayerIndex.One)
						v.Y = 0;

					if (this.m_playerIndex == PlayerIndex.Two)
						v.Y = v.Height;

					if (this.m_playerIndex == PlayerIndex.Three)
						v.Y = v.Height * 2;
				}
				else // standard case (4/3, 16/9, 16/10)
				{
					v.Width = v.Width / 2;

					if (this.m_playerIndex == PlayerIndex.One)
					{
						v.Y = 0;
						v.X = 0;
					}
					
					if (this.m_playerIndex == PlayerIndex.Two)
					{
						v.Height = v.Height / 2;
						v.X = v.Width;
					}

					if (this.m_playerIndex == PlayerIndex.Three)
					{
						v.Height = v.Height / 2;
						v.X = v.Width;
						v.Y = v.Height;
					}
				}
			}
			#endregion

			#region 4 players
			if (m_raceScreen.InitDatas.TotalPlayerCount == 3) // 4 player
			{
				if (v.Height > v.Width)
				{
					v.Height = v.Height / 4;

					if (this.m_playerIndex == PlayerIndex.One)
						v.Y = 0;

					if (this.m_playerIndex == PlayerIndex.Two)
						v.Y = v.Height;

					if (this.m_playerIndex == PlayerIndex.Three)
						v.Y = v.Height * 2;

					if (this.m_playerIndex == PlayerIndex.Four)
						v.Y = v.Height * 3;
				}
				else // standard case
				{
					v.Width = v.Width / 2;
					v.Height = v.Height / 2;

					if (this.m_playerIndex == PlayerIndex.One)
					{
						v.Y = 0;
						v.X = 0;
					}

					if (this.m_playerIndex == PlayerIndex.Two)
					{
						v.Y = 0;
						v.X = v.Width;
					}

					if (this.m_playerIndex == PlayerIndex.Three)
					{
						v.X = 0;
						v.Y = v.Height;
					}

					if (this.m_playerIndex == PlayerIndex.Four)
					{
						v.X = v.Width;
						v.Y = v.Height;
					}
				}
			}
			#endregion

			XeGame.Device.Viewport = v;
		}

Actually, a lot of work have been made when i see the screenshots i took 3 months ago. (Sun is now a big heap of particles, models have been smoothed a lot, physics are almost in place, post scree processing engine have been integrated, and the SceneRenderManager is almost ready, and will makes render a lot simpler)

See by yourself : Four players Sun, planets and ship

Is there life on Mars ? (Updated)

For life, i don’t know, but, I’m pretty sure I can crash on it 🙂

Mars Asteroid Earth

uXe update

Well, after some persons want me to show the progress of my DBP entry (which now i’m sure won’t be 100% ready for july 2), i can show you a screen of the effect me and my friend (loulou again!!!) we integrated today. It’s just a simple integration of the Particle3DSample from creators club, but, hey, it’s working great, it renders nice, and with some slight modifications, fit perfectly to our needs. Screenshot and svn adress with more 🙂
Continue reading ‘uXe update’ »