SAIMA/Assets//Shader/闪光/Flash.shader
GrassTE 159cfd8881 制作部分特效
1.创建了个人文件夹,复制了部分场景。
2.编写了URP的屏幕后特效框架。
3.制作了一个场景内模拟树叶飘落的粒子,增加一些场景内的动感。

4.制作了几个Shader
1)利用2D的顶点着色器制作了一个边缘扭曲的Shader可以用在飘落树叶上,模拟3D树叶翻飞的感觉。
2)制作了溶解的Shader,建议用在可破坏的障碍上。
3)制作了一个闪光的Shader,可以用在障碍物上突出障碍物,但是Shader还需修改,现在太违和了。

TODO:做了一半昼夜交替的效果,这也是忘了哪个老师的建议说可以加入一个太阳在运动,效果大概可以用灯光来做,目前测试的颜色变化是B先减弱15%,G减弱20%,然后B回升R减弱。

ps:我的拓展坞不见了接不了手柄,需要等明天到货后开发动起来的特效,这个键盘操作太脑檀了,我不认为普通人可以顺畅的两只手同方向依次按键还不会乱。

建议:
建议为可破坏的障碍物添加提前消失的机制,现在如果冲撞力度不大,碎块只会破碎不会分离,但碰撞体会关闭,很奇怪,建议使用Shader让其破碎后消失。(但是溶解消失的shader与游戏风格不搭,也可以给碎块一个右的力,做一个击飞效果)
2022-08-21 03:44:34 +08:00

121 lines
4.6 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Shader "Custom/Flash"
{
//                        
//               
//                     
//                      
//                      
//             
//                       
//                      
//                     
//                  
//                   
//                     
//                
Properties
{
_MainTex ("Base (RGB), Alpha (A)", 2D) = "black" {}
_Color("Color", Color) = (1,1,1,1)
_Angle("angle", Range(0, 360)) = 75
_Width("width", Range(0, 1)) = 0.2
_FlashTime("flash time", Range(0, 100)) = 1
_DelayTime("delay time", Range(0, 100)) = 0.2
_LoopInterval("interval time", Range(0, 100)) = 2
}
SubShader
{
LOD 200
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Pass
{
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Offset -1, -1
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _Color;
float _Angle;
float _Width;
float _FlashTime;
float _DelayTime;
float _LoopInterval;
float4 _MainTex_ST;
struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
struct v2f
{
float4 vertex : SV_POSITION;
half2 texcoord : TEXCOORD0;
fixed4 color : COLOR;
};
v2f o;
v2f vert (appdata_t v)
{
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = v.texcoord;
o.color = v.color;
return o;
}
// 计算亮度
//角度 宽度(x方向) 运行时间 开始时间 循环间隔
float flash(float2 uv, float angle, float w, float runtime, float delay, float interval)
{
float brightness = 0;
float radian = 0.0174444 * angle;
float curtime = _Time.y; //当前时间
float starttime = floor(curtime/interval) * interval; //本次flash开始时间
float passtime = curtime - starttime;//本次flash流逝时间
if (passtime > delay)
{
float projx = uv.y / tan(radian); //y的x投影长度
float br = (passtime - delay) / runtime; //底部右边界
float bl = br - w; //底部左边界
float posr = br + projx; //此点所在行右边界
float posl = bl + projx; //此点所在行左边界
if (uv.x > posl && uv.x < posr)
{
float mid = (posl + posr) * 0.5; //flash中心点
brightness = 1 - abs(uv.x - mid)/(w*0.5);
}
}
return brightness;
}
float4 frag (v2f i) : COLOR
{
float4 col = tex2D(_MainTex, i.texcoord);
float bright = flash(i.texcoord, _Angle, _Width, _FlashTime, _DelayTime, _LoopInterval);
float4 outcol = col + _Color*bright * col.a;// * step(0.5, col.a);
return outcol;
}
ENDCG
}
}
}