/// Портировано с http://www.iquilezles.org/apps/shadertoy/
/// "Information: 'Heart' by iq (2010)"
Синтаксис:
Используется glsl
Shader "Heart" {
Properties {
//_MainTex ("Base (RGB)", 2D) = "white" {}
_OffsetX ("Offset X", Float) = 0.5
_OffsetY ("Offset Y", Float) = 0.5
_Scale ("Scale", Float) = 0.5
_TimeT ("Time", Float) = 0.5
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
//sampler2D _MainTex;
float _OffsetX;
float _OffsetY;
float _Scale;
float _TimeT;
struct Input {
float2 uv_MainTex;
};
//float u( float x ) { return 0.5+0.5*sign(x); }
float u( float x ) { return (x>0.0)?1.0:0.0; }
//float u( float x ) { return abs(x)/x; }
void surf (Input IN, inout SurfaceOutput o) {
float2 p = (2.0*IN.uv_MainTex.xy-half2(_OffsetX,_OffsetY))/_Scale;
// animate
float tt = fmod(_TimeT, 2.0)/2.0;
float ss = pow(tt,.2)*0.5 + 0.5;
ss -= ss*0.2*sin(tt*6.2831*5.0)*exp(-tt*6.0);
p *= float2(0.5,1.5) + ss*float2(0.5,-0.5);
float a = atan2(p.x,p.y)/3.141593;
float r = length(p);
// shape
float h = abs(a);
float d = (13.0*h - 22.0*h*h + 10.0*h*h*h)/(6.0-5.0*h);
// color
float f = step(r,d) * pow(1.0-r/d,0.25);
half4 color = half4(f,0.0,0.0,1.0);
o.Albedo = color.rgb;
o.Alpha = color.a;
}
ENDCG
}
FallBack "Diffuse"
}
Properties {
//_MainTex ("Base (RGB)", 2D) = "white" {}
_OffsetX ("Offset X", Float) = 0.5
_OffsetY ("Offset Y", Float) = 0.5
_Scale ("Scale", Float) = 0.5
_TimeT ("Time", Float) = 0.5
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert
#pragma target 3.0
//sampler2D _MainTex;
float _OffsetX;
float _OffsetY;
float _Scale;
float _TimeT;
struct Input {
float2 uv_MainTex;
};
//float u( float x ) { return 0.5+0.5*sign(x); }
float u( float x ) { return (x>0.0)?1.0:0.0; }
//float u( float x ) { return abs(x)/x; }
void surf (Input IN, inout SurfaceOutput o) {
float2 p = (2.0*IN.uv_MainTex.xy-half2(_OffsetX,_OffsetY))/_Scale;
// animate
float tt = fmod(_TimeT, 2.0)/2.0;
float ss = pow(tt,.2)*0.5 + 0.5;
ss -= ss*0.2*sin(tt*6.2831*5.0)*exp(-tt*6.0);
p *= float2(0.5,1.5) + ss*float2(0.5,-0.5);
float a = atan2(p.x,p.y)/3.141593;
float r = length(p);
// shape
float h = abs(a);
float d = (13.0*h - 22.0*h*h + 10.0*h*h*h)/(6.0-5.0*h);
// color
float f = step(r,d) * pow(1.0-r/d,0.25);
half4 color = half4(f,0.0,0.0,1.0);
o.Albedo = color.rgb;
o.Alpha = color.a;
}
ENDCG
}
FallBack "Diffuse"
}