Wednesday 8 June 2016

Source Example 6 - Fog SM 1.1 to 2



This example shows the use of shader model 1.1 - 2 methodology for fog by using the render states.

Controls
Mouse to rotate camera.
Arrow Keys to translate camera.
F1 Switch Fog On.
F2 Switch Fog Off.

RC3DEFogSample1.zip

Source Example 4 - Terrain



So onto terrain, this example uses a height map 128X128 and is configured to use Riemers origional terrain shader (modified for the engine). Also included in this example are my terrain shaders along with the modified bump maped versions of these shaders and the associated textures.

It also gives an example of the terrain picking and collision, again this is quite basic.

Controls
Mouse to rotate the camera.
Arrow keys to translate the camera.
Right click to drop the terrains height and left to raise it.
Keys 1-4 select a terrain shader

  • 1 - Reimers Terrain Shader
  • 2 - My Terrain Shader
  • 3 - Reimers Terrain Shader with Bump Mapping
  • 4 - My Terrain Shader with Bump Mapping
  • Escape to exit.

    RC3DETerrainExample1.zip

    Source Example 2 - Scene Picking & Targets



    Moving on from example 1 but sticking with the Model and Scene class, this example shows how to apply picking objects from the scene and also how to apply a targeting reticle to a model using the Get2DCoors method.

    For this to be done I have added the RandomchaosContentPipelineManager to the project, this gives the model class the ability to use the bounding box data.

    You will see in the example screen above that the target reticle is not in the center of the model, this is because the skullocc.x file has it's center at the bottom of the model. I have also noticed a bug with the targeting code, if you target a model then rotate the camera 180 degrees away, you get the target reticle behind you.

    Again to ensure the download works, you will have to reference the Randomchaos3Engine.dll and the RandomchaosContentPipelineManager.dll, the later is done by right clicking the project name in the project explorer, select properties, select the Content Pipeline tab remove the current setting and replace with the path you have for the dll on your system.

    RC3DEModelExample2.zip

    If you have any comments or issues with this example, please post them here :)

    Thursday 4 October 2012

    Fancy playing with C++ and DirectX 11

    Well I am starting out down that road too, my C++ is rusty, I know little about DX11, but what the hell, you have to start somewhere right? So if you fancy trying your hand at it to, check out my first post on the subject.

    Heads up!

    As we have seen over the past few days, the future of this site seems uncertain, and so I have decided to archive my historical posts I have here; and have started to move them to a new blogspot blog which you can find here should this site go.

    I am also starting to take a look at DirectX11 with C++, and have started a new blog here, so if you are interested in this area of development, then please feel free to pop by, take a look at what I am up to and comment as much as you like :)

    I would also like to keep bloging about XNA as I love it so much, so I am intending to continue that here.

    To all of you that have followed, commented and helped my out over my time here and with XNA, I thank you so very, very much, without you guys I would not have discovered so much, and to all the people I have met at events and user group meets, it has been a pleasure to have known such an enthusiastic and nice bunch of guys.

    Thanks,

    Charles.

    2D Crepuscular (God) Rays

    If you follow my blog, you know I have already covered this as a 3D implementation, well while having a nose on twitter, I spotted that x35mm (another XNA developer from the midlands :D) was writing what looked like a pretty cool hack and slash Ronin game for DBP, and I thought, that would look nice with some God rays to give it some more lighting details, so sent x35mm my 2D implementation of the God ray post process, and this is what he did with it:



    Pretty cool eh :D
    So, I am going to post here this 2D implementation. Keep in mind that this effect will not work on the WP7 device as it uses custom shaders to do what it needs to do, might have a look at a CPU implementation, but I reckon it will suck.
    Overview
    If you refer back to my post on this for 3D you will see all the same shaders, the difference in this 2D sample is the way the light mask is built. Effectively you need to render your light source, over that render the elements in your scene that are obscuring that source over the top in black to create the light mask, then apply the Crepuscular post processing effect. Then render the scene as you would normaly and then using an additive blend apply the god ray’s over the top.
    1. Draw Light Source

    Here the post processor is rendering the light mask at the position we want on the screen, as you can see I have put up a few keyboard controls you can use to alter the parameters to the effect, so you can move the light source around, alter the exposure, stuff like that.
    2. Draw Light Mask

    There are a few items in this scene, a number of “mountain” images which are just wrap able textures and a samurai head icon for my mouse pointer, all png’s so we can use the alpha channel on them to allow light to bleed through. The post process is then applied to this to make the light bleed past the edges of the mask to give the god ray effect.
    3. Draw Scene

    The scene is then drawn ready to be blended with the processed mask.
    4. Combine Scene and Ray Images

    Finally it’s all brought together to give the overall effect.
    5. Animate It
    So I am scrolling the mountains at different speeds to give the sense of movement over the terrain and moving the mouse icon to obscure the light showing how dynamic this technique is. Also at the same time altering the parameters as I go.
    As you can see it renders at a good frame rate, 60fps,  and this is at 900x1440 on my laptop. I have not personally ran this sample on my 360, buy x35mm has I believe.
    Check out Dawn of the Ronin (pre god rays) here.
    The solution for this sample can be found here.
    I have also made an update to this so that the effect takes screen resolution into account here.
    If you use this technique in your work, please let me know, be cool to see it used in the real world, just like x35mm has done in his game.

    XNA with BulletSharp Physics Engine

    Did a quick clip to show the progress of my current engine as I have started to put a third party physics engine in. For years I have struggles and struggled with writing my own, with some success, but to be honest, I never could quite get it right. So I have took it on the chin and decided to go with a third party engine. I chose BulletSharp as it’s the physics engine used in ST Excalibur. In this clip I have the engine with a load of cubes, a sphere and terrain. As expected the lighting is deferred, with a single shadow casting light source.