Files
beyond/Assets/Shaders/Bend.shader
2024-11-20 15:21:28 +01:00

71 lines
2.4 KiB
Plaintext

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Custom/Bend" {
Properties {
_Color ("Main Color", Color) = (1,1,1,0.5)
_MainTex ("Texture", 2D) = "white" { }
_Amplitude ("Amplitude", Vector) = (0.2, 0.2, 0.2, 0.2)
_Fase ("Fase", Vector) = (0.1, 0.1, 0.1, 0.1)
}
SubShader {
Pass {
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
float4 _Amplitude;
float4 _Fase;
fixed4 _Color;
sampler2D _MainTex;
uniform half unity_FogDensity;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
half2 fogDepth: TEXCOORD1;
};
float4 _MainTex_ST;
v2f vert(appdata_base v) {
v2f o;
const float aScale = 0.001;
const float fScale = 1.0;
o.pos = float4(v.vertex.x + sin(_Time.z + v.vertex.y * _Fase.x /* * fScale*/) *_Amplitude.x * aScale,
v.vertex.y + sin(_Time.y + v.vertex.x * _Fase.y/* * fScale*/) *_Amplitude.y * aScale, v.vertex.z, v.vertex.w);
o.pos = UnityObjectToClipPos (o.pos);
//o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
// o.pos = float4(o.pos.x + sin(_Time.z + o.pos.y * _Fase.x) *_Amplitude.x,
// o.pos.y + sin(_Time.y + o.pos.x * _Fase.y) *_Amplitude.y, o.pos.z, o.pos.w);
float2 sv = o.uv - float2(0.5, 0.5);
sv *= 2.0;
float l = length(sv) * _Fase.z;
l = cos(l + _Time.z);
o.uv += float2(l,l) * _Amplitude.z;
o.fogDepth.x = length(mul (UNITY_MATRIX_MV, v.vertex).xyz);
o.fogDepth.y = o.fogDepth.x * unity_FogDensity;
return o;
}
fixed4 frag(v2f i) : SV_Target {
fixed4 clr = tex2D(_MainTex, i.uv) * _Color;
float fogAmt = i.fogDepth.y * i.fogDepth.y;
fogAmt = exp(-fogAmt);
clr.xyz = lerp(unity_FogColor, clr.xyz, fogAmt);
return clr;
//return fixed4(i.uv, i.uv);
}
ENDCG
}
}
}