Skip to content

Commit fb303d8

Browse files
Integer noise algorhitm.
1 parent a00687a commit fb303d8

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

Diff for: integer_hash.shader

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//source: https://www.shadertoy.com/view/XlXcW4
2+
Shader "Integer Hash"
3+
{
4+
Subshader
5+
{
6+
Pass
7+
{
8+
CGPROGRAM
9+
#pragma vertex vertex_shader
10+
#pragma fragment pixel_shader
11+
#pragma target 4.0
12+
13+
static const uint k = 1103515245U;
14+
15+
struct custom_type
16+
{
17+
float4 vertex : SV_POSITION;
18+
float2 uv : TEXCOORD0;
19+
};
20+
21+
float3 hash( uint3 x )
22+
{
23+
x = ((x>>8U)^x.yzx)*k;
24+
x = ((x>>8U)^x.yzx)*k;
25+
x = ((x>>8U)^x.yzx)*k;
26+
return float3(x)*(1.0/float(0xffffffffU));
27+
}
28+
29+
custom_type vertex_shader (float4 vertex:POSITION, float2 uv:TEXCOORD0)
30+
{
31+
custom_type vs;
32+
vs.vertex = UnityObjectToClipPos (vertex);
33+
vs.uv = uv;
34+
return vs;
35+
}
36+
37+
float4 pixel_shader (custom_type ps) : COLOR
38+
{
39+
uint2 resolution = uint2 (1024,1024);
40+
uint3 p = uint3(ps.uv.xy*resolution,_Time.g*60);
41+
return float4(hash(p),1.0);
42+
}
43+
ENDCG
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)