Changeset 1840 for trunk/tutorial
 Timestamp:
 Aug 30, 2012, 8:17:04 PM (8 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/tutorial/03_noise.lolfx
r1830 r1840 16 16 uniform float u_Time; 17 17 18 vec3 mod289(vec3 x) 19 { 20 return x  floor(x * (1.0 / 289.0)) * 289.0; 21 } 22 23 vec3 perm(vec3 x) 24 { 25 return mod289(((x * 34.0) + 1.0) * x); 26 } 27 18 28 vec4 noise3d(vec3 p1, vec3 p2, vec3 p3, vec3 p4) 19 29 { 20 vec3 q = vec3(12.3453, 54.3353432, 34.3490432); 21 vec4 s = vec4(dot(p1, q), dot(p2, q), dot(p3, q), dot(p4, q)); 22 return fract(sin(54.343909 + s) * 8433.235443); 30 p1 = perm(perm(perm(p1) + p1.zxy) + p1.yzx); 31 p2 = perm(perm(perm(p2) + p2.zxy) + p2.yzx); 32 p3 = perm(perm(perm(p3) + p3.zxy) + p3.yzx); 33 p4 = perm(perm(perm(p4) + p4.zxy) + p4.yzx); 34 return fract(vec4(p1.x, p2.x, p3.x, p4.x) / 41.0); 23 35 } 24 36 … … 85 97  HLSL.Frag  86 98 99 float3 mod289(float3 x) 100 { 101 return x  floor(x * (1.0 / 289.0)) * 289.0; 102 } 103 104 float3 perm(float3 x) 105 { 106 return mod289(((x * 34.0) + 1.0) * x); 107 } 108 87 109 float4 noise3d(float3 p1, float3 p2, float3 p3, float3 p4) 88 110 { 89 float3 q = float3(12.3453, 54.3353432, 34.3490432); 90 float4 s = float4(dot(p1, q), dot(p2, q), dot(p3, q), dot(p4, q)); 91 return frac(sin(54.343909 + s) * 8433.235443); 111 p1 = perm(perm(perm(p1) + p1.zxy) + p1.yzx); 112 p2 = perm(perm(perm(p2) + p2.zxy) + p2.yzx); 113 p3 = perm(perm(perm(p3) + p3.zxy) + p3.yzx); 114 p4 = perm(perm(perm(p4) + p4.zxy) + p4.yzx); 115 return frac(float4(p1.x, p2.x, p3.x, p4.x) / 41.0); 92 116 } 93 117
Note: See TracChangeset
for help on using the changeset viewer.