Пульсирует достаточно хитро ).
Надо будет вынести побольше настроек .
Скриншот бесполезен, поэтому не прикладываю.
Синтаксис:
Используется glsl
/// Портировано с http://www.iquilezles.org/apps/shadertoy/
/// Information: 'Pulse' by Danguafer/Silexars (2010)
Shader "Pulse" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_TimeT ("Time", Float) = 0.5
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
#include "UnityCG.cginc"
sampler2D _MainTex;
float _TimeT;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
half4 c = tex2D (_MainTex, IN.uv_MainTex);
float2 resolution = float2(4, 4);
float2 halfres = resolution.xy/2.0;
half2 cPos = IN.uv_MainTex;
cPos.x -= 0.5*halfres.x*sin(_TimeT/2.0)+0.3*halfres.x*cos(_TimeT)+halfres.x;
cPos.y -= 0.4*halfres.y*sin(_TimeT/5.0)+0.3*halfres.y*cos(_TimeT)+halfres.y;
float cLength = length(cPos);
float2 uv = IN.uv_MainTex.xy/resolution.xy+(cPos/cLength)*sin(cLength/30.0-_TimeT*10.0)/25.0;
float3 col =c.rgb*5.0/cLength;
half4 color = half4(col,1.0);
o.Albedo = color.rgb;
o.Alpha = color.a;
}
ENDCG
}
FallBack "Diffuse"
}
/// Information: 'Pulse' by Danguafer/Silexars (2010)
Shader "Pulse" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_TimeT ("Time", Float) = 0.5
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
#include "UnityCG.cginc"
sampler2D _MainTex;
float _TimeT;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o)
{
half4 c = tex2D (_MainTex, IN.uv_MainTex);
float2 resolution = float2(4, 4);
float2 halfres = resolution.xy/2.0;
half2 cPos = IN.uv_MainTex;
cPos.x -= 0.5*halfres.x*sin(_TimeT/2.0)+0.3*halfres.x*cos(_TimeT)+halfres.x;
cPos.y -= 0.4*halfres.y*sin(_TimeT/5.0)+0.3*halfres.y*cos(_TimeT)+halfres.y;
float cLength = length(cPos);
float2 uv = IN.uv_MainTex.xy/resolution.xy+(cPos/cLength)*sin(cLength/30.0-_TimeT*10.0)/25.0;
float3 col =c.rgb*5.0/cLength;
half4 color = half4(col,1.0);
o.Albedo = color.rgb;
o.Alpha = color.a;
}
ENDCG
}
FallBack "Diffuse"
}
Скрипт для управления временем (_Time из UnityCG.cginc у меня что-то не заработал):
Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class TimeToShader : MonoBehaviour {
public float timeScale = 1f;
void Update ()
{
Time.timeScale = timeScale;
renderer.material.SetFloat("_TimeT", Time.time);
}
}
using System.Collections;
public class TimeToShader : MonoBehaviour {
public float timeScale = 1f;
void Update ()
{
Time.timeScale = timeScale;
renderer.material.SetFloat("_TimeT", Time.time);
}
}