Compare commits
No commits in common. "308cc6c3c22c1257e5b6636ded3e1781ffd90b44" and "c39fca15678a13bbb492b162dbad814db9d23c14" have entirely different histories.
308cc6c3c2
...
c39fca1567
|
|
@ -16,7 +16,7 @@ fn on_fragment(in: Varying) -> @location(0) u32 {
|
|||
let x = bitcast<u32>(in.screen.x);
|
||||
let y = bitcast<u32>(in.screen.y);
|
||||
let rand = hash(hash(hash(SEED) ^ hash(x)) ^ hash(y));
|
||||
return rand >> 24;
|
||||
return rand >> 31;
|
||||
}
|
||||
|
||||
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 {
|
||||
let pos = vec2u(in.screen.xy);
|
||||
let state = textureLoad(field, pos, 0).x;
|
||||
return vec4f(f32(state) / 255.);
|
||||
return vec4f(f32(state));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,25 +16,12 @@ fn on_vertex(@builtin(vertex_index) vi: u32) -> Varying {
|
|||
|
||||
@fragment
|
||||
fn on_fragment(in: Varying) -> @location(0) u32 {
|
||||
let aa = textureGather(0, field, smp, in.uv, vec2(0, 0));
|
||||
let ab = textureGather(0, field, smp, in.uv, vec2(0, 1));
|
||||
let ba = textureGather(0, field, smp, in.uv, vec2(1, 0));
|
||||
let bb = textureGather(0, field, smp, in.uv, vec2(1, 1));
|
||||
let s = aa.y;
|
||||
let a = vec4(aa.xzw, bb.y);
|
||||
let b = vec4(ab.xy, ba.yz);
|
||||
var ret = 0u;
|
||||
for (var layer = 0u; layer < 8u; layer++) {
|
||||
let s = s >> layer & 1u;
|
||||
let a = a >> vec4(layer) & vec4(1u);
|
||||
let b = b >> vec4(layer) & vec4(1u);
|
||||
ret |= calc(s, a, b) << layer;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
fn calc(state: u32, a: vec4u, b: vec4u) -> u32 {
|
||||
let n = dot(a, vec4(1u)) + dot(b, vec4(1u));
|
||||
let a = textureGather(0, field, smp, in.uv, vec2(0, 0));
|
||||
let b = textureGather(0, field, smp, in.uv, vec2(0, 1));
|
||||
let c = textureGather(0, field, smp, in.uv, vec2(1, 0));
|
||||
let d = textureGather(0, field, smp, in.uv, vec2(1, 1));
|
||||
let state = a.y;
|
||||
let n = a.x + a.z + a.w + b.x + b.y + c.y + c.z + d.y;
|
||||
switch (n) {
|
||||
case 2u: { return state; }
|
||||
case 3u: { return 1u; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user