XNA UK User Group

A helping hand for bedroom coders throughout the land.
in

This Blog

Syndication

Twitters

RandomChaos

  • Still in 2D

    http://www.youtube.com/v/KCfAHoNR5W0 <p><a href="http://www.youtube.com/v/KCfAHoNR5W0">http://www.youtube.com/v/KCfAHoNR5W0</a></p>

    Yes, still playing about with these 2 dimensions, not as limiting as I thought it would be and XNA makes it very easy to implement. Just need to do shields, health, bombs and buildings now and I think I'll have a nice 4 player game to play with..

  • Nebulon is in Peer Review!

    If you have a creators club premium account, please help us out by reviewing the game for us here:

    http://catalog.xna.com/en-GB/GameDetails.aspx?catalogEntryId=7432580d-50e3-439e-b180-f1ca39df65a3&type=1

    We could really do with you guys getting into Nebulon and playing it to death, we don’t want it going out with any issues, so if you have a CC account, then please give it a go, let us know what you think, then once it’s on XBLCG, buy a copy :P

    Thanks.

    Posted Jul 02 2009, 11:17 AM by Nemo Krad with no comments
    Filed under:
  • Microsoft MVP!

    So, I opened my mail box up just before I knocked off work yesterday and lo and behold there was a mail from the Microsoft MVP Program. I knew that I had been nominated, and to be honest I was more than honoured to get that, but opening up the mail yesterday and reading that I have been accepted as an MVP for contributions to XNA/DirectX communities I almost fell off my chair.

    It is a great honour to have been made and MVP, and I hope to contribute more to the community and get more involved too. So, thanks to Microsoft for the award, to those that nominated me and to the followers of my community input.

  • More 2D Stuff

    http://www.youtube.com/v/GaSr9315U80 <p><a href="http://www.youtube.com/v/GaSr9315U80">http://www.youtube.com/v/GaSr9315U80</a></p>

    As you can see from the clip, I have done a bit more and I think this may well turn into a game. Currently thinking of it as a 4 local player game death match type thing.

    Don't worry, I will get back to some 3D stuff soon :)

  • Playing with 2D

    http://www.youtube.com/v/IXE-rsZRHDs <p><a href="http://www.youtube.com/v/IXE-rsZRHDs">http://www.youtube.com/v/IXE-rsZRHDs</a></p>

    Well, seeing as most of the world seems to be using XNA to produce 2D games, as well as my good friend Dave who’s Dark Omen Games Nebulon is now out of play test and going into Review (do you like the plug?) I thought I would have a play.

    So what’s in the clip I have put up here? Well, I have ported my 3D physics (as basic as it is) to a new 2D engine (still don’t have a name for it yet), so you have collision detection as well as pixel perfect collision resolution. I have used the same pixel perfect collision Riemer has used in his 2D game sample, I started off writing it that way anyway, but was streaming to a one dimensional array, after reading his post, it made sense to have a 2 dimensional array, it made the transformation from object space to the other easier. In the clip there are 15 sprites that are just rotating, and then there is the player sprite, this sprite is animated using a 31 sprite image. I created the sprite sheet by rendering a 3D model and taking a screen shot as I rotated it, then stuck them all together in the sprite sheet. The shadows are simply the same texture rendered before the main image in black with a value of .5f as the alpha channel.

    The model I got from Turbo Squid, one of the many free models you can get there. Here is the sprite sheet, single sprite and a detailed image, if you want to have a play with them. If you use them, please credit me or this post and put a comment on here about it, it’s nice to see how your stuff gets about :)

    The single sprite

    ship1

    The sprite sheet

    ship1Anim

    A detailed sheet (killer on pixel perfect collision detection!)

    ship1detail

    I am quite pleased with what I have got so far seeing as it is only about 14 hours work, broken into 2-3 hours chunks over the week, and that includes the art work!. I guess now I have a basic framework I just might write a 2D game.

  • Eye See You....

    http://www.youtube.com/v/iH-DobURJ1I <p><a href="http://www.youtube.com/v/iH-DobURJ1I">http://www.youtube.com/v/iH-DobURJ1I</a></p>

    Was doing some Blender3D modeling for Killer Core and spotted in the Noob to Pro Wiki a "Pixar" Eye example. So I had a go and not being the greatest at blender found I could not get it to work too well. But, I could see the principle and so did my own XNA version of it :) Let me know what you think, this is the first blast at it, since uploading I have already improved on it. All that you see here though is done with the exact same principles you can find in my HLSL Tutorials.
  • Nebulon In Play Test

    boxart

    So,as I have mentioned before, I am part of a group called Dark Omen Games, and we have finally got around to getting a Creators Club Premium membership so we can start to release our games on the Xbox Live Creators Games.

    As my post title suggests, the first game we are putting up is Nebulon, the brain child of Dave Bonner.

    Nebulon is a 2D top down shooter, you fly your ship around looking for alien “photons” to warp in so you can shoot them. You have to be quick though, they like to gang up and if to many get together there is the chance of a wormhole opening up and something nasty coming out..

    Here are a few screen shots:

    Nebulon 2009-06-02 22-34-26-59 Nebulon 2009-06-02 22-31-16-64  Nebulon 2009-06-02 22-32-36-56 Nebulon 2009-06-02 22-32-56-59 Nebulon 2009-06-02 22-33-21-60 Nebulon 2009-06-02 22-33-56-59

     

     

     

     

     

     

    As you can see it can get pretty funky.

    Here is a clip (pre play test drop):

    http://www.youtube.com/v/mKhoI9HbKig <p><a href="http://www.youtube.com/v/mKhoI9HbKig">http://www.youtube.com/v/mKhoI9HbKig</a></p>

    If you have a Creators Club Premium account, please get on a give it a play test, we really would love to hear your feed back on it so we have a solid, robust game going into peer review.

    You can leave your comments here, on the play test forum for Nebulon or on our blog.

    So get your trigger fingers at the ready and start blasting some photons!

  • Dark Omen Games – What are we up to..?

    Well at the minute we have 2 projects on the go, first up Nebulon.

    Nebulon (play list)

    Written by Dave Bonner using his Anarchy Engine, this is turning into a nice little 2D shooter. I love the particle effects he has going on, as you can see in the clips, you fly a ship around the grid, sing “photon’s” spontaneously  erupt from the background, if they collide they create a binary bad dude, if another joins then you have a 3 photon spinning nightmare that is after your ship! More badies to come, more weapons and pick ups. We are hoping to get this up into Play Testing for XBLCG in an moth or two.

     

    Killer Core (play list)

    This game coming out of my RandomChaos 3D Engine. The idea came from an old ZX Spectrum game I used to love called StarQuake. In Killer Core, you still need to get off world, but not only are you up against the planets aboriginals but also other players trying to get off before you!! You will be able to pick up various weapon types as well as traps and shields to help you get off world or even just hinder other players. A single player mode will also be available. We are hoping to get KC into play test by December, dooner if we can..

     

    So, that’s what we are up to at the moment, what about some of the old projects, like Warheads3D and BreakThrough and OctaineX, well they are on the back burner at the moment, BreakThrough might get a re write for XNA 3.1 and Warheads3D (working title) will be ported to XNA 3.1 also, as to OctaneX, not sure if Dave will peruse it, I hope he does I kind of liked that one.

     

    Let us know what you think of our stuff, either here, on the DOG blog or the Channel.

  • Collision Detection – Per Triangle

    http://www.youtube.com/v/4Enqcn1xsHw <p><a href="http://www.youtube.com/v/4Enqcn1xsHw">http://www.youtube.com/v/4Enqcn1xsHw</a></p>

    OK, have been helping out a friend with some collision detection, and in doing so, found that my current collision system is not up to scratch. So, I am going to implement the new collision system I have come up with...
    I can't take any credit for this, all I have done is implement code from a white paper into XNA. I would not have even looked at this yet and had it on the back burner, so a big thanks to James for giving it focus :)
    As you can see from the clip, it's still early days..

    Now to be honest I am still not 100% sure I need this level of collision detection. At the moment it is only of real use for low poly models but I have a plan to get it working for large ply models. Once I have that bottomed out I’ll post the code and you can see how it’s done. DONT expect me to explain the maths, I understand the principle, but not having the maths background, I don’t feel anywhere near qualified to explain the inner workings..

    Hope you like the clip anyway..

    Should really give you the link to the white paper shouldn’t I, you can find it here.

  • Basic HLSL Lighting Techniques Episode 8: Planet Shader…

    http://www.youtube.com/v/WdwJ2WvjY_A <p><a href="http://www.youtube.com/v/WdwJ2WvjY_A">http://www.youtube.com/v/WdwJ2WvjY_A</a></p>

    In this post I am going to show you how to do multiple passes, how to make your handy HLSL function calls available to more than one shader at a time, how to pass variables to pixel and vertex shaders (in the hlsl pass) while creating a simple planet shader with these elements.

    This tutorial seems to have grown and grown, the code for this post I wrote ages ago, but as I am sure you know by my lack of post, I have been very busy and not had much time to write it up and get it posted. Most of my time has been centred around work and family, and some time on a game I am trying to write with the hope of getting it on the XBLCG, I am aiming to get it into peer review by December, more on that later, back to this post…. So I have had to try and remember what I was thinking as I wrote some of the elements to this, some of it I remember clearly, others not so.

    This post is mostly going to try and explain how I came up with my planet shader (see clip) it’s not perfect, but I had fun writing it and I hope that it gives you some ideas for your shaders.

    Now this shader did not start off with the intention of being a multi pass shader, but once I got to adding more and more bits to it I found I started to run out of instruction slots and the only way around it that I could think of was to break the shader into more than one pass. So two passes went to three, three went to four and finally four to five.

    How do we go about creating a multi-pass shader? Well that’s quite simple, you just have more than one pass in your technique. The initial issue that I had was that my last technique over wrote the one before it so I discovered that I needed to blend the passes. This is done like any other blending the only difference is that it has to be done in the pass it’s self. Some passes needed an alpha blend others an additive blend.

    I am not going to go into too much detail on the code in the pixel and vertex shaders as it’s mostly covered in the previous episodes, I’ll mostly cover the passes.

    First Pass 

    In this pass we just do the colour, bump, glow and reflection shading giving us a basic planet, later when we add the clouds we will go back to the colour pixel shader we will add the shadows to this pass for the clouds. So, our first pass looks like this:

    pass Colors
    {
        AlphaBlendEnable = False;
        CullMode = CCW;
        VertexShader = compile vs_2_0 VS_Color();
        PixelShader = compile ps_2_0 PS_Color();        
    }

    As you can see I am setting some render states in this pass. I am just making sure the alpha blending is off and that the cull mode is counter clock wise, then the regular vertex shader is called followed by the pixel shader.

    Second Pass

    In the second pass I want to add some ripples to the oceans. The geometry is already drawn in the first pass so all I need to do is call my shader to apply the waves to the oceans, bus as I have said above, I need to blend the two pixel shaders to get my effect.

    pass Waves
    {
        AlphaBlendEnable = True;
        SrcBlend = SrcAlpha;
        DestBlend = One;
        
        PixelShader = compile ps_2_0 PS_Water();
    }    

    So, we switch on alpha blending, then do an additive blend. I can then call my water pixel shader to apply the ripples. If you look realy close, the ripples move across the surface of the planet, I have a function that alters the text coords of the ripples to do this. To show that you can share functions across shaders I put this function in another file, how this is accessed I will cover later.

    Third Pass

    In this pass I want to add my clouds, to do this I am going to draw the geometry again, this time slightly larger than the planets surface, that way my clouds will appear a little raised from plants surface. I also wanted so shadows to appear on the surface of the planet cast by the clouds. To do this I went back to the cloud pixel shader and added the cloud textures to the final colour calculation but rendered them based on a shadow intensity. To “animate” the clouds I rotate the texture around the planet, again there is a shader parameter you can use to control the speed and I have a function to move the text coords of the cloud texture to do this and again, this is in my seperate function file.

    pass Clouds
    {
        // Already set, no need to set again, keep them incase I move the passes about though.
        //AlphaBlendEnable = True;
        //SrcBlend = SrcAlpha;
        //DestBlend = One;
        
        VertexShader = compile vs_2_0 VS_OuterAtmoshpere(.02);
        PixelShader = compile ps_2_0 PS_Cloud();
    }

    As you can see the vertex shader here is passed a parameter, this parameter is how much bigger I want to draw the new geometry. The blending is set in the previous pass so no need to set it again, I have kept the code there though in case I decide to move it.

    VS_OUT2 VS_OuterAtmoshpere(VS_IN input,uniform float size)
    {
        VS_OUT2 output = (VS_OUT2)0;
        output.Normal = mul(input.Normal, world);
        output.Position = mul(input.Position, wvp) + (mul(size, mul(input.Normal, wvp)));
        output.TexCoord = input.TexCoord;
        output.pos = mul(input.Position,world);
        
        return output;
    }

    As you can see, you need to declare the size parameter as a uniform in order to have it as an internal parameter. As you can see the position the current vertex is draw at is moved out along the direction of the normal by the distance of the size passed in, so drawing me a larger model around the original.

    Forth Pass

    In this pass I attempt to fake atmosphere, I  don’t need to render the geometry again as I can use the geometry the cloud pass has just created, this time though I use an alpha blend to get the effect I want.

    pass OuterAtmoshpere
    {
        //AlphaBlendEnable = True;
        //SrcBlend = SrcAlpha;
        DestBlend = InvSrcAlpha;
        
        // No need to move it out again, can use the same geom as the clouds.
        //VertexShader = compile vs_2_0 VS_OuterAtmoshpere(.02);
        PixelShader = compile ps_2_0 PS_OuterAtmoshpere(true);
    }

    You can see in the pixel shader I pass a Boolean, this is so I only had to write one pixel shader for both the inner atmosphere and the atmosphere halo.

    Fifth Pass

    So, onto the final pass now, the atmosphere halo. This works pretty much the same as the previous pass, only we set the cull mode to be clock wise. This results in the the sphere being rendered inside out, I also render the sphere much larger.

    pass UpperOuterAtmoshpere
    {
        //AlphaBlendEnable = True;
        //SrcBlend = SrcAlpha;
        //DestBlend = InvSrcAlpha;
        
        VertexShader = compile vs_2_0 VS_OuterAtmoshpere(.2);
        PixelShader = compile ps_2_0 PS_OuterAtmoshpere(false);
        CullMode = CW;
    }

    In the class used to render the planet, I make sure that the cull mode is set back to counter clock wise cull after the render.

    Shader Header

    This is where I have put the functions to rotate and to revolve the texture coordinates, I did this to show how you don’t have to keep writing the same functions in each of your shaders if they are common across your shaders. So to have access to these functions in my shader I just do this (if you are a C/C++ programmer this will look very familiar :P)

    #include "ShaderTools.fxh"

    Simple as that….

    You can find the solution for this post here.

  • XNA Bar Camp - Update!!

    Just got some great news from Microsoft!

    They will be giving ALL attendees a 4 month Creators Club membership and those that book a slot a 12 month Creators Club membership!!

    How cool is that!!?!?!

    So, to get your 4 month Creators Club membership book a place for the day here (only 100 places in total!).

    To get your 12 month Creators Club membership book your talk by mailing us here (only 12 slots in total!).

  • XNA Bar Camp Panel Discussion....

    We are toying with the idea of a panel discussion at the up coming XNA Bar Camp, Birmingham, March 21st 2009 So, what kind of topics would you like to have covered?

    I think we have a few people lined up, Peter McGann will be there, I dare say he will be on the panel (must say I saw Peter at a NxtGen talk ages ago and he was very good, even helped me out with my point sprite particles..), as well as Edward Powell, I hope Leaf  and Robin and possibly even me!

    So, give us your topic ideas, this is your chance to get the answers you want at the meet, so fire away, just post a comment here and we will get it added to the discussion.

    Hope to see you there :P

  • XNA Bar Camp, Birmingham, March 21st 2009

    Well here is an exciting bit of news for my 100th post on here (can't believe I have 100 posts!!). You may well know about this already as I am sure you subscribe to the main site RSS feed, so here it is again..


    "The XNA UK User group cordially invites you to a day of XNA show and tell. Join us to share your latest XNA game or technique insight, to learn from others, and have a thoroughly good time with XNA.

    If you want to come along, and we hope you do, please book your attendance at this site ( Registration Open - only 100 places available!). For those of you who would also like a chance to show off something please pre-book your presentation slot by emailing us here; the show & tell slots are limited and will need some organising so don't hang about!

    Food and refreshments will be provided during the day. To participate in the LAN Party you will need to bring your own laptop (and Xbox Controller). We look forward to seeing lots of you there!

    Agenda:

    09:30 Arrival

    10:00 Opening Session by Microsoft

    11:00 Start of slot presentations 12 x 20min (inc setup) slots to book

    12:00 – lunch taken on the fly during slots

    15:00 LAN Party – XNA multiplayer games (Bring your own laptop and controller/s!!)

    18:00 Close

    Venue:

    iCentrum
    Aston Science Park
    Faraday Wharf
    Birmingham
    B7 4BB

    *Refreshments sponsored by Microsoft."


    Be there, or be a trapezoid (I guess that would be 2 primitives from 4 vertices's, possibly not a textured quad, but you get what I mean)..

  • Basic HLSL Lighting Techniques - Episode 7: Simple Animation

    http://www.youtube.com/v/Igt5R9Eigvw <p><a href="http://www.youtube.com/v/Igt5R9Eigvw">http://www.youtube.com/v/Igt5R9Eigvw</a></p>

    Now this is very simple animation, no bones are used at all here. The point of this post is to show you how you can manipulate vertices in the shader. What I intend to do with this tutorial is go a little further than just lighting and finish it of with some posts around doing a multi pass shader and reusing geometry in those subsequent passes as well as some other HLSL bits and bobs I have found useful. This post may seem a little abstract because of this, but please bare with me...

    In the DirectX SDK there is a simple HLSL tutorial and in there there is a technique that covers what I am going to do here, there is also a shader on the NVIDIA site that does a similar thing, I think it's called "Mr Wiggle", also the same idea is applied to the Ocean shaders I have posted before. So what we are going to look at, in it's simplest form, is this kind of animation. The great thing with this IMhO is that it's all done on the GPU, you don't have to re position the vertices on the CPU and pass them over, so making it efficient.

    I first started to play about with this sort of thing when I had the idea to do a 3D type of JellyCar (I love that game!) so I started playing with this kind of animation, I started off with a cube mesh I created in Blender 3D and applied the same principles I am going to show here.

    From a still you can't get a very good idea of the motion of the cube, but what you can see is how I have altered it's shape, this is done inside the shader, as I said the model is a cube. There is a small amount of motion in this shader, I have added a clip of it to the back of the tutorial clip at the top so you can see it in motion,it's not finished, still a WIP.

    Simple Animation for a Models

    What we are going to do is alter the existing BlinnPhong shader we did in an earlier tutorial. We are first going to add a new parameter of Time to the shader

    float Time : Time;

    And a function called CalcVertexAnimation (pretty sure this is the name of the method in the SDK tut too:P)

    float4 CalcVertexAnimation(float4 Offset)
    {
    return float4((cos(Time+Offset.y)*.5)+Offset.x ,Offset.y,(sin(Time-Offset.y) * .5)+Offset.z,Offset.w);
    }

    Now  add a call to this function in the vertex shader so that we alter the position of the incoming vertex

    input.Position += CalcVertexAnimation(input.Position);

    And then alter the call to the shader to pass the current time in (I multiply by 3 to speed it up a bit)

    if(effect.Parameters["Time"] != null)
    effect.Parameters["Time"].SetValue((float)gameTime.TotalGameTime.TotalSeconds * 3);

    And TA DA!! Simple Animation... I know, it's not that awesome, but when  I move onto multi pass shader and show how we can reuse the geometry, this sort of thing could be used to animate a force field around a model, well that was the implementation that sprang to my mind. But I am sure you will come up with far better applications for this sort of thing.

    http://www.youtube.com/v/x3kkoNGbA_s <p><a href="http://www.youtube.com/v/x3kkoNGbA_s">http://www.youtube.com/v/x3kkoNGbA_s</a></p>

    At the time of me playing about with this, I was on the XNA IRC and someone on there was asking for some help regarding how to go about doing a flag animation (sorry forget your name now..) So I suggested this method of doing it.

    http://www.youtube.com/v/ZRvTJxd-Ed4 <p><a href="http://www.youtube.com/v/ZRvTJxd-Ed4">http://www.youtube.com/v/ZRvTJxd-Ed4</a></p>

    Animated Flags

    What I did the first time around did the job, but, I was not happy with the way it was being lit. What is happening when we animate the vertex is that the relating normal for that vertex is not altering. This makes the lighting look unnatural, so in the shader we also have to re calculate the normal based on the animation function we have, the current vertex and it's surrounding vertices.

    I am not going to go into the detail of how I created the flag it's self, it's just a plane of vertices created on the XY axis, and it's normals all set to Vecto3.Backward so 0,0,1 facing.

    So the flag shader it's self is really just an Ambient light shader, that is passed a texture. As before we add a Time parameter and a CalcVertexAnimation function

    float4 CalcVertexAnimation(float4 Offset)
    {
    return float4(Offset.x,Offset.y,sin(Time+Offset.z+(Offset.y-Offset.x)) * 1.5,Offset.w);
    }

    As you can see the animation is a little different, we are just moving the vertex along the Z axis by the time + the X and Y axis I am multiplying by 1.5 to give it a bit more depth to each of the waves.

    The vertex shader has altered a fair bit, first thing I do is store the original position for the vertex, then set up an array of 3 positions, these three positions will give us our new normal value, but first we have to work out where they are. This will only work with this flag class as we know that our vertices are evenly spaced, this may not be the case in a model. So to get the correct normal we need to get the cross product from two sides of this vertex.

    The first side is created from the current vertex position - the vertices position below this current vertex.

    The second side is created from the current vertex position - the vertices position to the right of it.

    We can now use these two vales to give us the current vertices normal by using the intrinsic HLSL method cross and giving it our two sides.

    VS_OUT VS_ColorMap(VS_IN input)
    {
    VS_OUT output = (VS_OUT)0;

    float4 orgPos = input.Position;

    // Calc other vert positions to get aniamted normal.
    float4 poss[3];
    float4 nextPos = orgPos.xyzw;
    for(int p=1;p<3;p++)
    {
    if(p == 2)
    {
    nextPos.x = orgPos.x;
    nextPos.y -= .5;
    }
    else
    nextPos.x += .5;

    poss[p] = nextPos;
    poss[p] += CalcVertexAnimation(nextPos);
    }

    input.Position += CalcVertexAnimation(input.Position);
    poss[0] = input.Position;

    output.Position = mul(input.Position ,wvp);
    output.TexCoord = input.TexCoord;

    // Alter for animation;
    float3 side1 = poss[0] - poss[2];
    float3 side2 = poss[0] - poss[1];
    output.Normal = cross(side1,side2);
    //output.Normal = input.Normal;

    return output;
    }

    The Vertex shader is unchanged to, but here it is anyway

    PS_OUT PS_ColorMap(VS_OUT input)
    {
    PS_OUT output = (PS_OUT)0;

    float3 LightDir = normalize(LightDirection);
    float Diffuse = saturate(dot(LightDir,normalize(input.Normal)));

    float4 texCol = tex2D(ColorMapSampler,input.TexCoord);
    float4 Ambient = AmbientIntensity * AmbientColor;

    texCol *= Diffuse;

    output.Color = Ambient + texCol;

    return output;
    }

    And we then get this

    http://www.youtube.com/v/EDTu2eOZX8M <p><a href="http://www.youtube.com/v/EDTu2eOZX8M">http://www.youtube.com/v/EDTu2eOZX8M</a></p>

    I would like to thank my friend Michael Quandt for helping me sanity check the flag shader too, thanks mate :)

    So, the solution to this episode can be found here.

  • Dark Omen Games - Restart

    Well I am sure I have mentioned I am part of a small group of XNA developers and collectively we call our selves Dark Omen Games. Well, we had all sorts of issues with our domain and blog site last year, we still don't have the domain sorted out yet, but the blog is up and running.

    We have a few projects in the pipeline (as ever) and hope to actually finish some of them this year, so for all the news and development updates from the DOG team check out our blog here.

    Or if you want you can subscribe direct to the RSS feed here.

    With any luck we will get the domain sorted out and actually have a site too, until then please visit and comment on the blog. I have just put up a post on my first real attempt at an intro for DOG games that have been written with the RC3D engine, take a look and let us know what you think.

    Posted Jan 16 2009, 12:25 PM by Nemo Krad with no comments
    Filed under:
More Posts Next page »