Unity Shader学习笔记(6)RGB_Wave(波浪圈圈效果)尝试

先上效果图:

在这里插入图片描述

======================================= 效果为动态效果,视频文件链接===============================
Shader代码实现:

算法代码行可自行修改参数调试,顺便说一句,改变算法可以有很多玩法;

//灵感来源:https://www.shadertoy.com/view/XsXXDn
//修改制作:嘿皮土豆

Shader "LearnShadersFromOther/RGB_Wave"
{

	Properties{
		_MainTex("Mask Texture",2D) = ""{}

		_GlowScale("Glow Scale", Range(0,5)) = 1
	}

	SubShader
	{
		Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }

		Pass
		{
			ZWrite Off
			//控制混合方式,处理背景透明效果
			Blend One One

			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			#include "UnityCG.cginc"

			struct VertexInput {
			fixed4 vertex : POSITION;
			fixed2 uv:TEXCOORD0;
			fixed4 tangent : TANGENT;
			fixed3 normal : NORMAL;
			};


			struct VertexOutput {
			fixed4 pos : SV_POSITION;
			fixed2 uv:TEXCOORD0;
			};

			sampler2D _MainTex;
			float4 _MainTex_ST;
			fixed _GlowScale;

			VertexOutput vert (VertexInput v)
			{
			VertexOutput o;
			o.pos = UnityObjectToClipPos (v.vertex);
			o.uv = TRANSFORM_TEX(v.uv, _MainTex);
			//o.uv = v.uv;
			return o;
			}

			fixed4 frag(VertexOutput i) : SV_Target
				{
			
					fixed c[3];

					fixed4 col = tex2D(_MainTex, i.uv);

						for(int j=0;j<3;j++) 
						{
							float2 uv = i.uv;

							float2 uvr = 2 * uv - 1;
							uv -= 0.5;
							
							//uv = uv * 0.5 + 0.5;
							
							_Time.y += 0.5;

							//fixed l=length(uv);
							fixed l=sqrt(dot(uvr,uvr));
							
							uv += uv.yy / (l * abs((cos(_Time.y) + 2)) * cos(l * 11 - _Time.y - _Time.y));
							c[j] = 0.03/length(fmod(uv,1) - 0.5);
						}

						fixed3 diff = fixed3(c[0], c[1], c[2]);
						diff = diff*col.rgb * _GlowScale;

					return fixed4(diff,1);
				}
				ENDCG
		}
	}
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嘿皮土豆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值