XNA Creators Club Online
Page 1 of 1 (12 items)
Sort Posts: Previous Next

New Content Available: SpriteBatch and BasicEffect Shaders

Last post 8/28/2008 9:06 PM by emzic. 11 replies.
  • 8/15/2008 5:39 PM

    New Content Available: SpriteBatch and BasicEffect Shaders

    Hey Creators,

    Today we're releasing the shaders that run the SpriteBatch and BasicEffect drawing routines in the XNA Framework. This has been requested for a while, and now, thanks to Teh Shawn, we're bringing them to you.

    Here's the direct links:

    BasicEffect Shader

    SpriteBatch Shader

    They come with some simple documentation that shows you how the shader works and how to integrate it into your own game. The upshot for most cases is that now you can add your own pixel shader effects while still using SpriteBatch/BasicEffect!

    Thanks, and have fun!
    Charles

    Charles Cox
    XNA Community Content Producer | Microsoft
    http://www.the-agent.net
  • 8/17/2008 9:54 AM In reply to

    Re: New Content Available: SpriteBatch and BasicEffect Shaders

    Thanks a lot! You are great guys! :D
  • 8/18/2008 4:53 PM In reply to

    Re: New Content Available: SpriteBatch and BasicEffect Shaders

    Wouldn't it be a little more effective if SpriteBatch.RenderBatch() rendered the triangles not by using DrawIndexedPrimitives() in a while loop but using the hardware instancing by a secondary stream? Of course, only when running SM3.0. I guess that the benefit could be insignificant, but I'm just curious anybody's opinion.

  • 8/19/2008 9:27 PM In reply to

    Re: Maerius - instancing

    You make a good point; the first thing I though of was how SpriteBatch allows many sprites with different textures. So you'd need to have a different stream for each texture. afaik you can't give the GPU a vertex and index buffer pair and tell it some triangles will be drawn with Texture A, others with Texture B, more yet with Texture C.
  • 8/19/2008 9:33 PM In reply to

    Re: New Content Available: SpriteBatch and BasicEffect Shaders

    I'd guess that with something like a sprite (which is two triangles) the overhead from passing a second stream in for all the positions would be no better, or worse, than just rendering the triangles. Not to mention now you have a second code branch that only works on SM3.0 meaning you have more to maintain, bug test, and worry about breaking. It's probably just the easiest and safest bet for them to just stick with one version that works across all supported machines.

    But now that they've given you the shader, you can definitely write your own SpriteBatch to take advantage of anything you want. ;)

  • 8/20/2008 11:16 AM In reply to

    Re: New Content Available: SpriteBatch and BasicEffect Shaders

    Well I guess you're right. There is always an option of using ID3DXSprite but if I had to rewrite SpriteBatch class I would probably do it the same way it is done, so sorry for grumbling.
  • 8/28/2008 6:18 PM In reply to

    Re: New Content Available: SpriteBatch and BasicEffect Shaders

    thanks a lot for this! now how do i use my custom effect? i think i will need to remove the original BasicEffect from the ModelMesh.Effects ModelEffectCollection and add my own. but unfortunately i cant find a function in the ModelEffectCollection class that allows to add or remove an effect.
  • 8/28/2008 6:25 PM In reply to

    Re: New Content Available: SpriteBatch and BasicEffect Shaders

    Check out the samples section. There is a sample that shows how to use a custom effect with a model.

     

  • 8/28/2008 6:58 PM In reply to

    Re: New Content Available: SpriteBatch and BasicEffect Shaders

    thanks a lot! which example exactly do you mean? because i have looked through most of them and they all seem to not use the Effects-Collection on the ModelMesh but rather call effect.begin() and effect.end() and render the indexed primitves in between.
  • 8/28/2008 7:31 PM In reply to

    Re: New Content Available: SpriteBatch and BasicEffect Shaders

  • 8/28/2008 8:17 PM In reply to

    Re: New Content Available: SpriteBatch and BasicEffect Shaders

    Nick Gravelyn:
    Probably the one titled Custom Model Effect. ;)

    That's the one. I was too lazy to look it up. ;-)

  • 8/28/2008 9:06 PM In reply to

    Re: New Content Available: SpriteBatch and BasicEffect Shaders

    thanks a lot, i didnt see that one! :-) so it seems i need to write another contentprocessor, right? is there a way to add multiple effects to the ModelEffectCollection?
Page 1 of 1 (12 items) Previous Next