Pixel Shaders to render directly to screen

Hello all,

I’m fairly new to using shaders in MonoGame. Basically, I’m trying to figure out how to use a shader to render a background effect (e.g. a starfield). All of the shaders I’ve done have a pattern like:

 Effect effect = ...
 Game.SpriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, effect);
 effect.CurrentTechnique.Passes[0].Apply();
 // sprite drawing happens here, and runs through shader
 // ...
 Game.SpriteBatch.End();

…where the shader applies to any sprites drawn during the batch.

But what if I don’t want my shader to operate on textures, but rather just use it to blat pixels to the screen algorithmically? (e.g. https://www.shadertoy.com/view/Md2SR3)

I guess I could create a texture that is the size of the screen, and just draw it during the batch, but that seems like a waste of memory.

Thanks in advance.

Your shader didn’t have to take a texture. You would render a screen size quad and use the interpolated values passed from the vertex shader, such as texture coordinates (you can have texture coordinates without a texture), in your pixel shader to generate the colour you want at that location.