File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88#include < pp_depth_buffer_precision_pars_fragment>
99#include < pp_depth_utils_pars_fragment>
1010#include < pp_frame_buffer_precision_pars_fragment>
11+ #include < pp_noise_pars_fragment>
1112#include < pp_normal_codec_pars_fragment>
1213#include < pp_normal_utils_pars_fragment>
1314#include < pp_resolution_pars_fragment>
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import depthUtilsParsFragment from "./shaders/depth-utils-pars.frag";
1111import frameBufferPrecisionParsFragment from "./shaders/frame-buffer-precision-pars.frag" ;
1212import gbufferDefaultOutputFragment from "./shaders/gbuffer-default-output.frag" ;
1313import inputBufferParsFragment from "./shaders/input-buffer-pars.frag" ;
14+ import noiseParsFragment from "./shaders/noise-pars.frag" ;
1415import normalCodecParsFragment from "./shaders/normal-codec-pars.frag" ;
1516import normalUtilsParsFragment from "./shaders/normal-utils-pars.frag" ;
1617import resolutionParsFragment from "./shaders/resolution-pars.frag" ;
@@ -71,6 +72,7 @@ export class ShaderChunkExtensions {
7172 "pp_gbuffer_emission_fragment" : gbufferEmissionFragment ,
7273 "pp_input_buffer_pars_fragment" : inputBufferParsFragment ,
7374 "pp_normal_codec_pars_fragment" : normalCodecParsFragment ,
75+ "pp_noise_pars_fragment" : noiseParsFragment ,
7476 "pp_normal_utils_pars_fragment" : normalUtilsParsFragment ,
7577 "pp_resolution_pars_fragment" : resolutionParsFragment ,
7678 "pp_world_utils_pars_fragment" : worldUtilsParsFragment
Original file line number Diff line number Diff line change 1+ /* *
2+ * Bitwise noise functions, based on work by Lee C.
3+ *
4+ * @see https://amindforeverprogramming.blogspot.com/2013/07/random-floats-in-glsl-330.html
5+ */
6+
7+ uint uhash(uint x) {
8+
9+ x += x >> 11 ;
10+ x ^= x << 7 ;
11+ x += x >> 15 ;
12+ x ^= x << 5 ;
13+ x += x >> 12 ;
14+ x ^= x << 9 ;
15+ return x;
16+
17+ }
18+
19+ uint uhash(uvec2 p) {
20+
21+ uint x = p.x;
22+ x += x >> 11 ;
23+ x ^= x << 7 ;
24+ x += p.y;
25+ x ^= x << 6 ;
26+ x += x >> 15 ;
27+ x ^= x << 5 ;
28+ x += x >> 12 ;
29+ x ^= x << 9 ;
30+ return x;
31+
32+ }
33+
34+ uint uhash(uvec3 p) {
35+
36+ uint x = p.x;
37+ x += x >> 11 ;
38+ x ^= x << 7 ;
39+ x += p.y;
40+ x ^= x << 3 ;
41+ x += p.z ^ (x >> 14 );
42+ x ^= x << 6 ;
43+ x += x >> 15 ;
44+ x ^= x << 5 ;
45+ x += x >> 12 ;
46+ x ^= x << 9 ;
47+ return x;
48+
49+ }
50+
51+ float urand(uint h) {
52+
53+ const uint mantissaMask = 0x007FFFFFu;
54+ const uint one = 0x3F800000u;
55+
56+ h &= mantissaMask;
57+ h |= one;
58+
59+ float r2 = uintBitsToFloat(h);
60+ return r2 - 1.0 ;
61+
62+ }
63+
64+ float urand(float p) {
65+
66+ return urand(uhash(floatBitsToUint(p)));
67+
68+ }
69+
70+ float urand(vec2 p) {
71+
72+ return urand(uhash(floatBitsToUint(p)));
73+
74+ }
75+
76+ float urand(vec3 p) {
77+
78+ return urand(uhash(floatBitsToUint(p)));
79+
80+ }
You can’t perform that action at this time.
0 commit comments