Xor Shaders
  • Tutorials
  • About

When to use shaders

2/3/2015

4 Comments

 
I have gotten many shader requests for effects that shaders wouldn't be good at making. Today I would like to explain the uses of shaders so that you know when to use them and when to look in to other resources like particles.

SHader uses

Shaders are for changing the color of pixels. It isn't used for anything more. Shaders can use textures or math to mix colors or blend them, but shaders can't easily be used for clickable or interactive objects in a scene. In general shaders are for recoloring or distorting. If you need textured shapes that can have gravity or motion (like rain for example), then you should use particles.

Particle uses

Particles are for moving and animated, textures or shapes that don't interact with objects or the scene. These are useful for effects like fire, rain, smoke, snow, etc. Blend modes can be applied to them also, so you can have additive blend (brightens the scene). However because particles aren't very interactive, then you may need objects.

Object uses

Objects should be used for anything interactive. That means that it should be used for things that can collide with other objects and bounce for instance. These however should be used lightly, because the are often the slowest. You probably don't want to use this for rain that can collide unless you don't have much rain.

Conclusion

Shaders are designed for effects like scan lines, vignette or sepia tone. Particles are designed for rain, fire, smoke, etc. Objects are for anything interactive like a bouncing ball. Now this doesn't mean that you can't use shaders for interactive things, but the process is harder and may be slower.
4 Comments
John Carmack
2/8/2016 09:28:16 pm

"Shaders are for changing the color of pixels. It isn't used for anything more."

LOL no. They can do a lot more than that.

Reply
Xor
2/17/2016 10:48:26 am

In the context, I am referring to the fragment shader which does just that. With a combination of the vertex shader and fragment shader you have a lot more options.

Reply
Jaysan
12/18/2017 01:15:19 pm

Let's say I want to pixelate (progressively more with time) some sprites like the SNES mosaic effect did back in old days. If it's not clear, I want to lower progressively the resolution of sprites. Are shaders appropriate?

Reply
Xor link
12/19/2017 08:16:06 am

You could use a shader to pixelate the textures, but I recommend just using a surface by changing the width and height. When you draw the surface draw it at stretched to a fixed width and height. Make sure texture interpolation is turned off or it will look blurry. Send me a message if you need help with the implementation!

Reply



Leave a Reply.

    Tutorials

    New tutorial at GMshaders.com!

    Categories

    All
    3D
    Beginner
    Intermediate

    Archives

    October 2021
    November 2019
    January 2019
    May 2016
    August 2015
    June 2015
    March 2015
    February 2015
    January 2015
    December 2014

    RSS Feed

Powered by Create your own unique website with customizable templates.