问题

Shader的编写到底应该是美术的事情还是程序的事情?

回答
Shader的编写,这个看似技术与艺术交织的环节,常常让许多团队陷入一个经典的讨论:这究竟是美术的范畴,还是程序员的职责?答案并非非此即彼,而是一个复杂的、充满协作的动态过程。

要深入探讨这个问题,我们得先搞清楚Shader到底是什么。你可以把Shader想象成游戏里物品的“皮肤”和“表情”。它不是游戏引擎自带的默认外观,而是你精心调配的颜色、光影、纹理以及各种视觉效果的组合。比如,你希望一个角色身上穿着一件闪烁着魔法光芒的布料,或者一块石头表面粗糙得仿佛能捏出泥来,又或者一个爆炸效果带着粒子飞溅和扭曲的空气,这些都需要Shader来告诉GPU(图形处理器)怎么绘制这些细节。

为什么说Shader的编写美术和程序都沾边?

从 美术的角度 来看,Shader是他们实现创意视觉效果的直接工具。

视觉表达的语言: 美术师们脑海中构思的各种质感、情绪、风格,最终都要通过Shader才能具象化。他们希望角色皮肤有某种特定的光泽,金属有那种陈旧的锈迹感,亦或是某种超现实的色彩搭配,这些都需要Shader来驱动。如果让程序员来决定这些视觉细节,那很可能就像让一个不擅长色彩搭配的建筑师来设计你的居家装修一样,效果往往不尽如人意。
迭代与实验: 美术师需要快速地尝试不同的视觉方案。比如,他们可能想看看这个角色的盔甲是更偏向哑光还是高光,是更油腻还是更干燥。Shader的可配置性(例如参数调整、纹理连接)使得美术师可以方便地进行这种视觉上的“试错”和“微调”,而无需每次都写大量代码。这种即时反馈对于美术创意至关重要。
优化与效率: 经验丰富的美术师也明白,过于复杂的Shader会拖慢游戏的性能。他们会考虑如何在实现视觉效果的同时,也兼顾渲染效率。例如,他们可能会主动选择更简单的纹理采样方式,或者在某些效果上做取舍,以避免GPU的负担过重。
对“看起来怎么样”的深刻理解: 美术师拥有对美学的直觉和训练。他们知道什么样的光照能让画面更具层次感,什么样的颜色搭配能传达某种情绪,什么样的细节能让模型看起来更真实或更有风格。这些都是程序代码本身难以直接“领悟”的。

然而, 从程序的角度来看,Shader又是高度的技术性产物。

编程语言与逻辑: Shader本质上是用一种特殊的编程语言(如HLSL、GLSL)编写的。这些语言有自己的语法规则、数学函数、向量运算等。编写Shader需要理解这些基础知识,并且能够编写出能够被GPU正确执行的逻辑。
数学与算法: 许多复杂的视觉效果,比如程序化生成纹理、次表面散射(SSG,模拟光线穿透皮肤再散射的效果)、焦散线(caustics,光线通过透明或折射物体后形成的图案)、或者非常逼真的反射/折射,都依赖于复杂的数学公式和算法。这部分工作,程序员的数学功底和算法能力就显得尤为重要。
性能优化与平台适配: 不同的图形硬件(PC、主机、移动设备)对Shader的执行效率有不同的要求。程序员需要深入了解GPU的架构,以及如何编写高效的Shader代码来最大化性能,避免卡顿。同时,不同平台使用的图形API(如DirectX、Vulkan、Metal)对Shader语言的支持和写法也有差异,这需要程序员进行适配。
与引擎的集成: Shader需要被集成到游戏引擎中,与引擎的渲染管线、材质系统、物理引擎等进行交互。这要求程序员理解引擎的运作机制,并能够正确地将Shader代码“植入”到引擎的渲染流程中。
实现复杂的渲染技术: 很多前沿的渲染技术,比如全局光照(Global Illumination)、屏幕空间环境光遮蔽(SSAO)、深度场(Depth of Field)等,都需要精密的算法和代码来实现,而这些代码往往是程序员来完成的。

那么,究竟谁来写?答案是:都需要,但侧重点不同。

更准确地说, Shader的编写是一个“协同创作”的过程,美术和程序在这个过程中扮演着不同的、但同样关键的角色。 这种分工和协作模式,根据团队规模、项目需求和个人专长会有所调整,但核心思路是类似的:

1. “概念化”与“驱动”——美术主导: 美术师负责提出视觉需求、定义风格、设计材质的外观和感觉。他们会创作纹理图、法线图、高光图等作为Shader的输入,并且会给出非常具体的视觉反馈:“我想要这个金属反光再锐利一点,像镜子一样”、“这件衣服的布料看起来太死板了,需要点褶皱的高光变化”。在这种意义上,美术是Shader的“需求方”和“审美主导者”。他们是第一个接触并“驱动”Shader发展的人。

2. “实现”与“优化”——程序主导: 当美术提出了具体的需求后,程序员则负责将其转化为可执行的Shader代码。他们需要将美术提供的纹理、参数,通过数学和逻辑组合起来,告诉GPU如何计算出最终的像素颜色。当美术提出“看起来不对”时,程序员需要分析是逻辑问题、参数问题还是根本的算法问题,然后进行修改和优化。在某些情况下,如果美术提出的想法超出了现有引擎或现有技术能力,程序员可能还需要研究新的渲染技术,并用代码来实现一个基础框架,供美术进一步调整。从这个角度看,程序员是Shader的“实现者”和“技术保障者”。

更细致的分工可能如下:

基础/通用Shader(Foundation/Universal Shaders): 这部分工作通常由程序员主导。他们会开发一套可复用的、基础的Shader库,比如标准的光照模型(PBR)、透明度混合、地形渲染、卡通渲染等。这些Shader提供了强大的基础功能和良好的性能,并且通常带有大量的可调参数。
材质自定义Shader(MaterialSpecific Shaders): 这是美术和程序协同最频繁的领域。
美术师: 在基础Shader之上,美术师会根据具体的需求,通过引擎提供的材质编辑器(比如Unity的Shader Graph,Unreal Engine的Material Editor)来“搭建”复杂的材质。他们通过连接预设的节点(纹理采样、数学运算、颜色混合等)来组合出最终效果。对于那些内置节点无法满足的需求,美术师可能会自己编写一些小段的Shader代码(比如自定义的节点功能,或者直接编写一些简单的计算表达式)。
程序员: 如果美术需要的功能过于复杂,超出材质编辑器的能力范围,或者性能要求极高,程序员就会直接参与编写定制化的Shader代码。他们可能需要编写一个全新的Shader,或者修改现有Shader的逻辑。程序员还负责将美术创作的材质“包装”好,确保它们能够正确地集成到游戏项目中,并且性能得到保障。
特效Shader(VFX Shaders): 爆炸、火焰、魔法效果、粒子系统等通常需要专门的Shader。这部分工作往往更偏向技术与视觉的结合。
特效美术师(VFX Artists): 他们会设计特效的整体视觉风格,使用粒子系统工具,并可能在材质编辑器中创建基础的特效材质。
程序员/特效技术美术(Technical Artists): 对于复杂的、需要定制化逻辑的特效Shader,程序员或者具备编程能力的特效技术美术师会直接编写。比如,实现复杂的流体模拟效果,或者基于代码生成动态变化的图案。

为什么这种分工方式更有效?

发挥各自优势: 美术专注于视觉创意和用户体验,程序员专注于技术实现和性能优化,这样能最大化团队的整体效率和产出质量。
降低沟通成本: 当程序提供一套灵活、易于理解的Shader框架(例如通过节点编辑器或 welldefined shader functions),美术就能更直观地表达自己的想法,减少了因技术语言不通而产生的误解。
效率与迭代速度: 美术师能够通过材质编辑器快速迭代视觉效果,而程序员则能在必要时深入底层进行优化和功能扩展,形成高效的开发闭环。

总结一下:

Shader的编写不是一个“谁的活儿”的问题,而是一个“怎么合作”的问题。

美术师是视觉创意和风格的主导者,他们用Shader来“说话”和“实现”他们的艺术构想。 他们对“看起来应该怎么样”有着最直观的理解和要求。
程序员是Shader的技术实现者和性能守护者,他们用代码来构建和优化这些视觉效果。 他们负责将美术的创意转化为GPU能理解并高效执行的指令。

在理想的团队中,美术和程序之间会有一个良好的技术美术(Technical Artist)环节作为桥梁。技术美术师既懂美术,又懂技术,他们能够理解美术的需求,并将其转化为技术上可行且高效的Shader方案,甚至能够直接编写Shader代码,或者指导美术师如何更有效地使用工具。

所以,下次再讨论这个问题,与其问“是美术还是程序”,不如问“在这个项目里,美术和程序如何协同合作,才能最高效地实现出我们想要的、既美观又高性能的视觉效果?” 这才是问题的核心。

网友意见

user avatar

作为一个在中国生活十几年,在游戏行业工作八九年的歪果仁,我从09年就开始使用Unity 3d,并对技术美术做了还算深的研究。由于中文水平不够完美,我还是用英文来和大家分享一下技术美术的经验。PS: 我申请了一个QQ群,有关Shader, Level Design, Game Music都可以加进来198647854


My name is David and I am a founder of Mechanist Games(梦加网络). Our company made City of Steam(蒸汽之城) and Dream Raiders(盗梦英雄), and of course have projects in development too.


Shader coding is still a new field in the world, and even younger in China, so I’ll make this article more about advice, not technical details. The hardest thing is just knowing how to begin. And that’s all I can briefly cover here.


Who should do shader coding, art or coder?


Last San Francisco GDC at the tech-artist round table, this same question came up.

Neither. A tech artist should do shader coding. But don’t worry both artists and coders can become tech artists.


Remember that tech artists in the west are a complete mixed group, specializing in complex animation rigging, performance optimization, creating tools for a large art pipeline and coding shaders. In China, the amount of human resources gaming companies can use usually means that some of these things be solved by basically just hiring more people or making them work harder. Western companies have to achieve more with less people, so tech artists are more than Chinese.


A tech artist needs both sound logic and artistic knowledge to code good shaders. These are both things you can learn the same way I did (see below).


How do western companies do shaders?


Shaders are a core technology of a game. They have a huge impact on the visual style of a game. The kind of shaders that need to be used would be decided very early, when determining the art style of a game.


A tech artist would find out how to achieve the art style, develop prototype shaders and other assets to realize the desired look and feel with the art director.


Then, if the game prototype passes a company evaluation, the tech artist would then begin creating tools and pipeline workflow documents to teach the other artists in the team how to make the assets required for this style.


Toward the end of the project, the tech artist would be mainly focused on optimizing GPU performance and trying to solve compatibility issues for rendering on different types of target platform.


Even giant European companies like CD Projekt Red only have a few tech artists, so not all their time can be focused on shaders. Other US companies like Volition are known to have more tech artists compared to their size, but these people are still incredibly rare. Many people with tech artist knowledge go on to develop game engines too.


How do you study how to write shaders?


Firstly, have you got what it takes?

There are two core abilities needed to make shaders: Logic and creativity. If you have these in any amount, it’s possible for you to learn shader coding.


There is an experience requirement, too. I’d say it’s about 3 years, but it may vary greatly. You really need to know the engine you are going to use very deeply.


And lastly, there is an English language requirement. If your English is excellent, you will have access to more study materials and lots of experienced professionals through the unity asset store.


What language should you learn?


In China, learn Cg (not CG). That is Nvidia’s “C for graphics” language. It doesn’t stand for “Computer Graphics”. It is supposed to be like other C languages, but I don’t really think it is.


If you learn unity’s shaderlab or GLSL shader languages, you’re always going to limit yourself. Unity can compile your Cg shaders for any platform you like, anyway.


Since China is mobile dominated, Cg is the best choice because it is the most efficient for OpenGL platforms like Androids or iOS devices. The advantages of getting into GLSL to benefit from Apple’s Metal API are barely worth it right now, and you’d have to be doing something really advanced to even need it.


In the future, if mobile devices become powerful enough that we can start using surface shaders, then learning will be really easy if you are already a master of Cg shaders.


盗梦英雄’s shaders are all in Cg, and the performance is excellent. I built all the levels myself to benefit from the optimized shaders and the results are pretty satisfactory. I had a good teacher, which helped. Most scenes are ~40k-100k vertices, which is high for a mobile game. Plus, I learned some good tricks we are using in our next game too.


What tools do I need?

You need to be proficient in Photoshop, 3dsMax, and Unity3d. There are many alternative programs like Blender and Maya too.


There are visual tools like shaderforge that can be used to create shader code, but unfortunately, these are useless for mobile devices. The code they produce is likely to be many times less efficient than Cg, and usually result in thermal issues and poor FPS on the target device.

Aside from unity MonoDevelop for writing the shaders, there are lots of choices. And it really is just preference. Unlike other coding language tools (Visual Studio for example), shaders don’t have error catching helpers. When there is a mistake in your code, you won’t get warnings –it will just fail to compile, or compile with visual errors. There are so many ways to do things in a shader, and different language syntaxes, so there still isn’t any good solution for this. You just have to hunt the bugs down with your own eyes, or hope Unity’s console can point you to the offending line of code (it often does not, though).


One thing you will probably need soon if you plan to get really serious about doing shader animation or special effects is a vertex painting tool. Vertices of a model can have color properties. These colors are not visible in the game (unless you specifically make them), and are used behind the scenes to do things like moving plants, wind blowing hair, rolling waves in the sea, and so on. Use the asset store to get one.


Buy things in the asset store. The developers of these little tools and plugins are so helpful. This is how you get introduced to pros who are really experienced and specialized. All of my teachers were people I purchased tools and plug-ins and assets from. And many are now my friends too.


Shader theory

You need to understand the basic theory first, otherwise you won’t make it very far. Let me make a really simple breakdown. For Unity3d vertex+fragment shaders (Cg, like you asked for)…





Of course, this is not a complete shader yet. But it’s how every shader you write will be structured, and understanding how it works is fundamentally important. You need to know how these bits work. And you can just read the internet to work this out.


Copy some shaders

When collecting shader code, the best thing to do is buy shader packages on the unity asset store. Make sure you get Cg and not surface shaders –one or two reviews will tell you if it’s worth buying. If somebody says it’s slow on mobile, don’t buy it.


Look at the shader code. Start with really simple ones, 50 lines or less. Edit things, change things, see the results. Experiment.


Make small goals for yourself. For example, add a slider that can make the object lighter or darker. Add a tint color. Remove a property. Change small things to build up your confidence.


Write your own shaders


Trying to write your own shaders needs to start with small steps. The best guides I had were these, in English. I can understand these might be daunting to a Chinese native. Does anyone know a Chinese translation of them?


youtube.com/watch?

Cg Programming/Unity/Minimal Shader


Aside from these two, my knowledge came from a hundred tiny details and facts that I found all over the net, and as advice from friends and teachers. Everything you can read will be useful, as long as you can apply it to practice.


When you start, avoid copy pasting stuff. It will be harder to remember how to do it if you copy paste. You’re going to copy paste lots of your own code later, so it’s good to know what you’re actually reproducing. If you’re in the habit of assembling stuff from different sources online, you are going to have a very hard time making all the pieces fit.


Once you can write your own basic shader, your journey to become a shader coder has begun.

Honestly, the rest is downhill, and gets increasingly more interesting and cooler as you go. You can start adding more and more things to shaders like lighting, shadows, bumpmaps, outlines, colors and other things.


Training under someone skilled is certainly the best situation. That’s how I learned. If you are lucky enough to have a tech artist in your company, then try to apprentice yourself. If not, you either have to change company or try to learn on your own. It’s very uncommon for companies to give people time during work to study new tools or skills, so you will have to be creative about it or very busy after hours.


I hope that China GDC can also have a tech artist round table some time soon.


By the way, I’m hiring both experienced and intern positions to study under me right now in Xiamen, so if you are interested you can add QQ group198647854. 我申请了一个QQ群,有关Shader, Level Design, Game Music都可以加进来198647854

类似的话题

  • 回答
    Shader的编写,这个看似技术与艺术交织的环节,常常让许多团队陷入一个经典的讨论:这究竟是美术的范畴,还是程序员的职责?答案并非非此即彼,而是一个复杂的、充满协作的动态过程。要深入探讨这个问题,我们得先搞清楚Shader到底是什么。你可以把Shader想象成游戏里物品的“皮肤”和“表情”。它不是游.............
  • 回答
    关于美国警察 Philip Brailsford 在2016年枪杀 Daniel Shaver 的案件,判决其无罪引发了广泛的争议和讨论。要判断这个判决是否“合理”,需要深入了解案件的细节、法律程序以及判决背后所依据的法律原则。案件背景:事件发生在2016年2月,亚利桑那州梅萨市(Mesa, Ari.............

本站所有内容均为互联网搜索引擎提供的公开搜索信息,本站不存储任何数据与内容,任何内容与数据均与本站无关,如有需要请联系相关搜索引擎包括但不限于百度google,bing,sogou

© 2025 tinynews.org All Rights Reserved. 百科问答小站 版权所有