Unity Advanced
Computer Graphics
Week 02
GameUIT - March 2017 - Tri.TMT
Contact: Fb: bit.ly/fb_tri , Linkedin: bit.ly/linkedin_tri
Source code : GitHub
Render Pipeline
The Difference between a CPU and GPU
The Difference between a CPU and GPU
The Difference between a CPU and GPU
Shader Languages
Cg (short for Central Graphics) - nvidia
GLSL (glslang) - OpenGL
HLSL (High-Level Shading Language) - DirectX
Shading Language used in Unity
In Unity, shader programs are written in a variant of HLSL language (also called
Cg but for most practical uses the two are the same).
Shader Compilers
- Windows & Microsoft platforms (DX9, DX11, DX12 and Xbox One) all use Microsoft’s
HLSL compiler (currently d3dcompiler_47).
- OpenGL Core, OpenGL ES 3 and Metal use Microsoft’s HLSL followed by bytecode
translation into GLSL, using a modified version of hlslcc.
- OpenGL ES 2.0 uses source level translation via hlsl2glslfork and glsl optimizer.
- Other console platforms use their respective compilers (e.g. PSSL on PS4).
Surface Shaders use Cg 2.2 and MojoShader for code generation analysis step.
First Shader
Project > Click Right > Create > Shader > Unlit Shader
First Shader
Shader Property
Shader Property
Shader Property
Shader data types and precision
Float : 32 bits
Half : 16 bits
Fixed : 11 bits
Integer
https://docs.unity3d.com/Manual/SL-DataTypesAndPrecision.html
ShaderLab Syntax
SubShader
Fallback
- Fallback "name"
Pass
Vertex and Fragment shaders
Vertex and Fragment shaders
Fragment Shader : Simple Color
Fragment Shader : Simple Color
Fragment Shader : ColorUV
Fragment Shader : ColorUV
Fragment Shader : Simple Texture
Fragment Shader : Multi Texture
Fragment Shader : Multi Texture
Vertex Shader : Waves
Vertex Shader : Waves
ShaderLab built-in values
ShaderLab built-in values
https://docs.unity3d.com/460/Documentation/Manual/SL-BuiltinValues.html
Exercise 01 : Shader GrayScale
GrayScale
Exercise 01 : Shader Brightness - Contrast
Exercise 02 : Shader Brightness - Contrast
BrightNess
Exercise 03 : Terrain
Exercise 04 : Shader Blur (option)
https://github.com/mattdesl/lwjgl-basics/wiki/ShaderLesson5
Exercise 03 : Shader Blur (option)
Exercise 03 : Shader Blur (option)
Other
https://www.assetstore.unity3d.com/en/#!/content/47482
https://www.assetstore.unity3d.com/en/#!/content/42566
Q&A
Thanks for watching.

Unity advanced computer graphics week 02