Skip to content

JamesKim2998/unity-shader-startup-study

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Unity Shader Startup (μœ λ‹ˆν‹° 쉐이더 μŠ€νƒ€νŠΈμ—…)

Chapter 1: What is a Shader

Technically, a shader is the function that outputs final pixel color for screen presentation.

But things is not that simple, cause it's just a description for programmers. A shader is not just a function but also has more somewhat emotional touch.

In the past, the shader language is super complicated, so only programmers can handle it, and could produce reliable and quality results.

As time goes on, hardwares have been improved. These days, emotional touch has much more priority than technical efficiency.

Chapter 2: Prerequisites for Learning Shader

Rendering Pipeline

Explaining full details about rendering pipeline needs tremendous amount of expertise, so we skip all details.

Step 1: Receive Object Data

Send vertex data which includes vertex index, position, normal, color, and such to GPU.

Step 2: Vertex Shader

Translate object coordinate to camera coordinate.

Step 3: Rasterizer

Convert 3D object to 2D image

Step 4: Pixel Shader / Fragment Shader

Calculate light, put shadow, sample texture, etc.

Chapter 3: Layout of Unity Shader

Basically there's three ways to write shader using ShaderLab.

  1. Use only ShaderLab language.
  2. Surface Shader
  3. Vertex & Fragment Shader

Use only ShaderLab language

  • Very light computation cost.
  • Good hardware compatibility.
  • Using Unity specific language, so not very well mixed with other shader syntax.
  • Because of this, it's obsolete now.

Surface Shader

  • Basic lighting and the complex part of vertex shader are automatically handled.
  • But when it comes to optimization, it's hard to reach quality result.
  • And it's hard to use the case when the advanced technic should be applied.

Vertex & Fragment Shader

  • Hard to learn, but you can manually control all the part, so it's easy to optimize and good for applying advanced technic.

Chapter 4: Making Basic Surface Shader

Code

BrightDark Shader

BrightDark Shader

Chapter 5: Manipulating Texture with Surface Shader

Code

Grayscale

Grayscale Shader

Lerp

Lerp Shader

Chapter 6: Learn How to Use UV

Code

UV

UV Shader

Fire

Fire Shader

Fire2

Fire2 Shader

Chapter 7: Using Vertex Color

Code

VertexColor

VertexColor Shader

Chapter 8: Using StandardOutputShader

Code

StandardOutputShader

StandardOutputShader Shader

NormalMap

NormalMap Shader

VertexColorImproved

VertexColorImproved Shader

Chapter 9: Lambert & Blinn Phong

Code

Types of Digital Lights

  • Directional Light: Has only information like direction, intensity and color. The cheapest light.
  • Point Light: The light proceeds as sphere shape. Has heavier computational cost than directional light.
  • Spot Light: Highlights specific area. Also has heavy computational cost, so you should think about performance when use this kind of light.

Lambert

Lambert Shader

BlinnPhong

BlinnPhong Shader

Chapter 11: Manually Implement Lambert Lighting

Code

Custom Lambert

Custom Lambert Shader

Custom Lambert Shader Final

Half-Lambert

Half-Lambert Shader

Half-Lambert Shader Final

Chapter 12: Rim Light

Code

RimLight

RimLight Shader

Hologram

Hologram Shader

Chapter 13: Blinn-Phong Specular

Code

BlinnPhongSpecular

BlinnPhongSpecular Shader

BlinnPhongSpecularWithRim

BlinnPhongSpecularWithRim Shader

FakeSpecular

FakeSpecular Shader

Chapter 14: NPR (None-Photorealistic) Rendering

Code

Outline

Outline Shader

OutlinePattern

OutlinePattern Shader

Toon

Toon Shader

ToonWithSpecular

ToonWithSpecular Shader

FresnelOutline

FresnelOutline Shader

DiffuseWarping

DiffuseWarping Shader

DiffuseWarpingAdvanced

DiffuseWarpingAdvanced Shader

About

🌈 Study Unity shader. (Summer 2018)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published