Profil von PetriDark Codex StudiosFotosBlogListenMehr ![]() | Hilfe |
|
19 November Getting stable againFinally, my time is starting to get stable. I'm used to traveling every week now, and both the projects I'm on is beginning to get over the "startup period". This means I will get a bit more time and be able to create some tutorials and make some updates to this blog again.
I also have used a lot of time writing a long article for a magazine about XNA Shader Programming. More info about this will be written later, but the article is finished and is in the publishing process. Quite cool! :)
Anyway, the book "3D Game Development with Microsoft Silverlight 3: Beginner's Guide"( using Balder ;) ), by Gastón C. Hillar, is published and can be found here. The book contains a lot of samples, witch can be downloaded from here.
I got a copy of the book myself and have read a lot of it and it's really great. A good read, clear, good examples and very easy to follow. If you are in to Silverlight and want to look at the Silverlight world from a 3D perspective, I would recommend this book. 18 November Dark Codex received 100.000 NOK for the development of myBeastAs some of you know, Dark Codex Studio and Tumbleweed is creating the game myBeast for the popular iPhone platform. After a long process, Dark Codex Studio was one of the selected companies to get support from Norsk Filmfond, for the myBeast project. With a sum of 100.000 NOK, the development of myBeast will be a lot easier as Dark Codex is a new DA company.
More information( Norwegian ):
06 November Dragon AgeI got my copy of Dragon Age Origins this other day, but are still waiting for the release on PS3..
So far, the game is really great. Back in the earlier days I played a lot of Baldur's Gate and Neverwinter nights and I'm sure this game will be just as great. At least I'm hooked so far.. The graphics is awesome!!!
I'm playing as a Human Rouge, going for archery for a start, but guess I will try all the start stories to see what's the most fun and then move from there.
Anyway, I spent a few days in Finland earlier this week as I'm on a project for Nokia, and will be going back there tomorrow so it won't be much time for gaming.. Guess Dragon Age got to wait a few more days..
31 Oktober Happy Halloween21 Oktober Lack of timeSo, it's been a while since last time I was blogging. This is because I have been VERY busy with work as I'm rolling of the Telenor Way of Work project. From next week I will work more with UI/UX both in Norway and Finland. Looking forward to this :) 04 Oktober XNA Shader Programming - Tutorial 24, BloomXNA Shader Programming
Tutorial 24 - Bloom post process shader
Welcome to the XNA Shader Programming Tutorial 24. Today, we are going to implement a bloom effect. The shader will be a post process shader, and will bloom any given texture. I learned blooming from http://xna.creators.com, so this implementation is based on this example.
What is Blooming?
Well, blooming occurs when colors flows over to surrounding pixels, brightening or overexposing them in the process. The dark pixels on the edges of bright pixels will get affected by the bright pixels, making the dark pixels lose some details. Fig 24.2 shows the difference between a scene with bloom (left) and one without bloom (right).
Fig 24.2 - Difference between bloom an non-bloom scene
We will need a few render targets to archive the bloom effect. First is the original scene, then we will one texture that will contain the blooming and two textures that will contain the blurred version of the bloom scene.
The 1st blur texture will blur the bloom texture once, and the 2nd blur texture will blur the 1st blur texture, creating a better looking blur. Our blur shader is not the best way of blurring but its good enough. If you want to create a more advances blur effect, look up “Gaussian blur”.
The first thing we will do is to render the normal scene to a texture. Next, we need to extract the bright areas in the original scene and store it in another texture named BloomTexture. We will use a shader to extract the bright colors. What this shader will do is to get a pixel from the original scene, and based on a threshold variable, calculate if this color is bright enough for the blooming effect.
Threshold will contain a value between 0.0 and 1.0, and is used to remove colorinformation from Color that is below Threshold.
Fig 24.3 contains our bloom texture, based on the original scene with a Threshold of 0,3f. As you can see, the scene removes everything dark( based on Threshold ) and keeps the rest. sampler TextureSampler : register(s0);
// Get the threshold of what brightness level we want to glow float Threshold = 0.3;
float4 PixelShader(float2 texCoord : TEXCOORD0) : COLOR0 { float4 Color = tex2D(TextureSampler, texCoord);
// Get the bright areas that is brighter than Threshold and return it. return saturate((Color - Threshold) / (1 - Threshold)); }
technique Bloom { pass P0 { // A post process shader only needs a pixel shader. PixelShader = compile ps_2_0 PixelShader(); } }
Next, we will need to blur this scene. We will use the same blur effect as we used in tutorial 23 (blur), but this time we will use it two times to blur the scene a bit better. Fig 24.4 shows the 2x blurred version of our blooming texture. Fig 24.4 – Blurred version of our bloom texture
The last thing we will do is to combine the original scene with the blurred bloom texture. We could just have rendered the original scene, and blended the bloom texture over it to combine the original scene with the bloom texture, but this would not look that good and we would have non flexibility in the combination process. So, what does this mean? You guessed right, we will make a new shader that will combine the two textures!
This shader will have four parameters that you can use to control the combination process. These are the intensity of our bloom texture and the original scene texture, and the saturation of the original scene texture and the bloom textures. float BloomIntensity = 1.3;
// Controls the Intensity of the original scene texture float OriginalIntensity = 1.0;
// Saturation amount on bloom float BloomSaturation = 1.0;
// Saturation amount on original scene float OriginalSaturation = 1.0;
We give them a default value, but you can control this from the application that will use this shader.
Next, we create a function that will help us with color saturation (the difference of a color against gray, or its own brightness). This function will saturate a given input color, based on a saturation value and the gray color we used to make a grayscale scene earlier in this article. { // We define gray as the same color we used in the grayscale shader float grey = dot(color, float3(0.3, 0.59, 0.11));
return lerp(grey, color, saturation); }
Let’s move on, and start on the PixelShader function. We start by getting the color from our blurred bloom texture, and the original scene. float4 bloomColor = tex2D(BloomSampler, texCoord);
// Get our original pixel from ColorMap float4 originalColor = tex2D(ColorMapSampler, texCoord);
Next, we use the AdjustSaturation function to adjust the bloomColor and originalColor based on the parameters we added to the shader. bloomColor = AdjustSaturation(bloomColor, BloomSaturation) * BloomIntensity; originalColor = AdjustSaturation(originalColor, OriginalSaturation) * OriginalIntensity;
Using these parameters, you can make the original scene very dark, and only bloomed areas bright and vice versa. You should play around with these values to see how this works!
We continue the pixel shader by darkening the original scene where the bloomColor is bright, so we avoid making these areas burned-out. originalColor *= (1 - saturate(bloomColor));
Now, the final step is to combine the textures. return originalColor + bloomColor;
No magic behind this, just return the two colors added together!
And boom you got bloom! Pretty simple, right? All we do is really just combining a few simple shaders to create an advances effect.
Listing 11 – CombineBloom.fx // BloomIntensity, OriginalIntensity, BloomSaturation and OriginalSaturation is used // to control the blooming effect. // This shader is based on the example in creators.xna.com, where I learned this technique.
// Our bloom texture sampler BloomSampler : register(s0);
// Our original SceneTexture texture ColorMap;
// Create a sampler for the ColorMap texture using lianear filtering and clamping sampler ColorMapSampler = sampler_state { Texture = <ColorMap>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = Clamp; AddressV = Clamp; };
// Controls the Intensity of the bloom texture float BloomIntensity = 1.3;
// Controls the Intensity of the original scene texture float OriginalIntensity = 1.0;
// Saturation amount on bloom float BloomSaturation = 1.0;
// Saturation amount on original scene float OriginalSaturation = 1.0;
float4 AdjustSaturation(float4 color, float saturation) { // We define gray as the same color we used in the grayscale shader float grey = dot(color, float3(0.3, 0.59, 0.11));
return lerp(grey, color, saturation); }
float4 PixelShader(float2 texCoord : TEXCOORD0) : COLOR0 { // Get our bloom pixel from bloom texture float4 bloomColor = tex2D(BloomSampler, texCoord);
// Get our original pixel from ColorMap float4 originalColor = tex2D(ColorMapSampler, texCoord);
// Adjust color saturation and intensity based on the input variables to the shader bloomColor = AdjustSaturation(bloomColor, BloomSaturation) * BloomIntensity; originalColor = AdjustSaturation(originalColor, OriginalSaturation) * OriginalIntensity;
// make the originalColor darker in very bright areas, avoiding these areas look burned-out originalColor *= (1 - saturate(bloomColor));
// Combine the two images. return originalColor + bloomColor; }
technique BloomCombine { pass P0 { // A post process shader only needs a pixel shader. PixelShader = compile ps_2_0 PixelShader(); } }
YouTube - XNA Shader programming, Tutorial 24 - Bloom post process Source and Executable: Tutorial 24 - Bloom XNA Shader Programming - Tutorial 23, Blur post processXNA Shader Programming
Tutorial 23 - Blur post process shader
Welcome to the XNA Shader Programming Tutorial 23. Today, we are going to implement a simple version of blur. The shader will be a post process shader, an will blur any given texture.
Implementing the Shader
To blur a scene, we will need to implement a new post process shader that will take the average of a number of the pixels neighbor pixels, and return that color as the color we want the player to see. The blur shader will have a distance variable that will be used to modify the texture coordinate we will use as a lookup texture containing our normal scene, so it takes the top-left, top-right, bottom-left and bottom-right pixel, adds them together and divides it by 4 so we get the average.
On the image, you can see the blur shader in effect. The shader takes the average of the surrounding pixels with a given distance (in this case 0.002) set in the shader or in the application.
Fig 23.2 - This shows how the blur shader works( From tutorial 19 )
The following piece of code looks up the pixels surrounding the current pixel that is being processed.
Color = tex2D( ColorMapSampler, float2(Tex.x+BlurDistance, Tex.y+BlurDistance)); Color += tex2D( ColorMapSampler, float2(Tex.x-BlurDistance, Tex.y-BlurDistance));
Color += tex2D( ColorMapSampler, float2(Tex.x+BlurDistance, Tex.y-BlurDistance));
Color += tex2D( ColorMapSampler, float2(Tex.x-BlurDistance, Tex.y+BlurDistance));
We simply just modify the pixel to grab the surrounding pixels and add it to our color. Next, we need to divide color by 4 so we get the average color.
Color = Color / 4; Listing 23.1 – Blur post process shader
// The blur amount( how far away from our texel will we look up neighbour texels? ) float BlurDistance = 0.002f;
// This will use the texture bound to the object( like from the sprite batch ).
sampler ColorMapSampler : register(s0);
float4 PixelShader(float2 Tex: TEXCOORD0) : COLOR
{
float4 Color;
// Get the texel from ColorMapSampler using a modified texture coordinate. This
// gets the texels at the neighbour texels and adds it to Color.
Color = tex2D( ColorMapSampler, float2(Tex.x+BlurDistance, Tex.y+BlurDistance));
Color += tex2D( ColorMapSampler, float2(Tex.x-BlurDistance, Tex.y-BlurDistance));
Color += tex2D( ColorMapSampler, float2(Tex.x+BlurDistance, Tex.y-BlurDistance));
Color += tex2D( ColorMapSampler, float2(Tex.x-BlurDistance, Tex.y+BlurDistance));
// We need to devide the color with the amount of times we added
// a color to it, in this case 4, to get the avg. color
Color = Color / 4;
// returned the blurred color
return Color;
}
technique PostProcess
{
pass P0
{
// A post process shader only needs a pixel shader.
PixelShader = compile ps_2_0 PixelShader();
}
}
This was a pretty simple blur effect. You can also create blur effects by rendering to a downscaled texture. You can downscale multiple times to create a nice blur. You could also use this shader and blur a texture multiple times to create a better looking blur.
I have added a line crossing the scene, where the left side of the line is the blurred scene, and the right side of the screen is the original scene.
I will wite a tutorial on Gaussian Blur later, as this blur effect is not very nice. But to get better results with this shader, you can blur a scene multiple times using this shader.
Source and Executable: Tutorial 23 - Blur 02 Oktober Demo: Break a LegBreak a Leg is a really fun and addicting 1st person platform/action game created by a Norwegian team from NITH. In this game, you have to move through a city by breaking the laws of physics, using jump-pads on top of buildings, a lot of coordination, creativity and air-time, on the shortest time possible.
The graphics look great, and the levels have been designed in a really great way, making one level fun to play for many many hours( yeah, I did that ). You must race agains time, a ghost of your previous best run or your friend in two-player mode.
You can read more about the game on gamer.no (Norwegian), or on the developers journal (Norwegian), or best of all: Try the game for yourself on your own computer!
So, what are you waiting for? Jump, fly, SMASH !
Demo( 330 MB ):
16 September Follow the MyBeast developmentDark Codex Studios and Tumbleweed Interactive are Co-Operating on a game project named MyBeast.
The Developer Journal from the game have just been released, and will be updated frequently.
The journal can be found here: http://forums.tigsource.com/index.php?topic=8240.0
Game Camp stand at Game On tomorrow!Are you are going to Game On tomorrow? Be sure to visit our stand!
Me and Thomas Beswick will be standing there all evening, providing you with information about cool technology:
- What is Game Camp?
- How you can start creating games using XNA
- Provide you with a complete game and source-code
- Project NATAL
- Lionhead's Milo
See you there! 08 September Fixing the missing file( SkinnedModelPipeline ) error when compiling Mage Defender: RemakeI got some feedback that there is a file missing from the project, so I uploaded the file and it can be downloded below.
To fix this issue, follow these steps:
2 - Add the SkinnedModelPipeline.dll file to the Referenced under Content in the Mage Defender project:
![]() 3 - Compile and run!
Thats it, please tell me if you still have any problems with this! 07 September Game On Invitation( Norwegian )Hei alle sammen, Din nye hverdag med fremtidens spillteknologi Tumbleweed Interactive om dagens spillbransje 06 September Mage Defender on CodePlexMage Defender: Remake is now on CodePlex, and can be found on the following URL: http://magedefender.codeplex.com/
From there you can download the newest sourcecode when we release it, and download the newest releases.
Have fun!
05 September Final Fantasy VII out on PS3For those of you who didn't know, one of the best games ever made is out on PS3( Since GameCon in Germany ): Final Fantasy VII.
I still got my original PS1 game( Yes, you can play PS1 games on PS3 now.. ), but for those of you who want to experience this great adventure, go to the PS Store and buy it for a very cheap price compared to what you will get ;)
03 September Mage Defender, XNA Game with sourceMage Defender Remake
Today, we released the newest version of Mage Defender, created in XNA as apart of Thomas Beswicks and my "Creating a game from A-Z" presentation held at Game Camp, 03.09.2009. Note: The download-URL for these files will change( and be updated ) once I find another host. Credits:
Programming: Petri Wilhelmsen
Idea: Petri Wilhelmsen, Thomas Beswick
Art: Thomas Beswick
Music: Egil Hasting aka. Higen
Special thanks to: Tuuli Savolainen, Laura Marie Tan, Sindre Rian, Victor Bredholt, Ragnar Fatland The game is much more advanced than ever, with full 3D-Cel shading, animations and particles. The game got many adcanced spells, AI, bosses and a short story mode. ![]() Made Defender Remake for PC and XBox360.
So, as I promised, the game will be released with it's full source code.
There are some small things that I need to change before I upload the game, but it will be up today or tomorrow. A new post will be added with the link, and a codeplex page will be created for the project. Download ( XNA 3.1 ):
Source( 63mb ) Binary Installer( 29mb ) Note: The URL for these files will change( and be updated ) once I find another host. If you are missing a refernece( SkinnedModelPipline ) follow these steps in order to fix this issue:
2 - Add the SkinnedModelPipeline.dll file to the Referenced under Content in the Mage Defender project:
![]() 3 - Compile and run!
Thats it, please tell me if you still have any problems with this!
A history on Mage Defender Mage Defender, Original
In 1999, I created a DOS game named Mage Defender. You were a mage, and had to shoot slimes to protect your castle.
If slimes managed to pass you, the castle lost lives, and if one hit you, you lost lives. Mage Defender Deluxe, Silverlight
So, in 2007 I wanted to learn Silverlight 1.1, and decided to make a remake of the game. The game got a little more advanced, with multiple spells and castle levels, but still only slimes to kill. You also get Ability Points during level up,so you can spec. your player. Screenshots from my old gamesHi,
I was going trough my old project files when cleaining up my drives today, and found some old games that me and my friends have created back in the old days.
I decided to put them up here, to save them and share them with you.
Enjoy :P
The start of Project Ice Eagle, got pretty far on this. Tried it out a bit and found it rather funny. Discworld/Terry Prachett type of humor :P
The next few screenshots are from Veneficus, a story of magic. This is the game that almost finished, but died once the hardware got too good, classic.
The start of a new 3D engine named DeBreeze Engine 2.0, the same engine used for Veneficus( 2004 ) and Ice Eagle(2003). The engine was started in 2002, with the basis on the above Mage Defender II engine.
And this last image is from my first DirectX application ever, created in 2000. The models are created by Thomas Beswick. As we went to different schools, he created the models and copied them out on multiple floppies, sending them to me by my brother as they were in the same school. :P I had to wait multiple days between each model delivery, as the discs usually got corrupt and had to wait on a new delivery. :P 01 September SaveState not working?As you might have experienced when using XNA, some of the render states are set incorrectly when rendering sprites with SpriteBatch or when rendering a model using a shader. Remember, SaveState is a heavy process so use it only when you really need this, try setting the render states manually instead!
There are many posts about this issue, but I will create another myself, as I came across another problem( see last solution point ).
Let's take a look on common solutions to this problem.
My render states get distorted after rendering sprites/textures with SpriteBatch To solve this, you can set the SaveStateMode to SaveState when calling the Begin() method of SpriteBatch. spriteBatch.Begin( SpriteBlendMode.None, SpriteSortMode.Immediate, SaveStateMode.SaveState);// Render your sprites spriteBatch.End(); If SaveStateMode is set to SaveState, a StateBlock object will capture the current state of you rendering device. Once you call End(), the StateBlock will call Apply(), witch applies the state captured earlier. This usually works in most situations. My render states get distorted after rendering a model using a shader/effect To solve this, you can set the SaveStateMode to SaveState when calling the Begin() method of Effect. effect.Begin(SaveStateMode.SaveState); Again, If SaveStateMode is set to SaveState, a StateBlock object will capture the current state of you rendering device. Once you call End(), the StateBlock will call Apply(), witch applies the state captured earlier. This usually works in most situations. I am saving the state on my sprites/models, but the renderstates still get distorted!?? Ok, this is the problem I had today. I was rendering a 3D model, and after rendering it, everything got distorted.. I tried, just for fun, to call spriteBatch.Begin(...SaveState), render the model, and calling spriteBatch.End(). This worked by my model got some big problems related to the Z-buffer/Depth buffer and so on, so the model got pretty ugly. I also tried to set the SaveStateMode to SaveState in Effect.Begin(..) and in mesh.Draw(SaveStateMode.SaveState); but without any luck.. So, finally, I treid to save the state manually, and to my suprise, it worked very well! :D To save the state manually, add the following lines of code to your application: StateBlock stateBlock = new StateBlock(GraphicsDevice); // pass in your GraphicsDevice here. stateBlock.Capture(); // Saves the state. //Do your magic, like mesh.Draw(); stateBlock.Apply(); // restores the state again.
Good luck! 30 August Game Camp Event teaser27 August Game Camp 3. September 2009, be there!It's just one week before the Game Camp user group for Septemner 09 starts. The agenda just got nailed, so get prepared for some good sessions and join us for a nice and free evening at NITH. :)
The event starts at 18:00 and lasts to about 21:30, but feel free to attend to whatever session you like!
Agenda:
18:00 - 19:00 “Creating a game from A-Z” by Petri Wilhelmsen and Thomas Beswick 19:15 - 20:15 3D Game engine design by Einar Ingebrigtsen 20:30 - 21:30 Hvordan får pengestøtte til spill by Tumbleweed Interactive Speakers:
How to get there:
Norges Informasjonsteknologiske høgskole (NITH)
Schweigaards gate 14, 0185 Oslo Norway
|
|
|