这篇文章主要为大家详细介绍了Unity3D Shader实现扫描显示效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
上一篇使用的方式是对UV进行剪裁,如果用于模型的话,会出现一些问题。本篇使用的方式是对模型进行模型空间的剪裁,可设置剪裁方向。效果如下:
设置界面如下:
Shader "XM/ScanEffect2"
{
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_Clip("Clip", float) = 0
[KeywordEnum(None, Left, Up, Forward)]_Mode("Mode", Float) = 0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows vertex:vert
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
float4 localPos;
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
float _Clip;
float _Mode;
void vert(inout appdata_full i, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
o.localPos = i.vertex;
}
void surf (Input i, inout SurfaceOutputStandard o) {
if(i.localPos.x >= _Clip && _Mode == 1 || i.localPos.y >= _Clip && _Mode == 2|| i.localPos.z >= _Clip && _Mode == 3)
{
clip(-1);
}
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, i.uv_MainTex) * _Color;
o.Albedo = c.rgb;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程学习网。
沃梦达教程
本文标题为:Unity3D Shader实现扫描显示效果(2)
![](/xwassets/images/pre.png)
![](/xwassets/images/next.png)
猜你喜欢
- C# 使用Aspose.Cells 导出Excel的步骤及问题记录 2023-05-16
- Unity Shader实现模糊效果 2023-04-27
- 在C# 8中如何使用默认接口方法详解 2023-03-29
- 如何使用C# 捕获进程输出 2023-03-10
- .NET CORE DI 依赖注入 2023-09-27
- user32.dll 函数说明小结 2022-12-26
- WPF使用DrawingContext实现绘制刻度条 2023-07-04
- Unity3D实现渐变颜色效果 2023-01-16
- Oracle中for循环的使用方法 2023-07-04
- c# 模拟线性回归的示例 2023-03-14