当前位置:网站首页>unity 扫描圈 圆扩展方法
unity 扫描圈 圆扩展方法
2022-06-30 05:17:00 【小生云木】
unity 扫描圈 圆扩展方法
完整shader代码
Shader "SongShaderDemo/RadiationCircle"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {
}
_CentorPoint("CentrePoint",Vector)= (0, 0, 0, 0)
_Dis("Float", Float) = 30//最大距离
_Range("Range", Range(0, 1.0)) = 0.01//移动范围
_LineWide("LineWide", Range(0, 1)) = 0.001//线宽
_Color("color",Color) = (1,1,1,1) //颜色,一般用fixed4
_TransColor("TransColor",Color) = (1,1,1,0) //颜色,一般用fixed4
_FillTex("FillTexture", 2D) = "white" {
}
_FillColor("FillColor",Color) = (1,1,1,1) //颜色,一般用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
}
}
}
边栏推荐
- Unity shortcut key
- Sourcetree usage
- Unity C trigonometric function, right triangle corner calculation
- Nestjs configures static resources, template engine, and post examples
- Unity camera control
- PyGame. Why can't I exit when I click X in the window? I can only exit when I return idle
- [note] usage model tree of the unity resource tree structure virtualizingtreeview
- Detailed explanation of the loss module of mmdet
- Introduction to mmcv common APIs
- pytorch中常用损失函数总结
猜你喜欢
![[vcs+verdi joint simulation] ~ take the counter as an example](/img/fb/214a4e65c53503ecbc38a5e43523cf.png)
[vcs+verdi joint simulation] ~ take the counter as an example
![[notes] unity webgl input Chinese](/img/f7/805f510ff691227b4c2b529cc1099a.jpg)
[notes] unity webgl input Chinese

Unity3d packaging and publishing APK process

Unity- the camera follows the player

Pit of smoothstep node in shadergraph

Unity C trigonometric function, right triangle corner calculation

Unity project hosting platform plasticscm (learn to use 2)

Redis cluster concept
![[typescript] cannot redeclare block range variables](/img/52/2fd3071ca9e3c5023c6b65961e2cf7.jpg)
[typescript] cannot redeclare block range variables

Intellj idea jars projects containing external lib to other project reference methods - jars
随机推荐
VFPBS上传EXCEL并保存MSSQL到数据库中
2021-10-31
Unity C trigonometric function, right triangle corner calculation
【 VCS + Verdi joint simulation】 ~ Taking Counter as an Example
Unity gets the resolution of the game view
Unity mobile end sliding screen rotation
Unity supports the platform # define instruction of script
Records of some problems encountered during unity development (continuously updated)
Unity scroll view element drag and drop to automatically adsorb centering and card effect
Read and save txt files
Unity3d get screen width and height
Responsive flow layout
[notes] unity Scrollview button page turning
OpenGL draws model on QT platform to solve the problem of initializing VAO and VBO
Records of problems encountered in unity + hololens development
Nestjs introduction and environment construction
Unity ugui text value suspended enlarged display add text background
Parkour demo
Nestjs入门和环境搭建
MinGW-w64下载文件失败the file has been downloaded incorrectly!
