当前位置:网站首页>Unity2D_线框材质
Unity2D_线框材质
2022-08-09 19:20:00 【不可_收_圾】
一.这个好像是以UV分隔
Shader "Custom/Wireframe"
{
Properties
{
_Color("Color",Color) = (1.0,1.0,1.0,1.0)
_EdgeColor("Edge Color",Color) = (1.0,1.0,1.0,1.0)
_Width("Width",Range(0,1)) = 0.2
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Blend SrcAlpha OneMinusSrcAlpha
LOD 200
Cull Front
zWrite off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "UnityCG.cginc"
struct a2v {
half4 uv : TEXCOORD0;
half4 vertex : POSITION;
};
struct v2f {
half4 pos : SV_POSITION;
half4 uv : TEXCOORD0;
};
fixed4 _Color;
fixed4 _EdgeColor;
float _Width;
v2f vert(a2v v)
{
v2f o;
o.uv = v.uv;
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag(v2f i) : COLOR
{
fixed4 col;
float lx = step(_Width, i.uv.x);
float ly = step(_Width, i.uv.y);
float hx = step(i.uv.x, 1.0 - _Width);
float hy = step(i.uv.y, 1.0 - _Width);
col = lerp(_EdgeColor, _Color, lx * ly * hx * hy);
return col;
}
ENDCG
}
Blend SrcAlpha OneMinusSrcAlpha
LOD 200
Cull Back
zWrite off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
#include "UnityCG.cginc"
struct a2v
{
half4 uv : TEXCOORD0;
half4 vertex : POSITION;
};
struct v2f
{
half4 pos : SV_POSITION;
half4 uv : TEXCOORD0;
};
fixed4 _Color;
fixed4 _EdgeColor;
float _Width;
v2f vert(a2v v)
{
v2f o;
o.uv = v.uv;
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag(v2f i) : COLOR
{
fixed4 col;
float lx = step(_Width, i.uv.x);
float ly = step(_Width, i.uv.y);
float hx = step(i.uv.x, 1.0 - _Width);
float hy = step(i.uv.y, 1.0 - _Width);
col = lerp(_EdgeColor, _Color, lx * ly * hx * hy);
return col;
}
ENDCG
}
}
FallBack "Diffuse"
}
二.以顶点连线分隔
在Unity资源商店里就有:UCLA Wireframe Shader
参考:Unity Shader物体线框https://www.cnblogs.com/Haha1999/p/15662830.html
边栏推荐
猜你喜欢
Transformer如何用于3D视觉?阿联酋MBZUAI最新《3D视觉Transformers处理》综述,涵盖100+种方法
Definition and Basic Operations of Sequence Tables
STM32WB55的FUS更新及协议栈固件烧写方法
新起之秀 DPU,正在掀起数据中心变革!
2.2 监督学习-1
tki-tree 树组件控制默认展开第几层数据
IS31FL3737B general 12 x 12 LED drive 40 QFN I2C 42 ma
【kali-权限提升】(4.2.6)社会工程学工具包(中):中间人攻击工具Ettercap
真香|持一建证书央企可破格录取
Win11搜索不到文件的解决方法
随机推荐
安科瑞支持以太网通讯、profibus通讯嵌入式电能表APM指导性技术要求-Susie 周
Prometheus Operator 通过additional 添加target
CMake 安装升级更高版本
获取一段程序运行的时间
Acrel5000web能耗系统在某学院的应用-Susie 周
解决执行Command报错executable file not found in $PATH
How to deal with keys when Redis is large?
【IoT毕设】STM32与机智云自助开发平台的宠物智能喂养系统
mysql duplicate data group multiple latest records
看完这波 Android 面试题;助你斩获心中 offer
Environment: Flink version: 1.15.1 jar package: flink-sql-connector-oracle
基于SSM实现手机销售商城系统
Toronto Research Chemicals加米霉素-d4说明书
基于光通信的6G水下信道建模综述
Redis 大的情况下,key 要如何处理?
hdu 2647 Reward(拓扑排序)
How are data integration APIs key to enterprise digital transformation?
AttributeError: module 'click' has no attribute 'get_os_args'
Number of daffodils within a thousand
线性表的定义和基本操作