шейдер Kaleidoscope
Добавлено: 30 окт 2010, 02:50
Еще один порт с shadertoy, анимированно издевается над текстурой ).
Синтаксис:
Используется glsl
/// Портировано с http://www.iquilezles.org/apps/shadertoy/
Shader "Kaleidoscope" {
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) {
half2 resolution = half2(1.0,1.0);
half2 p = -1.0 + 2.0 * IN.uv_MainTex / resolution.xy;
half2 uv;
float a = atan2(p.y,p.x);
float r = sqrt(dot(p,p));
uv.x = 7.0*a/3.1416;
uv.y = -_TimeT+ sin(7.0*r+_TimeT) + .7*cos(_TimeT+7.0*a);
float w = .5+.5*(sin(_TimeT+7.0*r)+ .7*cos(_TimeT+7.0*a));
float3 col = tex2D(_MainTex,uv*.5).xyz;
half4 color = half4(col*w,1.0);
o.Albedo = color.rgb;
o.Alpha = color.a;
}
ENDCG
}
FallBack "Diffuse"
}
Shader "Kaleidoscope" {
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) {
half2 resolution = half2(1.0,1.0);
half2 p = -1.0 + 2.0 * IN.uv_MainTex / resolution.xy;
half2 uv;
float a = atan2(p.y,p.x);
float r = sqrt(dot(p,p));
uv.x = 7.0*a/3.1416;
uv.y = -_TimeT+ sin(7.0*r+_TimeT) + .7*cos(_TimeT+7.0*a);
float w = .5+.5*(sin(_TimeT+7.0*r)+ .7*cos(_TimeT+7.0*a));
float3 col = tex2D(_MainTex,uv*.5).xyz;
half4 color = half4(col*w,1.0);
o.Albedo = color.rgb;
o.Alpha = color.a;
}
ENDCG
}
FallBack "Diffuse"
}