BasicEffect and SpriteBatch shader source code

BasicEffect and SpriteBatch shader source code

  • Comments 5

I'm pleased to announce we have released the HLSL source code for the shaders used by BasicEffect and SpriteBatch.

If you are just getting started with shaders and looking for something simple, these are probably not the best place to start. I would recommend the Shader Series as an introduction to 3D, or the Sprite Effects sample for 2D.

These new releases are intended for experienced programmers who are already familiar with how shaders work, and want to see exactly how we implemented the shaders that come built into the XNA Framework. The Xbox version of the SpriteBatch vertex shader is particularly interesting in the way it uses a vfetch instancing technique to offload computations to the GPU.

  • Thanks Shawn, that opens up some interesting possibilities. Very handy stuff.

  • I have thought to myself at least 100 times, "Hmm, I wish I could look at how the basic effect code is doing X or Y".  Is it possible Microsoft installed some Mind reading software in the last Vista update.  

  • This is very helpful in the transition to understanding and programming more complex shaders. I do have one newbie problem though. Are you (or someone else in the community) able to make an XNA project identical to the official XNA tutorial 1 that uses this newly published customizable BasicEffect (as an .fx file) instead of the normal (integrated) BasicEffect. Tutorial 1 is the one with the p1_wedge spaceship from the Spacewar starter kit. Obviously the visual end result should be the same. I just can't get it to work myself. As far as I can see, the Spacewar models all consists of one Bone, one Mesh, one Texture and three MeshParts (most likely the fuselage is one MeshPart and the cockpit and engine exhausts are the other two MeshParts). I tried with all the models from the Spacewar starter kit and they seem to all have the same problem. The cockpit and engine exhausts never get the correct material/texture/lighting, although the fuselage looks fine. This is probably a MeshParts material/effect problem, but since I cannot fix it myself, I am hoping that someone can show me and others how to make tutorial 1 use this new published BasicEffect.

  • XNAThomas:

    Great question!

    In fact I decided this deserved its own article. See here: http://blogs.msdn.com/shawnhar/archive/2008/08/22/basiceffect-a-misnomer.aspx

  • Link's broken as of 2010-10-22

    Fix please.

    I'm dying here......;-(

Page 1 of 1 (5 items)
Leave a Comment
  • Please add 4 and 6 and type the answer here:
  • Post