views:

589

answers:

3

I would like to control ambient lighting for a 2D SpriteBatch rendered set of graphics on a global scale. I realise I can do this by blending the color passed into SpriteBatch.Draw but I'd rather do this globally.

The BasicEffect shader contols fixed function pipeline style lighting in XNA for simple scenes.

Is the BasicEffect shader and that of the SpriteBatch incompatible? Has anyone got these working together?

+1  A: 

This isn't a direct answer to your question, but may be of some use to you. BasicEffect and SpriteBatch objects are just shaders that the XNA team bundled with the release.

The source code of these shaders is available to for you to view/modify to your liking. Doing your own shaders will keep you from running into roadblocks continuously.

Here's where you can find more info and the source code: blogs.msdn.com

bufferz
A: 

As far as I'm aware, sprite batch uses it's own effect internally when rendering it's quads to the screen, as you can only render with one effect at the time, my answer would be no, they are not compatible.

Sekhat
A: 

Yes, they are incompatible.

This is because the spritebatch sas to use its own custom vertex shader to do the quad rendering. You can use your own custom pixel shader, and there is a sample on the xna creator's club education site that shows you how to use custom pixel shader effects with the spritebatch.

Joel Martinez