当前位置:网站首页>《UnityShader入门精要》总结(2):初级篇
《UnityShader入门精要》总结(2):初级篇
2022-07-29 09:18:00 【饿掉鱼】
紫色:大类概念或简短有力的总结
蓝色:细分概念或重要部分
红色:重要的补充注释
第五章:认识UnityShader
从一个最简单的着色器结构说起

一个包含了顶点着色器和片元着色器的基本代码
#pragma 定义了着色器类型
vertex为顶点,fragment为片元 (shader使用的是CG语法)

其中的Fixed4,float4等都代表了什么?

看一个进阶版的将顶点和片元着色器联动的代码

如果觉得比较绕.可以暂时将冒号当做"来自于"理解
float4 vertex : POSITION
比如创建了一个float4变量vertex,其来自于POSITION(模型空间顶点坐标)
这次vert返回了一个v2f结构而非float4了.并且最后frag也成功引用了v2f完成着色
(vertex.normal是法线)


调用属性
属性就是在编辑器界面可更改的变量。使用Properties

直接在着色器中引用

这样,一个颜色可随时调节的shader就做好了

边栏推荐
猜你喜欢

浅谈契约测试

Flowable UI production flow chart

Mathematical modeling clustering
![[unity entry program] C # and unity - understand classes and objects](/img/bd/13cc90638c6e6ad4a45507b0ed2fb7.png)
[unity entry program] C # and unity - understand classes and objects

No swagger, what do I use?

2022 R2 mobile pressure vessel filling test question simulation test platform operation
![[Bert multi label text classification practice] I - overview of practical projects](/img/47/3e6cf5d49e41a03ea7f9b6eb295e1d.png)
[Bert multi label text classification practice] I - overview of practical projects

Could not receive a message from the daemon

How to change MySQL into Chinese

2022危险化学品经营单位主要负责人操作证考试题库及答案
随机推荐
Can the access database be accessed remotely
远程连接windows版本服务器redis的配置文件设置
不同数据库相同字段查不重复数据
A structured random inactivation UNET for retinal vascular segmentation
Trie树(字典树)讲解
[machine learning] logistic regression code exercise
Could not receive a message from the daemon
MySQL error summary
How to change MySQL into Chinese
Tesseract text recognition -- simple
【集中培训】HCIP-Cloud Computing 资源交流帖
Leetcode: interview question 08.14. Boolean operation
2022 P cylinder filling test simulation 100 questions simulation test platform operation
File upload and expansion
Flowable 基础篇1
用户身份标识与账号体系实践
Leetcode:132. split palindrome string II
C# 使用RestSharp库实现POST请求
乱打日志的男孩运气怎么样我不知道,加班肯定很多
Retinal Vessel Segmentation via a Semantics and Multi-Scale Aggregation Network