Подсмотрел на оф.форуме алгоритм для генерации шума,
поэтому вот небольшой сурфейс шейдер на тему:
Создает анимированный во времени шумок.
Синтаксис:
Используется glsl
Shader "Noise1" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert
#include "UnityCG.cginc"
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
float Rand( float2 inpos )
{
float2 input = inpos;
const float2 randvec = float2(15.12345, 91.98765);
float randangle = dot( input , randvec );
float rand = sin( randangle ) * 115309.76543;
return 1.0 - 2.0 * frac(rand);
}
void surf (Input IN, inout SurfaceOutput o) {
//tex2D (_MainTex, IN.uv_MainTex).rgb;
float g = Rand( IN.uv_MainTex.xy + _Time.y );
o.Albedo = half3(g,g,g);
}
ENDCG
}
Fallback "Diffuse"
}
Properties {
_MainTex ("Texture", 2D) = "white" {}
}
SubShader {
Tags { "RenderType" = "Opaque" }
CGPROGRAM
#pragma surface surf Lambert
#include "UnityCG.cginc"
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
float Rand( float2 inpos )
{
float2 input = inpos;
const float2 randvec = float2(15.12345, 91.98765);
float randangle = dot( input , randvec );
float rand = sin( randangle ) * 115309.76543;
return 1.0 - 2.0 * frac(rand);
}
void surf (Input IN, inout SurfaceOutput o) {
//tex2D (_MainTex, IN.uv_MainTex).rgb;
float g = Rand( IN.uv_MainTex.xy + _Time.y );
o.Albedo = half3(g,g,g);
}
ENDCG
}
Fallback "Diffuse"
}