Image source 图片来源
A shader is an extra bit of code that is added to a render of a scene (or any other post production method). Shaders can alter visuals by changing the way textures and lighting are displayed, sometimes in ways that would be impossible with other techniques. 着色器是添加到场景渲染(或任何其他后期制作方法)的额外代码。着色器可以通过更改纹理和照明的显示方式来更改视觉效果,有时以其他技术无法实现的方式进行更改。
Shaders were originally designed to alter just the actual shading(referring to light) in a final scene, hence the name.
This has since evolved to alter all kinds of effects such as hue and saturation, bloom, contrast, and motion blur.
着色器最初被设计为仅改变最终场景中的实际着色(指光),因此得名。
此后,这已经发展到可以改变各种效果,例如色调和饱和度,绽放,对比度和运动模糊。
A shader is developed to use the computer’s GPU to add these effects, taking strain off the CPU for other tasks (such as calculating physics interactions). It feeds the vertex and texture information to the GPU which then gives back the lighting and color information.
Any real time render engine, and even some traditional renderers in 3D software packages will use shaders to calculate the lighting using physical based rendering (PBR).
着色器被开发为使用计算机的GPU来添加这些效果,从而减轻CPU在其他任务(例如计算物理相互作用)的压力。它将顶点和纹理信息提供给GPU,然后GPU返回照明和颜色信息。
任何实时渲染引擎,甚至 3D 软件包中的一些传统渲染器都将使用着色器,使用基于物理的渲染 (PBR) 来计算照明。
Image source 图片来源
Most shaders will be pre-sets within the software you decide to use. For example, if you use Unreal Engine 4 for designing a video game, the post processes object will give you options of which shaders you want to turn on or off in your game.
大多数着色器都是您决定使用的软件中的预设。例如,如果您使用虚幻引擎4来设计视频游戏,后期处理对象将为您提供要在游戏中打开或关闭哪些着色器的选项。
You can then open these up for even more options on how they will look in the build.
然后,您可以打开它们,以获取有关它们在构建中的外观的更多选项。
These types of shaders are called vertex shaders. However, more complex types of shaders exist called geometry and tessellation shaders.
这些类型的着色器称为顶点着色器。但是,存在更复杂的着色器类型,称为几何和曲面细分着色器。
These other types of shaders can actually change the base geometry of a mesh to give better results in certain instances. For example, tessellation shaders are slowly replacing LOD (level of detail) models as they can optimize a mesh in real-time depending on its distance to the camera. This can help save storage space as only one mesh is used instead of 3 or 4.
这些其他类型的着色器实际上可以更改网格的基本几何体,以便在某些情况下提供更好的结果。例如,曲面细分着色器正在慢慢取代LOD(细节层次)模型,因为它们可以根据网格到相机的距离实时优化网格。这有助于节省存储空间,因为仅使用一个网格而不是 3 个或 4 个网格。
Shaders are a very powerful tool. Their applications and abilities change rapidly as technology improves over time.
着色器是一个非常强大的工具。随着技术的进步,它们的应用和能力会迅速变化。
Image source 图片来源
A base level of understanding of what they are and what they can do is always good to have, but the vast majority of people do not need to know how they work in detail. This is because the presets in most software will usually cover any basics you may need.
对它们是什么以及它们能做什么的基本理解总是好的,但绝大多数人不需要知道他们是如何工作的。这是因为大多数软件中的预设通常会涵盖您可能需要的任何基础知识。
If the software you use doesn’t have a shader you want, or if you can’t change a parameter to the way you need it to be, it is possible to learn to create your own shaders. Though some development knowledge is required to do this.
如果您使用的软件没有所需的着色器,或者您无法将参数更改为所需的方式,则可以学习创建自己的着色器。虽然需要一些开发知识来做到这一点。
There are some tutorials on this topic, but note it’s very complex and takes a lot of practice to really understand what goes into actually making something for yourself.
有一些关于这个主题的教程,但请注意,它非常复杂,需要大量的练习才能真正理解真正为自己制作东西的原因。
Writing shaders is usually considered a specialized job on films, video games, and other big production studios. In fact, sometimes people are hired by large studios to only work on custom shaders. So if you’re good enough at designing shaders you could make a career out of it!
编写着色器通常被认为是电影,视频游戏和其他大型制作工作室的专门工作。事实上,有时人们被大型工作室雇用,只使用自定义着色器。因此,如果您擅长设计着色器,则可以从中开创一份职业!