Archive for October, 2006

Found a couple more HLSL resources. 1 tutorial + 1 sample

Tuesday, October 31st, 2006

Once again, I’ve stumbled on some cool HLSL (High Level Shader Language), but haven’t had time to seriously read it!!!

Rather than bookmarking it selfishly, I’ll continue my trend of blogging about it.  Fire and forget blogging – ROCK ON!!!

So here we go…

“XNA – Parallax Mapping” tutorial

Over at Ziggyware I found an XNA based tutorial for a Parallax Mapping Shader.  Advanced stuff by my reckoning!

Check out the “XNA – Parallax Mapping” tutorial here

“Human Skin shader” sample

I can’t remember how, but I also stumbled on what looks like some seriously hard-core shader action at “J.I. Styles | Online portfolio”.  It’s not XNA specific, but the HLSL (*.fx) file is there to download.  The sample is an awesome Human Skin shader!  Impressive!  Out of my league, but impressive!

Check out ”Adventures in HLSL pixel shaders” here

Guide to migrating an XNA app from Game Studio Express Beta 1 to Beta 2

Tuesday, October 31st, 2006

I see David “LetsKillDave” Weller has posted a short and sweet blog introducing us to some changes to XNA and how to start converting from Game Studio Express Beta 1 to the very imminent Beta 2.  This is the 1st guide I’ve seen on the subject - good stuff Dave!

Check it out here

Also, he keeps us all on the edge of our seats saying:

If you’ve read this far, you’re probably thinking, “So when will beta 2 be available?”  The answer is…look for my next post that will come within the next 24 or so hours

;)

XNA Game Studio Express Beta 2 – COMING SOON!!!

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.

XNA Code Snippet: My HLSL (*.fx file) for rendering the Aircraft

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();
}
}

Updated Screenshots: Definately NOT Smoke free!!!

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

Another new XNA game build – S-s-s-s-s-smokin’!!!

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.

Microsoft HOTFIX to fix the MS security patch (MS06-051) that broke Battlefield 2142 for some

Friday, October 20th, 2006

Bit of a mouthful, but here’s the deal.

Evidently an earlier Microsoft Security Patch (MS06-051) broke the just released BF2142 for a few unhappy souls.  Jeesh, talk about bad timing, eh!!!

So the good news is Microsoft have just released a new hotfix that fixes the problem.

Get it here.

New XNA game build & screenshots – you can blow stuff up now!!!

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

 

Sharing my XNA game source? No, but happy to share snippets.

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?

Another new XNA game build for you to try

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.