mouthporn.net
#shaders – @askagamedev on Tumblr
Avatar

Ask a Game Dev

@askagamedev / askagamedev.tumblr.com

I make games for a living and can answer your questions.
Avatar
Anonymous asked:

Just what is a shader anyway?

In short - a shader is a post-processing effect.

A shader is a small program that runs at certain points during the rendering pipeline that makes changes according to its program. You can think of a shader as a processing pass - it takes the existing information from the game and processes things to produce some kind of different result, often some kind of visual effect. For example, it can take all shades of green on a character model and apply some kind of filter to them, distort them, blur them, modify transparency, brighten them, project some other source onto them like a green screen, or any of a number of other effects. Most shaders have a format like “every so often, for each thing that matches some (or all) of these specific conditions, do this to the thing”. This can be very powerful to add specific touches to specific elements like making metal more dully reflective, glass transparent but also refractive, or even things water volumes reacting to objects placed into them. Since they can run every frame, you can have real time post-processing effects like these:

Breath of the Wild’s cel shading (and what it looks like without the shader)

Unity’s toon water shader:

Making fur:

They can also be applied to specific objects like how this VFX has shaders to cause distortion on particles emitted from the model here:

The big takeaway is whenever you see somebody say “shader”, think “post processing effect”.

The FANTa Project is being rebooted. [What is the FANTa project?]

Got a burning question you want answered?

Avatar
Anonymous asked:

How do dev teams go about making custom shaders for game visuals stylized or otherwise? Do they use photos of various colors and textures or is it all cgi and light effects based on equations?

Before we get into how custom shaders are created, we should talk for a minute about what a shader actually is. 

When we want to draw something on the screen, we first do a bunch of calculations about what model is where, what texture is where, what animation it’s playing, and so on and so forth. Then, once we figure all of that out, the rendering engine figures out what the camera sees and what all of the pixels should look like. The final result of this is a bunch of pixels set to specific colors at specific locations on the screen. 

Shaders are like mini programs that let us make programmatic adjustments to the pixels we’re about to display on the screen, kind of like how CG artists insert stuff into movie after the scenes have been shot via digital replacement. A shader is a specific program that takes each pixel that would be drawn on screen and runs some code on it to add some possible additional effect. Instead of affecting the game world possibly off-screen, shaders only work on the pixels that are going to be rendered.

Shaders are scripts usually written by technical artists and behave like code written by programmers specifically for graphical effects. Here’s some example code for a simple blur shader:

This shader, for each pixel we want to draw, takes the color of the eight neighboring pixels (up, down, left, right, and diagonals) and then takes their colors into account by some fractional number to adjust the color of the pixel in question. The overall effect is a blur, because each pixel’s color is slightly adjusted based on its neighbors’ color.

Shaders can also incorporate data like additional textures, time, etc. to do things like animate as well. Since it’s all code at the core, they can get super complicated really fast, which is why developers try to simplify things like making visual shader editors to make things a little easier for artists without heavy programming backgrounds. 

So, going back to your question, a lot of shader creation is about identifying the additional visual effect we’re trying to create, taking what we are given by the renderer, then writing a program to transform the pixels of what we have into pixels that are the color of what we want. The more complicated the effect, the more complicated the shader.

The FANTa Project has chosen its concept! We’re making a Skyrim Dungeon! [What is the FANTa project?]

Got a burning question you want answered?

You are using an unsupported browser and things might not work as intended. Please make sure you're using the latest version of Chrome, Firefox, Safari, or Edge.
mouthporn.net