Now it’s 8-layer life!
This commit is contained in:
parent
c39fca1567
commit
33487a68b2
|
|
@ -16,7 +16,7 @@ fn on_fragment(in: Varying) -> @location(0) u32 {
|
||||||
let x = bitcast<u32>(in.screen.x);
|
let x = bitcast<u32>(in.screen.x);
|
||||||
let y = bitcast<u32>(in.screen.y);
|
let y = bitcast<u32>(in.screen.y);
|
||||||
let rand = hash(hash(hash(SEED) ^ hash(x)) ^ hash(y));
|
let rand = hash(hash(hash(SEED) ^ hash(x)) ^ hash(y));
|
||||||
return rand >> 31;
|
return rand >> 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hash(key : u32) -> u32 {
|
fn hash(key : u32) -> u32 {
|
||||||
|
|
|
||||||
|
|
@ -16,5 +16,5 @@ fn on_vertex(@builtin(vertex_index) vi: u32) -> Varying {
|
||||||
fn on_fragment(in: Varying) -> @location(0) vec4f {
|
fn on_fragment(in: Varying) -> @location(0) vec4f {
|
||||||
let pos = vec2u(in.screen.xy);
|
let pos = vec2u(in.screen.xy);
|
||||||
let state = textureLoad(field, pos, 0).x;
|
let state = textureLoad(field, pos, 0).x;
|
||||||
return vec4f(f32(state));
|
return vec4f(f32(state) / 255.);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,14 @@ fn on_fragment(in: Varying) -> @location(0) u32 {
|
||||||
let b = textureGather(0, field, smp, in.uv, vec2(0, 1));
|
let b = textureGather(0, field, smp, in.uv, vec2(0, 1));
|
||||||
let c = textureGather(0, field, smp, in.uv, vec2(1, 0));
|
let c = textureGather(0, field, smp, in.uv, vec2(1, 0));
|
||||||
let d = textureGather(0, field, smp, in.uv, vec2(1, 1));
|
let d = textureGather(0, field, smp, in.uv, vec2(1, 1));
|
||||||
|
var ret = 0u;
|
||||||
|
for (var layer = 0u; layer < 8u; layer++) {
|
||||||
|
ret |= calc(a >> vec4(layer) & vec4(1u), b >> vec4(layer) & vec4(1u), c >> vec4(layer) & vec4(1u), d >> vec4(layer) & vec4(1u)) << layer;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn calc(a: vec4u, b: vec4u, c: vec4u, d: vec4u) -> u32 {
|
||||||
let state = a.y;
|
let state = a.y;
|
||||||
let n = a.x + a.z + a.w + b.x + b.y + c.y + c.z + d.y;
|
let n = a.x + a.z + a.w + b.x + b.y + c.y + c.z + d.y;
|
||||||
switch (n) {
|
switch (n) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user