当前位置:网站首页>Expansion method of unity scanning circle
Expansion method of unity scanning circle
2022-06-30 05:19:00 【Xiaosheng yunmu】
unity Scanning circle Circle extension method
Download address of engineering documents
complete shader Code
Shader "SongShaderDemo/RadiationCircle"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {
}
_CentorPoint("CentrePoint",Vector)= (0, 0, 0, 0)
_Dis("Float", Float) = 30// Maximum distance
_Range("Range", Range(0, 1.0)) = 0.01// Moving range
_LineWide("LineWide", Range(0, 1)) = 0.001// Line width
_Color("color",Color) = (1,1,1,1) // Color , It's usually used fixed4
_TransColor("TransColor",Color) = (1,1,1,0) // Color , It's usually used fixed4
_FillTex("FillTexture", 2D) = "white" {
}
_FillColor("FillColor",Color) = (1,1,1,1) // Color , It's usually used fixed4
}
SubShader
{
Tags {
"RenderType" = "Transparent" "IgnoreProjector" = "True" "Queue" = "Transparent" }
LOD 100
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv0 : TEXCOORD0;
float2 uv : TEXCOORD2;
float4 vertex : SV_POSITION;
float3 worldPos : TEXCOORD3;
};
CBUFFER_START(UnityPerMaterial)
sampler2D _MainTex;
float4 _MainTex_ST;
sampler2D _FillTex;
fixed4 _FillColor;
float4 _FillTex_ST;
float4 _CentorPoint;
float _Dis;
float _Range;
float _LineWide;
fixed4 _Color;
fixed4 _TransColor;
CBUFFER_END
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _FillTex);
o.uv0 = TRANSFORM_TEX(v.uv, _MainTex);
o.worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.uv0);
float dis = distance(i.worldPos, _CentorPoint.xyz);
float rangeMax = _Dis * _Range ;
float rangeMin = (_Dis)*_Range - _LineWide;
fixed4 Circle= _TransColor;
fixed4 FillCol = _TransColor;
if (dis> rangeMin&&dis< rangeMax)
{
Circle= fixed4(_Color.xyz, ((dis - rangeMin) / _LineWide)*(1 - _Range));
}
if (dis < rangeMin)
{
fixed4 FillTex = tex2D(_FillTex, i.uv);
if (FillTex.w!=0)
{
FillCol = fixed4(FillTex.xyz, (1 - _Range)) + _FillColor;
}
else
{
FillCol = FillTex + _FillColor;
}
}
fixed4 all = Circle + FillCol;
return all*all.w+ col*(1- all.w);
}
ENDCG
}
}
}
边栏推荐
- 【LeetCode】Easy | 232. Using stack to realize queue (pure C manual tearing stack)
- 东塔攻防世界—xss绕过安全狗
- Modbus protocol register
- East Tower attack and defense world - XSS bypasses the safety dog
- Unity3d- use animator and code to control task walking
- Chapter 7 vertex processing and drawing commands of OpenGL super classic (7th Edition)
- Detailed explanation of sorting sort method of JS array
- QT connecting external libraries
- Unity notes_ SQL Function
- Bessel curve with n control points
猜你喜欢

Unityshader learning notes - Basic Attributes

Baiwen.com 7 days Internet of things smart home learning experience punch in the third day

Records of some problems encountered during unity development (continuously updated)

ParticleSystem in the official Manual of unity_ Collision module

14x1.5cm竖向标签有点难,VFP调用BarTender来打印
![[notes] unity webgl input Chinese](/img/f7/805f510ff691227b4c2b529cc1099a.jpg)
[notes] unity webgl input Chinese

East Tower attack and defense world - XSS bypasses the safety dog

Introduction to mmcv common APIs

Unity project hosting platform plasticscm (learn to use 2)

Redis cluster concept
随机推荐
Unity ugui text value suspended enlarged display add text background
产生 BUG 测试人员需要自己去分析原因吗?
Responsive layout
Tensorflow2 of ubantu18.04 X installation
C # three ways to obtain web page content
Force buckle 27 Removing Elements
Network communication problem locating steps
Unity notes_ SQL Function
Nestjs中控制器和路由的配置使用
East Tower attack and defense world - XSS bypasses the safety dog
Unityshader learning notes - Basic Attributes
Chapter 10 of OpenGL super classic (7th Edition) calculation shader
Unity application class and data file path
GoLand No Tests Were Run : 不能使用 fmt.Printf() &lt;BUG&gt;
Unity3d- use animator and code to control task walking
Pytorchcnn image recognition and classification model training framework
[typescript] cannot redeclare block range variables
Chinese pycharm changed to English pycharm
【LeetCode】Easy | 232. Using stack to realize queue (pure C manual tearing stack)
The minecraft server address cannot be refreshed.