XNA for C#
DirectX 9 for C#
DirectX 9 for C++
DirectX 9 for VB
Forum
   
My XNA Book
      
       Go to section on this site

Additional info


Latest Forum posts

 Tutorial 3 for Windows Phone 7
  Posted by: Anonymous
  When: 20/05/2013 at 02:30:13

 No download link for 2d series: shooter
  Posted by: zaboleq
  When: 07/05/2013 at 15:46:28

 Collision Class?
  Posted by: Anonymous
  When: 05/05/2013 at 19:03:59

 stack overflow
  Posted by: cityguy
  When: 07/04/2013 at 01:58:38

 Meshes looks strange.
  Posted by: ab_saratov
  When: 01/04/2013 at 04:31:08

 Lamppost Not loaded
  Posted by: Anonymous
  When: 22/03/2013 at 06:43:52

 Collision Class?
  Posted by: Da_Boom
  When: 21/03/2013 at 01:23:09

 Math boggles me
  Posted by: cityguy
  When: 17/03/2013 at 03:44:48

 Collision Class?
  Posted by: Da_Boom
  When: 16/03/2013 at 03:44:42

 Tree update
  Posted by: Anonymous
  When: 15/03/2013 at 21:11:22


Ads

Experimenting with Lights in DirectX 

My thanks to Richard Sharpe for porting this chapter to C++!


Even when using colors and a Z buffer, your terrain seems to miss some depth detail when you turn on the Solid FillMode. By adding some lights, it will look much better. This chapter we will see the impact of a light on 2 simple triangles, so we can have a better understanding of how lights work in DirectX. We will be using the code from the Rotation & Translation chapter, so reload that code now. Start by letting DirectX know we will be using lights, by finding the line where you turn off lights and replacing it by this line:

 p_dx_Device->SetRenderState(D3DRS_LIGHTING,true);

Next you can simply start defining your lights. They start at index 0, and we’ll only be defining one. I like to split up each part of my program into functions so you know what each part is doing so add this function above your InitializeDevice function

 void Lights(LPDIRECT3DDEVICE9 p_dx_Device)
 {
      D3DLIGHT9 light;
 
      ZeroMemory(&light, sizeof(light));
      light.Type = D3DLIGHT_DIRECTIONAL;
      light.Diffuse.r = 1.0f;
      light.Diffuse.g = 1.0f;
      light.Diffuse.b = 1.0f;
      light.Diffuse.a = 1.0f;
      light.Direction.x = 0.8f;
      light.Direction.y = 0.0f;
      light.Direction.z = -1.0f;
 
      p_dx_Device->SetLight(0, &light);
      p_dx_Device->LightEnable(0, TRUE);
     
      return;
 }

As an example, I used the simplest case, a directional light. Imagine this as the sunlight: the light will travel in one particular direction. There are a few more types of light, I'll discuss them later on. The diffuse color is simply the color of the light. Of course you need to define the direction your light shines, and enable it. It is possible that your video card doesn't support lights, later I'll show you how to check on that. Now try running this code.
Very nice, your screen has gone black again. Why's that? To perform its calculations, DirectX needs another input: the 'normal' in every vertex. Consider next figure:



you have a light source a), and you shine it on the shown 3 surfaces, how is DirectX supposed to know that surface 1 should be lit more intensely than surface 3? (Actually, this could have been programmed by hard, but soon you'll see why it's not) If you look at the thin red lines in figure b), you'll notice that THEY are a nice indication of how much light you would want to be reflected (and thus seen) on every surface. So how can we calculate the length of these lines? Actually, DirectX does the job for us. All we have to do is give the blue arrow perpendicular (with an angle of 90 degrees, the thin blue lines) to every surface and DirectX does the rest (a simple cosine projection) for us! Because we know every surface consists of triangles, we can define these perpendicular directions together with our vertices, simply by using the D3DVECTOR normal; object in your OURCUSTOMVERTEX struct so change it now so it looks like this:

 struct OURCUSTOMVERTEX
 {
     float x,y,z;
     D3DVECTOR normal;
     DWORD color;
 };

You also need to reflect this change in your DrawScene function:

 p_dx_Device->SetFVF(D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE);

you also need to change the statement in you FillVertices function to

 if (FAILED(p_dx_Device->CreateVertexBuffer(3*sizeof(OURCUSTOMVERTEX), 0, D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE, D3DPOOL_DEFAULT, &p_dx_VertexBuffer, NULL)))

We could start defining these arrows. But first, have a look at the next picture, where the arrows above represent the direction of the light and the color bar below the drawing represents the color of every pixel along our surface:



If we simply define the perpendicular vectors, it is easy to see there will be an 'edge' in the lighting (see the bar directly above the a)). This is because the right surface receives (and thus also reflects) 'more' of the light then the left surface. So it will be easy to see the surface is made of separate triangles. However, if we place in the shared top vertex a 'normal' as shown in figure b), DirectX automatically interpolates the lighting in every point of our surface! This will give a much smoother effect, as you can see in the bar above the b). This vector is of course half of the sum of the 2 top vectors of a).
To demonstrate this example, reset the camera position:

 void SetUpCamera(LPDIRECT3DDEVICE9 p_dx_Device)
  {
      D3DXVECTOR3 m_EyePos(0, -40, 100);
      D3DXVECTOR3 m_TargetPos(0, 50, 0);
      D3DXVECTOR3 m_UpVector(0, 1, 0);
      D3DXMATRIXA16 m_View;
      D3DXMatrixLookAtLH(&m_View, &m_EyePos, &m_TargetPos, &m_UpVector);
      p_dx_Device->SetTransform(D3DTS_VIEW, &m_View);
 
      D3DXMATRIX m_Projection;
      D3DXMatrixPerspectiveFovLH(&m_Projection, D3DX_PI/4, 500/500, 1, 200);
      p_dx_Device->SetTransform(D3DTS_PROJECTION, &m_Projection);
 }

Notice how the direction of the light corresponds with the one in the previous example: positive x coordinate means 'to the left' and negative z coordinate means 'downward'. Then change your VertexDeclaration method like this:

 OURCUSTOMVERTEX cv_Vertices[6];
 LPDIRECT3DVERTEXBUFFER9 p_dx_VertexBuffer;
 
 cv_Vertices[0].x = 0.0f;
 cv_Vertices[0].y = 0.0f;
 cv_Vertices[0].z = 50.0f;
 cv_Vertices[0].color = 0xff3333FF;
 cv_Vertices[0].normal.x = 1;
 cv_Vertices[0].normal.y = 0;
 cv_Vertices[0].normal.z = 1;
 
 cv_Vertices[1].x = 50.0f;
 cv_Vertices[1].y = 0.0f;
 cv_Vertices[1].z = 0.0f;
 cv_Vertices[1].color = 0xff3333FF;
 cv_Vertices[1].normal.x = 1;
 cv_Vertices[1].normal.y = 0;
 cv_Vertices[1].normal.z = 1;
 
 cv_Vertices[2].x = 0.0f;
 cv_Vertices[2].y = 50.0f;
 cv_Vertices[2].z = 50.0f;
 cv_Vertices[2].color = 0xff3333FF;
 cv_Vertices[2].normal.x = 1;
 cv_Vertices[2].normal.y = 0;
 cv_Vertices[2].normal.z = 1;
 
 cv_Vertices[3].x = -50.0f;
 cv_Vertices[3].y = 0.0f;
 cv_Vertices[3].z = 0.0f;
 cv_Vertices[3].color = 0xff3333FF;
 cv_Vertices[3].normal.x = -1;
 cv_Vertices[3].normal.y = 0;
 cv_Vertices[3].normal.z = 1;
     
 cv_Vertices[4].x = 0.0f;
 cv_Vertices[4].y = 0.0f;
 cv_Vertices[4].z = 50.0f;
 cv_Vertices[4].color = 0xff3333FF;
 cv_Vertices[4].normal.x = -1;
 cv_Vertices[4].normal.y = 0;
 cv_Vertices[4].normal.z = 1;
 
 cv_Vertices[5].x = 0.0f;
 cv_Vertices[5].y = 50.0f;
 cv_Vertices[5].z = 50.0f;
 cv_Vertices[5].color = 0xff3333FF;
 cv_Vertices[5].normal.x = -1;
 cv_Vertices[5].normal.y = 0;
 cv_Vertices[5].normal.z = 1;

This defines the 2 surfaces of the picture above. By adding a Z (other than 0), the triangles are now 3D. You can notice that I’ve defined the normal vectors perpendicular, as to reflect example a) of the image above. Don't forget to change the lines further down that say

 3*sizeof(OURCUSTOMVERTEX):

to

 6*sizeof(OURCUSTOMVERTEX)

to reflect the increase in the number of vertices.

All there's left to do is change your DrawScene method so this will be your new method:

 void DrawScene(LPDIRECT3DDEVICE9 p_dx_Device, LPDIRECT3DVERTEXBUFFER9 p_dx_VertexBuffer)
  {
      flt_Angle += (float)0.05;
 
 
      p_dx_Device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(72,61,139), 1.0f, 0);
      p_dx_Device->BeginScene();
 
      D3DXMATRIX m_Translation;
      D3DXMatrixTranslation(&m_Translation,-5,0,0);
 
      D3DXMATRIX m_World;
      p_dx_Device->SetTransform(D3DTS_WORLD,&m_Translation );
 
      p_dx_Device->SetStreamSource(0, p_dx_VertexBuffer, 0, sizeof(OURCUSTOMVERTEX));
      p_dx_Device->SetFVF(D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE);
      p_dx_Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);
 
      p_dx_Device->EndScene();
      p_dx_Device->Present(NULL, NULL, NULL, NULL);
 }

Now run this code and you'll see what I mean with 'edged lighting': the light shines brightly on the right panel and the left panel is darker. You can see clearly the difference between the two triangles! Now it's time to combine the vectors on the edge from (-1,0,1) and (1,0,1) to (-1+1,0,1+1)/2 = (0,0,1):

 cv_Vertices[0].x = 0.0f;
 cv_Vertices[0].y = 0.0f;
 cv_Vertices[0].z = 50.0f;
 cv_Vertices[0].color = 0xff3333FF;
 cv_Vertices[0].normal.x = 0;
 cv_Vertices[0].normal.y = 0;
 cv_Vertices[0].normal.z = 1;
 
 cv_Vertices[1].x = 50.0f;
 cv_Vertices[1].y = 0.0f;
 cv_Vertices[1].z = 0.0f;
 cv_Vertices[1].color = 0xff3333FF;
 cv_Vertices[1].normal.x = 1;
 cv_Vertices[1].normal.y = 0;
 cv_Vertices[1].normal.z = 1;
 
 cv_Vertices[2].x = 0.0f;
 cv_Vertices[2].y = 50.0f;
 cv_Vertices[2].z = 50.0f;
 cv_Vertices[2].color = 0xff3333FF;
 cv_Vertices[2].normal.x = 0;
 cv_Vertices[2].normal.y = 0;
 cv_Vertices[2].normal.z = 1;
 
 cv_Vertices[3].x = -50.0f;
 cv_Vertices[3].y = 0.0f;
 cv_Vertices[3].z = 0.0f;
 cv_Vertices[3].color = 0xff3333FF;
 cv_Vertices[3].normal.x = -1;
 cv_Vertices[3].normal.y = 0;
 cv_Vertices[3].normal.z = 1;
     
 cv_Vertices[4].x = 0.0f;
 cv_Vertices[4].y = 0.0f;
 cv_Vertices[4].z = 50.0f;
 cv_Vertices[4].color = 0xff3333FF;
 cv_Vertices[4].normal.x = 0;
 cv_Vertices[4].normal.y = 0;
 cv_Vertices[4].normal.z = 1;
 
 cv_Vertices[5].x = 0.0f;
 cv_Vertices[5].y = 50.0f;
 cv_Vertices[5].z = 50.0f;
 cv_Vertices[5].color = 0xff3333FF;
 cv_Vertices[5].normal.x = 0;
 cv_Vertices[5].normal.y = 0;
 cv_Vertices[5].normal.z = 1;

When you run this code, you'll see that the reflection is nicely distributed from the bright right panel to the darker left tip. It's not difficult to imagine that this effect will give a much nicer effect on a large number of triangles, such as our terrain.




DirectX Tutorial 15 - DirectX Light basics

If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !



Click here to go to the forum on this chapter!

Or click on one of the topics on this chapter to go there:
  • HLSL Lighting troubles
          Inspired by the HLSL tutorial, I have started codi...
  • Mesh Creation
          Does anyone know how to create a mesh in c++ using...


    Also, you can see that since the middle vertices use the SAME normal, we could again combine the 2x2 shared vertices to 2x1 vertices using an index buffer. Notice however, that in the case you really WANT to create an edge, you need to specify the 2 separate normal vectors.

    Your code:


    #include<windows.h>
    #include<d3d9.h>
    #include<d3dx9.h>
    struct OURCUSTOMVERTEX
    {
        float x,y,z;
        D3DVECTOR normal;
        DWORD color;
    };

    int int_AppRunning = 1;

    float flt_Angle = 0;

    LRESULT CALLBACK OurWindowProcedure(HWND han_Wind,UINT uint_Message,WPARAM parameter1,LPARAM parameter2)
    {
         switch(uint_Message)
         {
             case WM_KEYDOWN:
             {
                 int_AppRunning = 0;
                 break;
            }
             break;
        }

         return DefWindowProc(han_Wind,uint_Message,parameter1,parameter2);
    }

    HWND NewWindow(LPCTSTR str_Title,int int_XPos, int int_YPos, int int_Width, int int_Height)
    {
         WNDCLASSEX wnd_Structure;

         wnd_Structure.cbSize = sizeof(WNDCLASSEX);
         wnd_Structure.style = CS_HREDRAW | CS_VREDRAW;
         wnd_Structure.lpfnWndProc = OurWindowProcedure;
         wnd_Structure.cbClsExtra = 0;
         wnd_Structure.cbWndExtra = 0;
         wnd_Structure.hInstance = GetModuleHandle(NULL);
         wnd_Structure.hIcon = NULL;
         wnd_Structure.hCursor = NULL;
         wnd_Structure.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
         wnd_Structure.lpszMenuName = NULL;
         wnd_Structure.lpszClassName = "WindowClassName";
         wnd_Structure.hIconSm = LoadIcon(NULL,IDI_APPLICATION);

         RegisterClassEx(&wnd_Structure);

         return CreateWindowEx(WS_EX_CONTROLPARENT, "WindowClassName", str_Title, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE, int_XPos, int_YPos, int_Width, int_Height, NULL, NULL, GetModuleHandle(NULL), NULL);
    }

    void Lights(LPDIRECT3DDEVICE9 p_dx_Device)
    {
         D3DLIGHT9 light;

         ZeroMemory(&light, sizeof(light));
         light.Type = D3DLIGHT_DIRECTIONAL;
         light.Diffuse.r = 1.0f;
         light.Diffuse.g = 1.0f;
         light.Diffuse.b = 1.0f;
         light.Diffuse.a = 1.0f;
         light.Direction.x = 0.8f;
         light.Direction.y = 0.0f;
         light.Direction.z = -1.0f;

         p_dx_Device->SetLight(0, &light);
         p_dx_Device->LightEnable(0, TRUE);
        
         return;
    }

    LPDIRECT3DDEVICE9 InitializeDevice(HWND han_WindowToBindTo)
    {
         LPDIRECT3D9 p_dx_Object;
         LPDIRECT3DDEVICE9 p_dx_Device;

         p_dx_Object = Direct3DCreate9(D3D_SDK_VERSION);
         if (p_dx_Object == NULL)
         {
             MessageBox(han_WindowToBindTo,"DirectX Runtime library not installed!","InitializeDevice()",MB_OK);
        }

         D3DPRESENT_PARAMETERS dx_PresParams;
         ZeroMemory( &dx_PresParams, sizeof(dx_PresParams) );
         dx_PresParams.Windowed = TRUE;
         dx_PresParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
         dx_PresParams.BackBufferFormat = D3DFMT_UNKNOWN;

         if (FAILED(p_dx_Object->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, han_WindowToBindTo,
             D3DCREATE_HARDWARE_VERTEXPROCESSING, &dx_PresParams, &p_dx_Device)))
         {
             if (FAILED(p_dx_Object->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, han_WindowToBindTo,
                 D3DCREATE_SOFTWARE_VERTEXPROCESSING, &dx_PresParams, &p_dx_Device)))
             {
                 MessageBox(han_WindowToBindTo,"Failed to create even the reference device!","InitializeDevice()",MB_OK);
            }
        }
        
         Lights(p_dx_Device);
         p_dx_Device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
         p_dx_Device->SetRenderState(D3DRS_LIGHTING,true);
         p_dx_Device->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(150, 150, 150));

         return p_dx_Device;
    }

    void DrawScene(LPDIRECT3DDEVICE9 p_dx_Device, LPDIRECT3DVERTEXBUFFER9 p_dx_VertexBuffer)
    {

         flt_Angle += (float)0.05;


         p_dx_Device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(72,61,139), 1.0f, 0);
         p_dx_Device->BeginScene();

         D3DXMATRIX m_Translation;
         D3DXMatrixTranslation(&m_Translation,-5,0,0);

         D3DXMATRIX m_World;
         p_dx_Device->SetTransform(D3DTS_WORLD,&m_Translation );

         p_dx_Device->SetStreamSource(0, p_dx_VertexBuffer, 0, sizeof(OURCUSTOMVERTEX));
         p_dx_Device->SetFVF(D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE);
         p_dx_Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

         p_dx_Device->EndScene();
         p_dx_Device->Present(NULL, NULL, NULL, NULL);
    }

    LPDIRECT3DVERTEXBUFFER9 FillVertices(HWND han_Window, LPDIRECT3DDEVICE9 p_dx_Device)
    {
         OURCUSTOMVERTEX cv_Vertices[6];
         LPDIRECT3DVERTEXBUFFER9 p_dx_VertexBuffer;

        cv_Vertices[0].x = 0.0f;
        cv_Vertices[0].y = 0.0f;
        cv_Vertices[0].z = 50.0f;
        cv_Vertices[0].color = 0xff3333FF;
        cv_Vertices[0].normal.x = 0;
        cv_Vertices[0].normal.y = 0;
        cv_Vertices[0].normal.z = 1;

        cv_Vertices[1].x = 50.0f;
        cv_Vertices[1].y = 0.0f;
        cv_Vertices[1].z = 0.0f;
        cv_Vertices[1].color = 0xff3333FF;
        cv_Vertices[1].normal.x = 1;
        cv_Vertices[1].normal.y = 0;
        cv_Vertices[1].normal.z = 1;

        cv_Vertices[2].x = 0.0f;
        cv_Vertices[2].y = 50.0f;
        cv_Vertices[2].z = 50.0f;
        cv_Vertices[2].color = 0xff3333FF;
        cv_Vertices[2].normal.x = 0;
        cv_Vertices[2].normal.y = 0;
        cv_Vertices[2].normal.z = 1;

        cv_Vertices[3].x = -50.0f;
        cv_Vertices[3].y = 0.0f;
        cv_Vertices[3].z = 0.0f;
        cv_Vertices[3].color = 0xff3333FF;
        cv_Vertices[3].normal.x = -1;
        cv_Vertices[3].normal.y = 0;
        cv_Vertices[3].normal.z = 1;
        
        cv_Vertices[4].x = 0.0f;
        cv_Vertices[4].y = 0.0f;
        cv_Vertices[4].z = 50.0f;
        cv_Vertices[4].color = 0xff3333FF;
        cv_Vertices[4].normal.x = 0;
        cv_Vertices[4].normal.y = 0;
        cv_Vertices[4].normal.z = 1;

        cv_Vertices[5].x = 0.0f;
        cv_Vertices[5].y = 50.0f;
        cv_Vertices[5].z = 50.0f;
        cv_Vertices[5].color = 0xff3333FF;
        cv_Vertices[5].normal.x = 0;
        cv_Vertices[5].normal.y = 0;
        cv_Vertices[5].normal.z = 1;

         if (FAILED(p_dx_Device->CreateVertexBuffer(6*sizeof(OURCUSTOMVERTEX),
             0, D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE, D3DPOOL_DEFAULT, &p_dx_VertexBuffer, NULL)))
         {
             MessageBox(han_Window,"Error while creating VertexBuffer","FillVertices()",MB_OK);
        }

         VOID* p_Vertices;
         if (FAILED(p_dx_VertexBuffer->Lock(0, 6*sizeof(OURCUSTOMVERTEX), (void**)&p_Vertices, 0)))
         {
             MessageBox(han_Window,"Error trying to lock","FillVertices()",MB_OK);
        }else{
             memcpy(p_Vertices, cv_Vertices, 6*sizeof(OURCUSTOMVERTEX));
             p_dx_VertexBuffer->Unlock();
        }

         return p_dx_VertexBuffer;
    }

    void SetUpCamera(LPDIRECT3DDEVICE9 p_dx_Device)
    {
         D3DXVECTOR3 m_EyePos(0, -40, 100);
         D3DXVECTOR3 m_TargetPos(0, 50, 0);
         D3DXVECTOR3 m_UpVector(0, 1, 0);
         D3DXMATRIXA16 m_View;
         D3DXMatrixLookAtLH(&m_View, &m_EyePos, &m_TargetPos, &m_UpVector);
         p_dx_Device->SetTransform(D3DTS_VIEW, &m_View);

         D3DXMATRIX m_Projection;
         D3DXMatrixPerspectiveFovLH(&m_Projection, D3DX_PI/4, 500/500, 1, 200);
         p_dx_Device->SetTransform(D3DTS_PROJECTION, &m_Projection);
    }

    int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreviousInstance,LPSTR lpcmdline,int nCmdShow)
    {
         MSG msg_Message;

         HWND han_Window = NewWindow("DirectX C++ Tutorial",100,100,500,500);
         LPDIRECT3DDEVICE9 p_Device = InitializeDevice(han_Window);
         LPDIRECT3DVERTEXBUFFER9 p_dx_VB = FillVertices(han_Window, p_Device);
         SetUpCamera(p_Device);

         while(int_AppRunning)
         {
             if(PeekMessage(&msg_Message,han_Window,0,0,PM_REMOVE))
             {
                 DispatchMessage(&msg_Message);
            }
             DrawScene(p_Device, p_dx_VB);
        }

         p_Device->Release();
         DestroyWindow(han_Window);

         return 0;
    }



    Google
     
    Webwww.riemers.net


    If you appreciate the amount of time I spend creating and updating
    these pages, feel free to donate -- any amount is welcome !



    - Website design & XNA + DirectX code : Riemer Grootjans -
    ©2003 - 2011 Riemer Grootjans
  • Translations

    This site in English
    This site in Korean
    This site in Czech

    Microsoft MVP Award



    2007 - 2011 MVP Award
    DirectX - XNA

    Contents

    News
    Home
    Forum
    XNA 2.0 Recipes Book (8)
    Chapter 1
    Chapter 2
    Chapter 3
    Chapter 4
    Chapter 5
    Chapter 6
    Chapter 7
    Chapter 8
    XNA 3.0 Recipes Book (8)
    Chapter 1
    Chapter 2
    Chapter 3
    Chapter 4
    Chapter 5
    Chapter 6
    Chapter 7
    Chapter 8
    Downloads
    Extra Reading (3)
    Matrices: geometrical
    Matrix Mathematics
    Homogenous matrices
    Community Projects (1)
    Team Project (1)
    News
    Tutorials (160)
    XNA 4.0 using C# (89)
    2D Series: Shooters (22)
    Starting a project
    Drawing fullscreen images
    Positioning images
    SpriteBatch.Draw()
    Rotation
    Keyboard input
    Writing text
    Angle to Direction
    Direction to Angle
    Smoke trail
    Manual texture creation
    Random terrain
    Texture to Colors
    Coll Detection Overview
    Coll Detection Matrices
    Putting CD into practice
    Particles
    Additive alpha blending
    Particle engine
    Adding craters
    Sound in XNA
    Resolution independency
    3D Series 1: Terrain (13)
    Starting a project
    The effect file
    The first triangle
    World space
    Rotation - translation
    Indices
    Terrain basics
    Terrain from file
    Keyboard
    Adding colors
    Lighting basics
    Terrain lighting
    VertexBuffer & IndexBuffer
    3D Series 2: Flightsim (14)
    Starting point
    Textures
    Loading the floorplan
    Creating the 3D city
    Loading a Model
    Ambient and diffuse
    Quaternion camera
    Flight kinematics
    Collision detection
    Adding targets
    Point sprites
    Alpha blending
    Skybox
    Camera delay
    3D Series 3: HLSL (18)
    Starting point
    HLSL introduction
    Vertex format
    Vertex shader
    Pixel shader
    Per-pixel colors
    Textured triangle
    Triangle strip
    World transform
    World normals
    Per-pixel lighting
    Shadow map
    Render to texture
    Projective texturing
    Real shadow
    Shaping the light
    Preshaders
    3D Series 4: Adv. terrain (19)
    Starting code
    Mouse camera
    Textured terrain
    Multitexturing
    Adding detail
    Skydome
    The water technique
    Refraction map
    Reflection map
    Perfect mirror
    Ripples
    The Fresnel term
    Moving water
    Specular highlights
    Billboarding
    Region growing
    Billboarding renderstates
    Perlin noise
    Gradient skybox
    Short Tuts (3)
    Run XNA on older pcs
    MessageBox in XNA
    Normal generation
    DirectX using C# (54)
    Series 1:Terrain (14)
    Opening a window
    Linking to the Device
    Drawing a triangle
    Camera
    Rotation - Translation
    Indices
    Terrain creation
    Terrain from file
    DirectInput
    Importing bmp files
    Colored vertices
    DirectX Light basics
    Mesh creation
    Mesh lighting
    Series 2: Flightsim (19)
    Starting code
    Textures
    The floorplan
    Creating the 3D City
    Meshloading from file
    Ambient light
    Action
    Flight kinematics
    Collision detection
    Skybox
    Texture filtering
    Adding targets
    Point sprites
    Alpha blending
    DirectSound
    Sounds in 3D
    Playing MP3 files
    Displaying text
    Going fullscreen
    Series 3: HLSL (19)
    Starting point
    HLSL Introduction
    Vertex Shader
    Shaded triangle
    Pixel Shader
    Textured Triangle
    Triangle Strip
    World transform
    Adding normals
    The first light
    Shadow mapping
    Render To Texture
    Projective texturing
    The first shadow
    Shaping the light
    Preshaders
    Multiple lights
    Adjusting Z values
    Finishing touch
    Short Tuts (2)
    Resizing problem
    Checking Device caps
    DirectX using C++ (15)
    Series 1: Terrain (15)
    Opening a window
    Ending the game loop
    Linking to the Device
    Clearing your window
    Drawing a triangle
    Culling
    Camera
    Rotation - Translation
    Indices
    Terrain creation
    Terrain from file
    DirectInput
    Importing .bmp files
    Adding colors
    DirectX Light basics
    DirectX using VB (2)
    Series 1: Intro (2)
    The first triangle
    Rotation - translation
    -- Tree view --


    Thank you!

    Support this site --
    any amount is welcome !

    Stay up-to-date

    I don't have the time to keep a News section, so stay informed about the updates by clicking on this RSS file!