当前位置:网站首页>[unity note] l3unity shader learning begins
[unity note] l3unity shader learning begins
2022-04-21 15:26:00 【lee2813】
This chapter is a guide map

One 、 Implementation vertex / Chip shader
( One ) A simple vertex / Chip shader
- 1. Create a new geometry : stay GameObject Create a new sphere
- 2. Create a new one Unity Shader
- 3. Create a new material , hold Shader Give it to him
- 4. Then assign the material to the corresponding sphere
( Two ) edit Unity Shader
1. Examples are as follows :

give the result as follows :

- first line :Shader Name
- SubShader Semantic chunk : Due to the use of default rendering settings and label settings , So you don't need to set .
- Pass Semantic chunk : The default render settings and label settings are also used
- And then there's the CGPROGRAM and ENDCG Surrounded by CG code snippet
- Compile instructions # pragram vertex/fragment name Represents the vertex shader / The function name of the fragment shader
- Function part :: The following represents the semantics of variables . for example :POSITION Indicates that the input is the location of model space ,SV——POSITION Indicates that the output of the vertex shader is the position of the clipping space .
- SV_Target: Represents output to a rendered object , The default here is frame cache
- UNIty_MATRIX_MVP: Pass the coordinates of model space through MVP Change to crop space .
2. Use a structure to define the input of the vertex shader

- Structure member format : Type( data type ) Name : Semantic ( The semantics of data )
- For vertex shader output ,unity Supported semantics by :POSITION,TANGENT,NORMAL,TEXCOORD0,TEXCOORD1,TEXCOORD2,TEXCOORD3,COLOR etc.
- Be careful , Semantics cannot be omitted , Otherwise, the shader will be confused
3. Communication between vertex shader and slice shader
- Example :

- Be careful : Vertex shaders are called per vertex , The slice shader is called on a slice by slice basis . The input of the slice shader is actually the result of interpolating the output of the vertex shader .
4. Shader properties
- effect : Provide convenient parameters for material adjustment
- Location :Properties In the semantic block
- Example : among ,'_Color’ For an attribute , The type is Color, The initial value is (1.0,1.0,1.0,1.0)
- in addition , In order to be in CG This attribute can be accessed in the module , Need to be in CG A code block is defined with Properti Variables matching attributes in semantic blocks

5. semantics
-
Definition : Semantics is given to Shader Input and output strings , Indicates the meaning of this parameter
-
Stage 1 : When transferring model data to vertex shaders from the application phase Unity Common semantics supported

-
Stage two : When passing data from vertex shader to slice shader Unity Common semantics used

-
Stage three : Chip shader output Unity Common semantics supported

-
Example

版权声明
本文为[lee2813]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211520486980.html
边栏推荐
- Installation and uninstallation of MySQL
- 最佳实践 | 疫情之下,了解 eolink 如何助力远程办公!
- Web.xml文件详解
- JD cloud has launched cloud computing to create an unbounded office experience for the future
- JUC learning record
- 【unity笔记】L3Unity Shader学习开始
- AcWing 1854. 晋升计数(模拟)
- JUC并发学习笔记
- Glass: GNN tagging technique for subgraph representation learning
- Mysql
猜你喜欢

【C语言进阶】自定义类型:结构体,位段,枚举,联合

Take it easy, just talk about the soft test

111页精细化工股份公司数据字转型解决方案

On the import and export of browser bookmarks

What exactly does the distributed core principle analysis that fascinates Alibaba P8? I was surprised after reading it

MySQL

Smart Park Digital financing - Digital enabling operation management platform solution

111 page data word transformation solution of Fine Chemical Co., Ltd

Introduction to openlayers (I)

华为电力PON配网解决方案
随机推荐
EL&JSTL
【二分搜索-中等】540. 有序数组中的单一元素
汉诺塔游戏与递归
基于JSP的公益网站设计与实现
最佳实践 | 疫情之下,了解 eolink 如何助力远程办公!
红队技术-父进程伪装(MITRE ATT&CK框架:T1134)
Spark / Scala - read rcfile & orcfile
[binary search - simple] sword finger offer II 068 Find insertion location
Detailed explanation of basic knowledge of database 5: index and its two engines in mysql, master-slave replication and relational / non relational database
Machine learning methods create learnable chemical grammars and construct synthetic monomers and polymers
【二分查找-简单】441. 排列硬币
[binary search - simple] LCP 18 Breakfast combination
AcWing 1854. Promotion count (Analog)
读书破万“卷”:国民阅读洞察2022
[binary search - simple] 367 Effective complete square
万有导航:简洁实用的综合导航网站
Can station B be called YouTube in China?
How to set start date query statement in SQL Server
Dry goods | environmental problems or chronic difficulties in testing? It's easy to do it in two steps
【C语言进阶】自定义类型:结构体,位段,枚举,联合