游戏开发论坛

 找回密码
 立即注册
搜索
查看: 4891|回复: 0

???Unity Shader??????????????????

[复制链接]

8717

主题

8783

帖子

1万

积分

版主

Rank: 7Rank: 7Rank: 7

积分
11952
发表于 2018-8-28 15:08:31 | 显示全部楼层 |阅读模式
?/????

????????????????????????????????Shader??????????????????????????????????????????????????????????????????????????????????????????????

?????????????????

??????????????????????????????????????????????????

???????????????????????????????

?????????????????????????????

????

1.gif

? ???????


2.gif

? ???????


3.gif

? ???????


4.gif

? ???????


??

5.jpg


????????????????????????????????????????????????????????????????????

????????????

6.gif


????????????????????????????????????????

7.jpg


?????????????

???

8.jpg

? ??????????


9.jpg

? ??????????



? ????


????????????????????????UV???????????????(0.11,0.51)????(0.12, 0.50)???(0.23,0.15)????(0.22,0.17)???????????????????????????????????????????????????????????????

10.jpg


????????????????????????????????????????????????????????????????????????????(NoiseTexture)??

11.jpg

? ??????


??????????????????????????????????

?????????"??"???????????????????????????????????????????????????

12.jpg

? Ps??????(??????????????)


13.gif

? ????????????


??????

14.jpg


15.jpg


?????????????????????????

1??????????Repeat???????????????????

16.jpg


2???????????????UV???????????????-1~1???????UV???????????????0.005???????????????????????????????????????

3??????????????????????????????????????R???(??????????(G)????(B)??)???????????????????????????????????????????????

17.jpg


4?????????????????????????????????????45???1????????????5~10???

???????????????????????????????????????????????????????????????????????????????

??

??????????????????????????UV????????????????? * ????????????

18.jpg

? ????????


19.gif

? U?????????????????


Shader???????????

20.jpg


?????????

1???????????

21.jpg


2????????

22.png


??

???????????X?Y???2D????Z????????? * ????????????????????????????????UV????????????????

23.gif

????????


24.jpg

?????


?????????????????????????????????????????????(????????????????????)?

Shader???????????

25.jpg


?????????

1???????????

26.jpg


?????Repeat??????????

27.gif


2????????

28.jpg


3??????

??????????????????(0,0)?????????

29.gif

??(0,0)??????


???????

30.jpg


??????? + ?? or ?? + ??

?????????????

31.gif

?????????


???????????

32.gif

??????????


33.jpg

? ???shader


???????

?????????????????(???????)??????????

??????

???????????????shader??Blend???Blend??????????????????????????????????????????????????????????????(???)?????????????????????(???????)????????????????

34.jpg

?????????


35.jpg


???????????BLEND?ADD??????(??BLEND???????...)????????

BLEND?

???????? = ??????? * ?????Alpha +  ??????? * (1 - ?????Alpha)

ADD?

???????? = ??????? +  ???????

???????????????Shader?Blend????????????

Blend SrcAlpha OneMinusSrcAlpha

? Blend One One

????????????????????????????????????Shader??????????????????????

?????????

1?????????????????????????

2???Alpha????????????????Alpha?????????Alpha????Unity???????Alpha???????????

3?????RGB?????Alpha??????????

4??????????????????????????????

??

?????????? = ???? op ??1 op ??2 op ??3

??x = ????? * ????? * ???????

????? = tex2D(???, uv + ??? + ???)

?????????Shader??????????????????????????????????????????????????????????????????????

???

??????????????????????????????

36.gif


??????????????????????????????????????

37.jpg


???????????????Motion?????uv??????PS????????????

38.jpg


??????????????????????????????UV?????(0~1)??????????????????

?????Motion?????????????????????????????????Point???????????UV???PhotoShop????????UV????????

39.jpg


????????????????????????????????????????????????????????????????????????????

????????

????????????????????Inspector??????????????????????????????????????????????? -- ???

40.jpg

? ????????????


41.gif

? ???????????


????????????

? ??Editor.cs????Editor?????

42.jpg


? ?????Editor?????

43.jpg


? ?Shader???????????????

44.jpg


? ?Editor?????OnInspectorGUI???

45.jpg


????????????????OnInspectorGUI????????????????????????OnInspectorGUI?????Inspector??????????

46.jpg

? ?????Inspector??


?????????????

???????????????????Properties ? Keywords?

Properties

Properties - ??????Shader???Properties???Properties????Inspector????????.mat?????????mat??????Draw??????????shader?

Keywords

Keywords - ??????????Shader???????????????

47.jpg


?????????????????Unity Shader Lab??????????????.shader(GPU???shader)?????(????)?

????????Shader????????????????????????????????????????????????shader???????????????

????Keywords??Unity???Keywords?????????multi_compile?shader_feature?????shader??????????Keyword???????????????.shader???????

48.jpg


???shader_feature?multi_compile??????????(????Making multiple shader program variants)???????????

OnInspectorGUI????????

??shader??Properties?Keywords
?
????????keyword???keyword??GUI???????
?
???????????
?
???????keyword
?
???????????

? ??shader??Properties?Keywords?

49.jpg


? ????????keyword???keyword??GUI????????

50.jpg


? ?????????????

???????MaterialProperty??????????????Shader??Properties????????

51.jpg


???????keyword ?????????????

52.jpg


?????????API

public Color ColorProperty(MaterialProperty prop, string label);//????

public float FloatProperty(MaterialProperty prop, string label);//?????

public Vector4 VectorProperty(MaterialProperty prop, string label);//????

public Texture TextureProperty(MaterialProperty prop, string label);//????

...

??API?????????MaterialEditor???

?????????????????????????????????????????...

????

? ?????????YouTube??????????????????????????????

https://www.youtube.com/watch?v=OYjMnMZe1Vg

? ???????????????Unity Shader Lab????????????????????????????????????????????

???????????????????????????????????

? ????????????????????TCG?????????????

????


via?????by??????  

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-17 13:51

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表