Archive for the ‘XNA’ Category

Thursday, October 26th, 2006

I’m a bit slow posting on this one, but in case you hadn’t heard already, it’s coming, and it’s coming soon.  Should be out in a couple of weeks.

:)

No word on what’s new in the Beta 2, but it’s probably a fairly safe bet that the “Content Pipeline” will be included.  At least that’s what everyone’s wishing for.  ;)

The XNA Team blog has the announcement.  Check it out here.

Average Rating: 4.6 out of 5 based on 299 user reviews.

Tuesday, October 24th, 2006

 

I promised I’d start sharing some snippets of source, so here’s the HLSL Shader code (an *.fx file) I use for rendering my Aircraft.  (as requested by Omegaman)

Those familiar with the XNA “Spacewars” sample will see an uncanny the resemblance to the sample’s Ship.fx file.  In fact it’s probably barely changed. Perhaps some trimming here and there, but I really can’t remember.

It’s pretty scary HLSL for a beginner like me.  I’d love to be able to explain it to folk, but frankly I barely understand it myself!  ;)

(next time hopefully I’ll be posting some HLSL I can at least reasonably explain)

I will try and describe its characteristics though:

  • It lights & shades the model with a provided Ambient color, a Directional light and a Point light.  Directional light is a color of light cast in a particular direction, from no particular point in space.  In other words, its brightness is the same no matter where the model is in space.  Point light however is a color radiating out from a point in space, so the closer the model is to it, the stronger the effect.
  • SkinTexture is the painted skin of the model…duh!
  • ReflectionTexture is special kind of texture – a TextureCube.  I haven’t really experimented with it but I believe the texture passed would be a mock up of the typical world around the model, and it would be rendered as ‘good enough’ reflections on the model.  I say ‘good enough’ because you’d probably have a static TextureCube of a typical sky, clouds and ground, rather than dynamically create one with the exact rendered background and moving clouds.  To do so, might be possible, but I imagine a performance killer if you had to do it on every frame.
  • I think the NormalMap stuff might be redundant actually.
//Input variables
float4x4 world;
float4x4 inverseWorld;
float4x4 worldViewProjection;
float4 viewPosition;
float4 Ambient;
float4 DirectionalDirection;
float4 DirectionalColor;
float4 PointPosition;
float4 PointColor;
float PointFactor;
float4 Material;
texture SkinTexture;
sampler Skin = sampler_state
{
Texture = (SkinTexture);
ADDRESSU = CLAMP;
ADDRESSV = CLAMP;
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};
texture NormalMapTexture;
sampler NormalMap = sampler_state
{
Texture = (NormalMapTexture);
ADDRESSU = CLAMP;
ADDRESSV = CLAMP;
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};
texture ReflectionTexture;
sampler Reflection = sampler_state
{
Texture = (ReflectionTexture);
ADDRESSU = CLAMP;
ADDRESSV = CLAMP;
MAGFILTER = LINEAR;
MINFILTER = LINEAR;
MIPFILTER = LINEAR;
};
struct VS_INPUT
{
    float4 ObjectPos: POSITION;
    float2 Tex : TEXCOORD0;
    float3 ObjectNormal : NORMAL;
};
struct VS_OUTPUT
{
float4 ScreenPos: POSITION;
float2 Tex: TEXCOORD0;
float3 WorldNormal: TEXCOORD1;
float4 PointDirection: TEXCOORD2;
};
VS_OUTPUT AircraftVS(VS_INPUT In)
{
VS_OUTPUT Out;
    //Move to screen space
    Out.ScreenPos = mul(In.ObjectPos, worldViewProjection);
    
    float4 WorldPos = mul(In.ObjectPos, world);
    float4 WorldNormal = mul(In.ObjectNormal, world);
    
    //Pass on texture coordinates and normal
    Out.Tex = In.Tex;
    Out.WorldNormal = WorldNormal;
    //Direction of point light to this vertex
    float4 lightDir;
    lightDir= PointPosition - WorldPos;
    float dist = length(lightDir);
    lightDir = lightDir/dist;
    
    //Store attenuation in w
    lightDir.w = saturate(1/(PointFactor * dist));
    Out.PointDirection = lightDir;
return Out;
}
float4 DirectionalLight(float3 WorldNormal)
{
    return DirectionalColor * saturate(dot(WorldNormal, normalize(DirectionalDirection)));
}
float4 PointLight(float3 Normal, float4 PointDirection)
{
    return PointColor * saturate(PointDirection.w * dot(Normal, normalize(PointDirection.xyz)));
}
float4 AircraftPS( float2 tex: TEXCOORD0, float3 WorldNormal : TEXCOORD1, float4 PointDirection : TEXCOORD2) : COLOR
{
    WorldNormal = normalize(WorldNormal);
    
    float4 Directional = DirectionalLight(WorldNormal);
    float4 Point = PointLight(WorldNormal, PointDirection);
    
    //Specular map is in alpha of diffusemap and material
    float MattFactor = Material.a * tex2D(Skin, tex).a;
    //Add it all up
    float4 retval;
    retval= saturate(
                Material *
                (                                        //Remove alpha channel from texture
                    ((Ambient + Directional + Point) * float4(tex2D(Skin, tex).rgb, 1)) +
                    (1-MattFactor) * texCUBE(Reflection, WorldNormal)
                )
            );
    
    
    return retval;
}
//--------------------------------------------------------------//
// Technique Section for Aircraft Effects
//--------------------------------------------------------------//
technique Aircraft
{
pass Single_Pass
{
        ZENABLE = TRUE;
        ZWRITEENABLE = TRUE;
        
        CULLMODE = CW;
        VertexShader = compile vs_1_1 AircraftVS();
        PixelShader = compile ps_2_0 AircraftPS();
}
}

Average Rating: 4.5 out of 5 based on 277 user reviews.

Tuesday, October 24th, 2006

I have updated the Latest Screenshots page with some shots of my game’s new smoke effects in action. (aka. Particle System)

Check them out over here!

Dusk smoke
Day smoke

Average Rating: 5 out of 5 based on 207 user reviews.

Tuesday, October 24th, 2006

I just uploaded another new build over here.  The aircraft now billow smoke as they take damage.

:)

p.s.  still no explosions yet.

Average Rating: 4.5 out of 5 based on 220 user reviews.

Monday, October 16th, 2006

I’ve uploaded a new build over at the Latest Build page.

New stuff?

  • Shooting actually damages things!!!
  • Plane collisions = certain death.
  • Keyboad controls changed to be more intuitive.
  • MultiSampling (aka. Antialiasing) now optional via configuration.

More info on the Latest Build page.

There are no explosions yet, but head on over and give the new build a try!  :)

I’d really appreciate some feedback, particularly around the keyboard controls.  I mostly use the XBOX 360 controller anyway,  and I’m a bit close to the keyboard problem(?) to have a realistic opinion myself.

I have also updated the Latest Screenshots page, so check out the goodness!

Title screen and menu
Dusk
Day

 

Average Rating: 5 out of 5 based on 178 user reviews.

Wednesday, October 11th, 2006

I’ve been asked in a blog comment whether I’m giving out the source.

I’m afraid,   no, sorry.   :(

Y’see, this is kind of a personal project and learning exercise for me. I first coded this exact game idea when I was 13 (that’s 23 years ago) in BASIC, but performance got rotten on those ancient “Home Computers”. And it certainly wasn’t 3D.

Now I’m much more capable and having another go…for fun.    ;)

I’m am certainly happy to share snippets and attempt to answer questions though!!!

Any special requests?

Average Rating: 4.9 out of 5 based on 272 user reviews.

Wednesday, October 11th, 2006

Howdy.

I’ve added a small menu to the Title screen.  You can now choose in-game whether to play in the bright sunny daylight setting, or moody dusk.

;)

There is a slight problem with my alignment of the menu overlay, causing a visible edge.  I rushed it – will fix.

Get it at the Latest Build Page.

p.s.  the download is now smaller, because there’s only one executable, where before I’d put in a dusk exe for the keenest customers.

Average Rating: 4.7 out of 5 based on 271 user reviews.

Tuesday, October 10th, 2006

G’day folks.

I’ve finally uploaded the latest build on the Latest Build page.

Feel free to try it out.  Remember it is a work-in-progress, and not a complete game yet.

Right now you can fly around, chase and shoot at another plane (albeit another Spitfire for now).

There’s no collision detection yet, so don’t expect any explosions or high scores yet.  ;)

The Latest Screenshots page now contains a small teaser screenshot of the newly rewritten game, and I will be uploading some proper screenshots soonish.

:)

Average Rating: 4.4 out of 5 based on 216 user reviews.

Friday, October 6th, 2006

Many people discover my blog while searching for XNA & HLSL Tutorials.

To be honest, I’m probably as much a beginner as most of you.  I do know your pain though – it’s damn hard to find an HLSL tutorial pitched at a beginner’s level.  That is why I blogged when I finally discovered some promising resources.

I’m planning to update this blog occasionally with whatever HLSL learning’s I uncover.  They will likely fall short of what you’d call a tutorial.  More likely they’ll be sporadic little journals sharing my HLSL findings as my own understanding grows.

I’ve also been in contact with the operator of the Riemers site. I’ve linked to his HLSL tutorial before and no doubt a few of you are finding it an excellent resource.

He plans to update or include more beginner’s level HLSL tutorials and has welcomed any feedback or ideas from me.  

I’ll be giving him my own wish list at some stage.

If you have any particular ideas or wishes, please leave a comment here, and I’ll be sure to pass them his way.

So what would you like to see in a beginner’s level HLSL tutorial?  Go ahead and comment!

Average Rating: 5 out of 5 based on 295 user reviews.

Monday, October 2nd, 2006

With my game (or at least work in progress) now rewritten for the XNA Framework, I thought I’d better look into how to distribute it.

Distributing the game build itself is nothing fancy.

However, an XNA game simply won’t run unless the XNA framework is installed also.  No surprise there.

Here’s the catch

Currently, while XNA is still in it’s Beta 1 phase, there is no easy way to redistribute the XNA framework dll’s along with your game build.

Sure, you could possibly try an identify the required Dll’s and through trial and error eventually get it to run.

But, you’d be violating the XNA beta 1 EULA.

This is just a temporary thing, as I believe a full (non-beta) release of XNA and Game Studio Express is planned before the end of 2006.  Don’t worry.  Microsoft most definitely wants people to be distributing their games.  That’s the whole idea!

The solution!!!

Until the full version comes out the only legal way to get an XNA game running on another machine is a bit annoying.

On the target machine you must first install the following:

  • .NET Framework v2.0 – no surprise there.
  • Microsoft C# Express
  • Microsoft Game Studio Express (beta 1).

Yep, it’s a bit of a pain to be sure.  Still, it is a “beta” remember. Mustn’t grumble. 

More details in these two MSDN threads: here & here.

Anyway, I plan to put up my first XNA build for download soon.  Unfortunately, you’ll need the above  stuff installed, which pretty much rules out all but the most motivated, or those already tinkering with XNA.

Average Rating: 4.7 out of 5 based on 288 user reviews.