diff --git a/shaders/post0.wgsl b/shaders/post0.wgsl deleted file mode 100644 index a075837..0000000 --- a/shaders/post0.wgsl +++ /dev/null @@ -1,57 +0,0 @@ -struct Data { - size: vec2, - step: vec2, - factor: vec2, - pad: vec2, -} - -@group(0) @binding(0) -var data: Data; - -struct VertexOutput { - @builtin(position) pos: vec4, - @location(0) uni: vec2, - @location(1) map: vec2, -} - -@vertex -fn vsmain(@builtin(vertex_index) in_vertex_index: u32) -> VertexOutput { - var out: VertexOutput; - switch in_vertex_index { - case 0u { - out.pos = vec4(1., -1., 0., 1.); - out.uni = vec2(1., 1.); - out.map = data.factor.xy; - } - case 1u { - out.pos = vec4(1., 1., 0., 1.); - out.uni = vec2(1., 0.); - out.map = vec2(data.factor.x, 0.); - } - case 2u { - out.pos = vec4(-1., -1., 0., 1.); - out.uni = vec2(0., 1.); - out.map = vec2(0., data.factor.y); - } - case 3u { - out.pos = vec4(-1., 1., 0., 1.); - out.uni = vec2(0., 0.); - out.map = vec2(0., 0.); - } - default {} - } - return out; -} - -@group(1) @binding(0) -var tmap: texture_2d; -@group(1) @binding(1) -var smap: sampler; - -@fragment -fn fsmain(in: VertexOutput) -> @location(0) vec4 { - var col: vec4; - col = textureSample(tmap, smap, in.map); - - return col; -} diff --git a/shaders/post1.wgsl b/shaders/post1.wgsl deleted file mode 100644 index a075837..0000000 --- a/shaders/post1.wgsl +++ /dev/null @@ -1,57 +0,0 @@ -struct Data { - size: vec2, - step: vec2, - factor: vec2, - pad: vec2, -} - -@group(0) @binding(0) -var data: Data; - -struct VertexOutput { - @builtin(position) pos: vec4, - @location(0) uni: vec2, - @location(1) map: vec2, -} - -@vertex -fn vsmain(@builtin(vertex_index) in_vertex_index: u32) -> VertexOutput { - var out: VertexOutput; - switch in_vertex_index { - case 0u { - out.pos = vec4(1., -1., 0., 1.); - out.uni = vec2(1., 1.); - out.map = data.factor.xy; - } - case 1u { - out.pos = vec4(1., 1., 0., 1.); - out.uni = vec2(1., 0.); - out.map = vec2(data.factor.x, 0.); - } - case 2u { - out.pos = vec4(-1., -1., 0., 1.); - out.uni = vec2(0., 1.); - out.map = vec2(0., data.factor.y); - } - case 3u { - out.pos = vec4(-1., 1., 0., 1.); - out.uni = vec2(0., 0.); - out.map = vec2(0., 0.); - } - default {} - } - return out; -} - -@group(1) @binding(0) -var tmap: texture_2d; -@group(1) @binding(1) -var smap: sampler; - -@fragment -fn fsmain(in: VertexOutput) -> @location(0) vec4 { - var col: vec4; - col = textureSample(tmap, smap, in.map); - - return col; -} diff --git a/shaders/post2.wgsl b/shaders/post2.wgsl deleted file mode 100644 index 7ff0758..0000000 --- a/shaders/post2.wgsl +++ /dev/null @@ -1,61 +0,0 @@ -struct Data { - size: vec2, - step: vec2, - factor: vec2, - pad: vec2, -} - -@group(0) @binding(0) -var data: Data; - -struct VertexOutput { - @builtin(position) pos: vec4, - @location(0) uni: vec2, - @location(1) map: vec2, -} - -@vertex -fn vsmain(@builtin(vertex_index) in_vertex_index: u32) -> VertexOutput { - var out: VertexOutput; - switch in_vertex_index { - case 0u { - out.pos = vec4(1., -1., 0., 1.); - out.uni = vec2(1., 1.); - out.map = data.factor.xy; - } - case 1u { - out.pos = vec4(1., 1., 0., 1.); - out.uni = vec2(1., 0.); - out.map = vec2(data.factor.x, 0.); - } - case 2u { - out.pos = vec4(-1., -1., 0., 1.); - out.uni = vec2(0., 1.); - out.map = vec2(0., data.factor.y); - } - case 3u { - out.pos = vec4(-1., 1., 0., 1.); - out.uni = vec2(0., 0.); - out.map = vec2(0., 0.); - } - default {} - } - return out; -} - -@group(1) @binding(0) -var tmap: texture_2d; -@group(1) @binding(1) -var smap: sampler; - -@fragment -fn fsmain(in: VertexOutput) -> @location(0) vec4 { - var col: vec4; - col = textureSample(tmap, smap, in.map); - - let vcol = vec4(0.0, 0.0, 0.0, 1.); - let vforce = length(in.uni * 2. - 1.) * 0.3; - col = mix(col, vcol, vforce); - - return col; -} diff --git a/shaders/sh0.wgsl b/shaders/sh0.wgsl deleted file mode 100644 index 132cfe6..0000000 --- a/shaders/sh0.wgsl +++ /dev/null @@ -1,99 +0,0 @@ -struct InstanceInput { - @location(0) r0: vec4, - @location(1) r1: vec4, - @location(2) r2: vec4, - @location(3) r3: vec4, -} - -struct VertexInput { - @location(4) pos: vec3, - @location(5) map: vec2, -} - -struct VertexOutput { - @builtin(position) pos: vec4, - @location(0) map: vec2, - @location(1) world: vec3, - @location(2) space_0: vec3, -} - -struct Camera { - view: mat4x4, -} - -struct Source { - col: vec3, - rad: f32, - pos: vec3, -} - -struct Len { - n: u32, - pad0: u32, - pad1: u32, - pad2: u32, -} - -struct Space { - model: mat4x4, - col: vec3, -} - - -@group(0) @binding(0) var camera: Camera; -@group(0) @binding(1) var ambient: vec4; -@group(1) @binding(0) var tmap_0: texture_2d; -@group(1) @binding(1) var smap: sampler; -@group(2) @binding(0) var sources_array_0: array; -@group(2) @binding(1) var sources_len_0: Len; -@group(3) @binding(0) var spaces: array; -@group(3) @binding(1) var tspace_0: texture_3d; -@group(3) @binding(2) var sspace: sampler; - - -@vertex -fn vsmain(inst: InstanceInput, input: VertexInput) -> VertexOutput { - let model = mat4x4( - inst.r0, - inst.r1, - inst.r2, - inst.r3, - ); - - var out: VertexOutput; - let world = model * vec4(input.pos, 1.); - out.pos = camera.view * world; - out.map = input.map; - out.world = world.xyz; - out.space_0 = (spaces[0].model * world).xzy; - - return out; -} - -@fragment -fn fsmain(out: VertexOutput) -> @location(0) vec4 { - var col: vec3; - let tex = textureSample(tmap_0, smap, out.map); - if tex.a < 0.9 { discard; } - - var sources = vec3(0.); - for (var i = 0u; i < sources_len_0.n; i++) { - let src = sources_array_0[i]; - if out.world.x > src.pos.x - src.rad && out.world.x < src.pos.x + src.rad && out.world.y > src.pos.y - src.rad && out.world.y < src.pos.y + src.rad && out.world.z > src.pos.z - src.rad && out.world.z < src.pos.z + src.rad { - let len = length(out.world - src.pos); - if len < src.rad { - let e = 1. - (len / src.rad); - sources += e * e * src.col; - } - } - } - - var space = vec3(0.); - var space_a = textureSampleLevel(tspace_0, sspace, out.space_0, 0.); - space = space_a.rgb * spaces[0].col; - - let light = ambient.rgb + sources + space; - col = light * tex.rgb; - - return vec4(col, 1.); -} diff --git a/shaders/sh1.wgsl b/shaders/sh1.wgsl deleted file mode 100644 index 8006812..0000000 --- a/shaders/sh1.wgsl +++ /dev/null @@ -1,52 +0,0 @@ -struct InstanceInput { - @location(0) r0: vec4, - @location(1) r1: vec4, - @location(2) r2: vec4, - @location(3) r3: vec4, -} - -struct InstanceColorInput { - @location(4) col: vec3, -} - -struct VertexInput { - @location(5) pos: vec3, -} - -struct VertexOutput { - @builtin(position) pos: vec4, - @location(0) instcol: vec3, -} - -struct Camera { - view: mat4x4, -} - - -@group(0) @binding(0) var camera: Camera; - - -@vertex -fn vsmain(inst: InstanceInput, instcol: InstanceColorInput, input: VertexInput) -> VertexOutput { - let model = mat4x4( - inst.r0, - inst.r1, - inst.r2, - inst.r3, - ); - - var out: VertexOutput; - let world = model * vec4(input.pos, 1.); - out.pos = camera.view * world; - out.instcol = instcol.col; - - return out; -} - -@fragment -fn fsmain(out: VertexOutput) -> @location(0) vec4 { - var col: vec3; - col = out.instcol; - - return vec4(col, 1.); -}