1.Introduction

Introduction

1. 课程导论

本课程是讲Unity Shader,主要分为五个部分:

  • 学习向量基础知识
  • 写第一个shader
  • 关注shaping functions
  • 添加灵活的噪声函数
  • 关注图片,纹理在shader里的,然后怎么用

1—5 关注片元着色器

6 开始关注顶点着色器 灯光

7 表面着色器

8 高级效果,low polygon mesh runtime和unity stencil buffer

9 透明效果

10 体积着色器 云效果

11 后处理技术(用在渲染之后

12 URP渲染管线

13 shader graph

14 回顾总结

2.Introduction

2.1 How To Rendering a triangle

  • Positions the vertices
  • Color the pixels

2.2 Unity Shaders

  • Vertex shader: Moves vertices from model coordinates to clip spacce coordinates
  • Fragment shader: Color the pixels in rgba format

2.3 RGBA

  • RGB value :[0,1]
  • Example:
    white pixel——(1,1,1,1)
    semi transparent red pixel——(1,0,0,0.5)

2.4 Z-buffering

  • something in front of another item would override the pixel color calculated by another shader
  • Z-buffer holds the distance of a pixel from the camera.
  • Renderer handles this for us.
  • We just move the vertices and color the pixels.

2.5 CPU and GPU

  • CPU: Can handle large programs with huge memory requirements
  • GPU:Can handle small programs with small memory requirements
  • GPU:Can run 100’s or even 1000’s of programs simutaneously
    Compare:because of parallel processing the GPU runs small programs
    many times faster than a CPU

2.6 Image programing

  • Often in a loop
  • Build up an image progressively逐步建立形象
  • Work across rows ande columns
    With shaders each vertex and pixel is independent of any other

3. CG is not Csharp

3.1 Strongly type

When we create a variable we need to give the variable a type:

type.eg. int num1 = 12;

CG is strongly typed like Csharp.

The number will have a certain number of digits and the deciaml point can go anywhere in these digits.

3.2 CG vectors

You can easily create vectors flow to V equals nought point five will create a variable v that contains two values with the value.

float2 v = 0.5;//v.x = 0.5 and v. y = 0.5
w = v*2;//w.x = 1 and w.y = 1

float4 w = 1.0;//w.x =1.0,w.y = 1.0,w.z = 1.0,w.w = 1.0

3.3 Packed arrays

Half,fixed…A fixed may take less memory than a float,it depends on the hardware.

Half2,half3,half4

Fixed2,fixed3,fixed4

  • Use half and fixed on mobile devices

Int2,int3,int4

Bool2,bool3,bool4

3.4 Functions

Csharp:

bool inRect(Vector2 pt,Vector4 rect){}

CG:

bool inRect(float2 pt,float4 rect){}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值