XNA for C#
DirectX 9 for C#
DirectX 9 for C++
DirectX 9 for VB
Forum
   2D Series finished!
My Book: Out Now!
      
       Go to section on this site

Additional info


Latest Forum posts

 Texture on a 3d Object
  Posted by: ToastbrotX
  When: 10/09/2010 at 10:23:08

 Unable to Build
  Posted by: Rich_Zap
  When: 09/09/2010 at 15:39:33

 HLSL calculating normals
  Posted by: Rich_Zap
  When: 09/09/2010 at 15:34:56

 Texture on a 3d Object
  Posted by: ToastbrotX
  When: 09/09/2010 at 11:14:19

 DRIVER ERROR XBOX 360
  Posted by: Anonymous
  When: 09/09/2010 at 01:12:47

 Reflection problem in corners ...
  Posted by: Anonymous
  When: 08/09/2010 at 21:03:35

 Texture on a 3d Object
  Posted by: radulph
  When: 08/09/2010 at 17:34:01

 InvalidDataException???
  Posted by: Anonymous
  When: 08/09/2010 at 09:10:36

 Unable to Build
  Posted by: Anonymous
  When: 08/09/2010 at 07:49:36

 Suggestion to change a few lines
  Posted by: Insomnica
  When: 06/09/2010 at 14:37:05


Ads

DirectX using C# and HLSL Season 3 – Overview

Welcome to this 3rd installment of my DirectX Tutorials for C#. This Series has as its main objective to introduce HLSL to you, what it is, what you can do with it and, of course, how to use it. This 3rd Series is written to be a complete hands-on HLSL Tutorial.

Once again, we’ll start very small, by drawing a simple triangle, and move on to more advanced topics and integrate them into our project. As main goal of this Series, we will be rendering a scene, that is being lit from 3 light sources.

So what’s so difficult about this? You already should have an idea about how to set up 3 lights for a scene, using regular DirectX code. In that case, however, all triangles in your scene would be lit by an amount of light that depends of how the triangle is facing your light sources (the sum of the 3 dot products between the normal of the triangle and the direction between the triangle and the light source).

But you will not see any shadows! This is because DirectX doesn’t know if there are any objects between the triangle and the light sources. So I thought having 3 lights with all of them casting their shadows would be nice goal for an introductionary Series on HLSL. Have a quick look at the screenshots at the bottom of this page and see if you can find the 3 light sources, together with their corresponding shadows.

Don’t be mistaken – this is already quite an advanced topic, and we’ll move quickly through the first sets of pages of this Series, as you already know how to draw triangles. This Series will put its main focus on HLSL.

So, what do I expect you to know already? You can click on each item to be taken to the page where the concept was introduced.

Required (concepts that will be expanded on):
  • Camera initialization
  • Drawing triangles from a vertex buffer (only vertex buffers, no index buffers)
  • Using a custom-made vertexformat
  • Adding textures to triangles
  • A basic understanding of lighting (dot product)

    Optional (code simply copied from previous chapters):
  • Device creation
  • Loading a Mesh from file
  • Fonts
  • Checking device capabilities
  • Handling device resets

    So what are you waiting for? Let’s move on to the first chapter!













    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 - 2008 Riemer Grootjans
  • Translations

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

    Microsoft MVP Award



    2007 - 2009 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 3.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
    2D screen processing
    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!