@null3d/three-compat 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +176 -0
- package/LICENSE-MIT +21 -0
- package/README.md +55 -2
- package/THIRD-PARTY-NOTICES.txt +38 -0
- package/lib/cineon.wgsl-curve-glsl-0-8037a6d76f7e58b8.js +24 -0
- package/lib/cineon.wgsl-curve-wgsl-0-aa981b4d4febd643.js +24 -0
- package/lib/cineon.wgsl.d.ts +6 -0
- package/lib/cineon.wgsl.js +32 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +9 -0
- package/lib/outline-blur.wgsl-effect-glsl-0-8bba256766a6abc5.js +24 -0
- package/lib/outline-blur.wgsl-effect-wgsl-0-eec3dd26791430a4.js +24 -0
- package/lib/outline-blur.wgsl.d.ts +12 -0
- package/lib/outline-blur.wgsl.js +32 -0
- package/lib/outline-composite.wgsl-effect-glsl-0-ec3ad62a51888ba2.js +24 -0
- package/lib/outline-composite.wgsl-effect-wgsl-0-299e4470a8cc82ed.js +24 -0
- package/lib/outline-composite.wgsl.d.ts +11 -0
- package/lib/outline-composite.wgsl.js +32 -0
- package/lib/outline-edge.wgsl-effect-glsl-0-3504093a25fda552.js +24 -0
- package/lib/outline-edge.wgsl-effect-wgsl-0-81e9ba5df0070101.js +24 -0
- package/lib/outline-edge.wgsl.d.ts +12 -0
- package/lib/outline-edge.wgsl.js +32 -0
- package/lib/outline.d.ts +62 -0
- package/lib/outline.js +153 -0
- package/lib/reinhard.wgsl-curve-glsl-0-5ed283fc6d5ae39f.js +24 -0
- package/lib/reinhard.wgsl-curve-wgsl-0-5a897a3e6bdd8e93.js +24 -0
- package/lib/reinhard.wgsl.d.ts +6 -0
- package/lib/reinhard.wgsl.js +32 -0
- package/lib/tone.d.ts +16 -0
- package/lib/tone.js +17 -0
- package/lib/version.d.ts +1 -0
- package/lib/version.js +3 -0
- package/package.json +54 -5
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default __null3dShader("[{\"webgpu\":{\"permutation\":0,\"wgsl\":{\"source\":0,\"pipelines\":{\"main\":{\"vertex\":\"effect_vs\",\"fragment\":\"effect_fs\"}}},\"glsl\":null}}]");
|
|
2
|
+
|
|
3
|
+
function __null3dShader(text, hot, load, index, kind) {
|
|
4
|
+
const paths = __null3dShader.paths || (__null3dShader.paths = ["{\"blocks\":[\"struct EffectBlock {\\n size: vec4<f32>,\\n clock: vec4<f32>,\\n inverse_projection: mat4x4<f32>,\\n u0_: vec4<f32>,\\n u1_: vec4<f32>,\\n u2_: vec4<f32>,\\n u3_: vec4<f32>,\\n u4_: vec4<f32>,\\n u5_: vec4<f32>,\\n u6_: vec4<f32>,\\n u7_: vec4<f32>,\\n drawn: vec4<f32>,\\n bloom: vec4<f32>,\\n}\\n\",\"\\nstruct EffectInput {\\n color: vec4<f32>,\\n uv: vec2<f32>,\\n pixel: vec2<f32>,\\n size: vec2<f32>,\\n time: f32,\\n layer: u32,\\n}\\n\",\"\\nstruct Uniforms {\\n direction: vec2<f32>,\\n kernelRadius: f32,\\n}\\n\",\"\\n@group(0) @binding(0)\",\"\\nvar<uniform> effect_block: EffectBlock;\",\"\\n@group(0) @binding(1)\",\"\\nvar effect_source: texture_2d<f32>;\",\"\\n@group(0) @binding(2)\",\"\\nvar effect_sampler: sampler;\",\"\\nvar<private> uniforms: Uniforms;\",\"\\nvar<private> custom_texture_layers: array<i32, 1>;\",\"\\n@group(1) @binding(0)\",\"\\nvar source: texture_2d_array<f32>;\",\"\\n@group(1) @binding(8)\",\"\\nvar sourceSampler: sampler;\\n\",\"\\nfn triangle(vertex_1: u32) -> vec4<f32> {\\n let x_1 = ((f32(((vertex_1 << 1u) & 2u)) * 2f) - 1f);\\n let y = ((f32((vertex_1 & 2u)) * 2f) - 1f);\\n return vec4<f32>(x_1, y, 0.5f, 1f);\\n}\\n\",\"\\nfn effect_value(part: u32) -> vec4<f32> {\\n switch part {\\n case 0u: {\\n let _e3 = effect_block.u0_;\\n return _e3;\\n }\\n case 1u: {\\n let _e6 = effect_block.u1_;\\n return _e6;\\n }\\n case 2u: {\\n let _e9 = effect_block.u2_;\\n return _e9;\\n }\\n case 3u: {\\n let _e12 = effect_block.u3_;\\n return _e12;\\n }\\n case 4u: {\\n let _e15 = effect_block.u4_;\\n return _e15;\\n }\\n case 5u: {\\n let _e18 = effect_block.u5_;\\n return _e18;\\n }\\n case 6u: {\\n let _e21 = effect_block.u6_;\\n return _e21;\\n }\\n default: {\\n let _e24 = effect_block.u7_;\\n return _e24;\\n }\\n }\\n}\\n\",\"\\nfn effectPassUv(uv: vec2<f32>) -> vec2<f32> {\\n return vec2<f32>(uv.x, (1f - uv.y));\\n}\\n\",\"\\nfn effectColor(uv_1: vec2<f32>) -> vec4<f32> {\\n var at: vec2<f32>;\\n\\n let _e2 = effect_block.size;\\n let render = _e2.xy;\\n at = clamp((uv_1 * render), vec2(0.5f), (render - vec2(0.5f)));\\n let _e13 = at;\\n let _e16 = effect_block.size;\\n let _e22 = textureSampleLevel(effect_source, effect_sampler, (_e13 / _e16.zw), 0f);\\n return _e22;\\n}\\n\",\"\\nfn load_effect_uniforms() -> Uniforms {\\n var u: Uniforms;\\n\\n let _e1 = effect_value(0u);\\n u.direction = _e1.xy;\\n u.kernelRadius = _e1.z;\\n let _e7 = u;\\n return _e7;\\n}\\n\",\"\\nfn load_custom_texture_layers() {\\n let _e1 = effect_value(7u);\\n custom_texture_layers[0] = i32(_e1.w);\\n return;\\n}\\n\",\"\\nfn gaussian(x: f32, sigma: f32) -> f32 {\\n return ((0.39894f * exp((((-0.5f * x) * x) / (sigma * sigma)))) / sigma);\\n}\\n\",\"\\nfn effect(input_1: EffectInput) -> vec4<f32> {\\n var weightSum: f32;\\n var sum: vec3<f32>;\\n var offset: vec2<f32>;\\n var i: i32 = 1i;\\n\\n let _e5 = effectPassUv(input_1.uv);\\n let _e8 = custom_texture_layers[0];\\n let _e12 = textureSampleLevel(source, sourceSampler, _e5, _e8, 0f);\\n let _e15 = custom_texture_layers[0];\\n let center = select(vec4(1f), _e12, (_e15 >= 0i));\\n let _e21 = uniforms.kernelRadius;\\n let sigma_1 = (_e21 / 2f);\\n let _e25 = gaussian(0f, sigma_1);\\n weightSum = _e25;\\n let _e28 = weightSum;\\n sum = (center.xyz * _e28);\\n let _e33 = uniforms.direction;\\n let _e38 = uniforms.kernelRadius;\\n let delta = ((_e33 / input_1.size) * (_e38 / 4f));\\n offset = delta;\\n loop {\\n let _e44 = i;\\n if (_e44 <= 4i) {\\n } else {\\n break;\\n }\\n {\\n let _e49 = uniforms.kernelRadius;\\n let _e50 = i;\\n let x_2 = ((_e49 * f32(_e50)) / 4f);\\n let _e55 = gaussian(x_2, sigma_1);\\n let _e59 = offset;\\n let _e61 = effectPassUv((input_1.uv + _e59));\\n let _e64 = custom_texture_layers[0];\\n let _e68 = textureSampleLevel(source, sourceSampler, _e61, _e64, 0f);\\n let _e71 = custom_texture_layers[0];\\n let plus = select(vec4(1f), _e68, (_e71 >= 0i));\\n let _e78 = offset;\\n let _e80 = effectPassUv((input_1.uv - _e78));\\n let _e83 = custom_texture_layers[0];\\n let _e87 = textureSampleLevel(source, sourceSampler, _e80, _e83, 0f);\\n let _e90 = custom_texture_layers[0];\\n let minus = select(vec4(1f), _e87, (_e90 >= 0i));\\n let _e94 = sum;\\n sum = (_e94 + ((plus.xyz + minus.xyz) * _e55));\\n let _e100 = weightSum;\\n weightSum = (_e100 + (2f * _e55));\\n let _e104 = offset;\\n offset = (_e104 + delta);\\n }\\n continuing {\\n let _e107 = i;\\n i = (_e107 + 1i);\\n }\\n }\\n let _e109 = sum;\\n let _e110 = weightSum;\\n return vec4<f32>((_e109 / vec3(_e110)), center.w);\\n}\\n\",\"\\n@vertex\",\"\\nfn effect_vs(@builtin(vertex_index) vertex: u32) -> @builtin(position) vec4<f32> {\\n let _e1 = triangle(vertex);\\n return _e1;\\n}\\n\",\"\\n@fragment\",\"\\nfn effect_fs(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {\\n var input: EffectInput;\\n\\n let _e0 = load_effect_uniforms();\\n uniforms = _e0;\\n load_custom_texture_layers();\\n let _e7 = effect_block.clock.x;\\n input.time = _e7;\\n input.layer = 0u;\\n let drawn = effect_block.drawn;\\n if (drawn.w > 0.5f) {\\n let from_top = vec2<f32>(position.x, (drawn.z - position.y));\\n input.size = drawn.xy;\\n input.pixel = from_top;\\n input.uv = (from_top / drawn.xy);\\n let _e30 = input.uv;\\n let _e31 = effectColor(_e30);\\n input.color = _e31;\\n input.layer = (u32(drawn.w) - 1u);\\n let _e37 = input;\\n let _e38 = effect(_e37);\\n return _e38;\\n }\\n let from_top_1 = position.xy;\\n let _e45 = textureLoad(effect_source, vec2<i32>(position.xy), 0i);\\n input.color = _e45;\\n let _e49 = effect_block.size;\\n input.size = _e49.xy;\\n input.pixel = from_top_1;\\n let _e55 = effect_block.size;\\n input.uv = (from_top_1 / _e55.xy);\\n let _e58 = input;\\n let _e59 = effect(_e58);\\n return _e59;\\n}\\n\"],\"lists\":[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]]}", "{\"blocks\":[],\"lists\":[]}"].map((json) => ({ json })));
|
|
5
|
+
const sourceOf = (n) => {
|
|
6
|
+
const path = paths[n < 0 ? 1 : 0];
|
|
7
|
+
const tables = path.tables || (path.tables = JSON.parse(path.json));
|
|
8
|
+
return tables.lists[n < 0 ? -1 - n : n].map((block) => tables.blocks[block]).join('');
|
|
9
|
+
};
|
|
10
|
+
const walk = (item) => {
|
|
11
|
+
for (const key in item) {
|
|
12
|
+
const field = item[key];
|
|
13
|
+
if (key === "source" && typeof field === 'number')
|
|
14
|
+
Object.defineProperty(item, key, { get: () => sourceOf(field), enumerable: true });
|
|
15
|
+
else if (field !== null && typeof field === 'object') walk(field);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const shader = JSON.parse(text);
|
|
19
|
+
walk(shader);
|
|
20
|
+
if (hot !== undefined) shader.hot = hot;
|
|
21
|
+
if (load !== undefined)
|
|
22
|
+
shader.builds = (target, set) => load(kind, target, set).then((module) => module.default[index] || {});
|
|
23
|
+
return shader;
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// The types of outline-blur.wgsl, which the null3D Vite plugin writes when it compiles the file.
|
|
2
|
+
// Edit the WGSL, not this file.
|
|
3
|
+
import type { CompiledEffect } from '@null3d/vite-plugin';
|
|
4
|
+
|
|
5
|
+
declare const shader: CompiledEffect<
|
|
6
|
+
{
|
|
7
|
+
readonly direction: 'vec2f';
|
|
8
|
+
readonly kernelRadius: 'f32';
|
|
9
|
+
},
|
|
10
|
+
'source'
|
|
11
|
+
>;
|
|
12
|
+
export default shader;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default __null3dShader("{\"kind\":\"effect\",\"uniforms\":[{\"name\":\"direction\",\"type\":\"vec2f\",\"offset\":0},{\"name\":\"kernelRadius\",\"type\":\"f32\",\"offset\":2}],\"depth\":false,\"bloom\":false,\"joins\":false,\"textures\":[{\"name\":\"source\",\"offset\":31,\"array\":false}],\"variants\":{},\"pieces\":{\"group\":{},\"fold\":{}},\"permutations\":0}", undefined, __null3dBuilds, 0, "effect");
|
|
2
|
+
|
|
3
|
+
function __null3dShader(text, hot, load, index, kind) {
|
|
4
|
+
const paths = __null3dShader.paths || (__null3dShader.paths = ["{\"blocks\":[],\"lists\":[]}", "{\"blocks\":[],\"lists\":[]}"].map((json) => ({ json })));
|
|
5
|
+
const sourceOf = (n) => {
|
|
6
|
+
const path = paths[n < 0 ? 1 : 0];
|
|
7
|
+
const tables = path.tables || (path.tables = JSON.parse(path.json));
|
|
8
|
+
return tables.lists[n < 0 ? -1 - n : n].map((block) => tables.blocks[block]).join('');
|
|
9
|
+
};
|
|
10
|
+
const walk = (item) => {
|
|
11
|
+
for (const key in item) {
|
|
12
|
+
const field = item[key];
|
|
13
|
+
if (key === "source" && typeof field === 'number')
|
|
14
|
+
Object.defineProperty(item, key, { get: () => sourceOf(field), enumerable: true });
|
|
15
|
+
else if (field !== null && typeof field === 'object') walk(field);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const shader = JSON.parse(text);
|
|
19
|
+
walk(shader);
|
|
20
|
+
if (hot !== undefined) shader.hot = hot;
|
|
21
|
+
if (load !== undefined)
|
|
22
|
+
shader.builds = (target, set) => load(kind, target, set).then((module) => module.default[index] || {});
|
|
23
|
+
return shader;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function __null3dBuilds(kind, target, set) {
|
|
27
|
+
const load = {
|
|
28
|
+
"effect wgsl 0": () => import("./outline-blur.wgsl-effect-wgsl-0-eec3dd26791430a4.js"),
|
|
29
|
+
"effect glsl 0": () => import("./outline-blur.wgsl-effect-glsl-0-8bba256766a6abc5.js"),
|
|
30
|
+
}[kind + ' ' + target + ' ' + set];
|
|
31
|
+
return load ? load() : Promise.resolve({ default: [] });
|
|
32
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default __null3dShader("[{\"webgl2\":{\"permutation\":0,\"wgsl\":null,\"glsl\":{\"main\":{\"vertex\":{\"source\":-1,\"uniformBlocks\":[],\"textures\":[]},\"fragment\":{\"source\":-2,\"uniformBlocks\":[{\"name\":\"EffectBlock_block_0Fragment\",\"group\":0,\"binding\":0}],\"textures\":[{\"name\":\"_group_0_binding_1_fs\",\"group\":0,\"binding\":1,\"sampler\":{\"group\":0,\"binding\":2}},{\"name\":\"_group_1_binding_0_fs\",\"group\":1,\"binding\":0,\"sampler\":{\"group\":1,\"binding\":8}},{\"name\":\"_group_1_binding_1_fs\",\"group\":1,\"binding\":1,\"sampler\":{\"group\":1,\"binding\":9}}]}}}}}]");
|
|
2
|
+
|
|
3
|
+
function __null3dShader(text, hot, load, index, kind) {
|
|
4
|
+
const paths = __null3dShader.paths || (__null3dShader.paths = ["{\"blocks\":[],\"lists\":[]}", "{\"blocks\":[\"#version 300 es\",\"\\nuniform vec2 null3d_depth_mapping;\\n\",\"\\nprecision highp float;\",\"\\nprecision highp int;\\n\\n\",\"\\nvec4 triangle(highp uint vertex_1) {\\n float x = ((float(((vertex_1 << 1u) & 2u)) * 2.0) - 1.0);\\n float y = ((float((vertex_1 & 2u)) * 2.0) - 1.0);\\n return vec4(x, y, 0.5, 1.0);\\n}\\n\",\"\\nvoid main() {\\n highp uint vertex = uint(gl_VertexID);\\n vec4 _e1 = triangle(vertex);\\n gl_Position = _e1;\\n gl_Position.z = gl_Position.z * null3d_depth_mapping.x + gl_Position.w * null3d_depth_mapping.y;\\n return;\\n}\\n\",\"#version 300 es\\n\",\"\\nprecision highp int;\\n\",\"\\nstruct EffectBlock {\\n vec4 size;\\n vec4 clock;\\n mat4x4 inverse_projection;\\n vec4 u0_;\\n vec4 u1_;\\n vec4 u2_;\\n vec4 u3_;\\n vec4 u4_;\\n vec4 u5_;\\n vec4 u6_;\\n vec4 u7_;\\n vec4 drawn;\\n vec4 bloom;\\n};\",\"\\nstruct EffectInput {\\n vec4 color;\\n vec2 uv;\\n vec2 pixel;\\n vec2 size;\\n float time;\\n highp uint layer;\\n};\",\"\\nstruct Uniforms {\\n vec4 settings;\\n};\",\"\\nlayout(std140) uniform EffectBlock_block_0Fragment { EffectBlock _group_0_binding_0_fs; };\\n\",\"\\nuniform highp sampler2D _group_0_binding_1_fs;\\n\",\"\\nhighp int custom_texture_layers[2] = int[2](0, 0);\\n\",\"\\nuniform highp sampler2DArray _group_1_binding_0_fs;\\n\",\"\\nuniform highp sampler2DArray _group_1_binding_1_fs;\\n\",\"\\nvec4 uniforms_0_ = vec4(0.0);\\n\",\"\\nlayout(location = 0) out vec4 _fs2p_location0;\\n\",\"\\nvec4 effect_value(highp uint part) {\\n switch(part) {\\n case 0u: {\\n vec4 _e15 = _group_0_binding_0_fs.u0_;\\n return _e15;\\n }\\n case 1u: {\\n vec4 _e30 = _group_0_binding_0_fs.u1_;\\n return _e30;\\n }\\n case 2u: {\\n vec4 _e45 = _group_0_binding_0_fs.u2_;\\n return _e45;\\n }\\n case 3u: {\\n vec4 _e60 = _group_0_binding_0_fs.u3_;\\n return _e60;\\n }\\n case 4u: {\\n vec4 _e75 = _group_0_binding_0_fs.u4_;\\n return _e75;\\n }\\n case 5u: {\\n vec4 _e90 = _group_0_binding_0_fs.u5_;\\n return _e90;\\n }\\n case 6u: {\\n vec4 _e105 = _group_0_binding_0_fs.u6_;\\n return _e105;\\n }\\n default: {\\n vec4 _e120 = _group_0_binding_0_fs.u7_;\\n return _e120;\\n }\\n }\\n}\\n\",\"\\nvec2 effectPassUv(vec2 uv) {\\n return vec2(uv.x, (1.0 - uv.y));\\n}\\n\",\"\\nvec4 effectColor(vec2 uv_1) {\\n vec2 at = vec2(0.0);\\n vec4 _e14 = _group_0_binding_0_fs.size;\\n vec2 render = _e14.xy;\\n at = clamp((uv_1 * render), vec2(0.5), (render - vec2(0.5)));\\n float _e41 = _group_0_binding_0_fs.size.w;\\n float _e43 = at.y;\\n at.y = (_e41 - _e43);\\n vec2 _e45 = at;\\n vec4 _e60 = _group_0_binding_0_fs.size;\\n vec4 _e66 = textureLod(_group_0_binding_1_fs, vec2((_e45 / _e60.zw)), 0.0);\\n return _e66;\\n}\\n\",\"\\nvoid load_effect_uniforms(inout vec4 param) {\\n vec4 local_7 = vec4(0.0);\\n vec4 _e1 = effect_value(0u);\\n local_7 = _e1.xyzw;\\n vec4 _e5 = local_7;\\n param = _e5;\\n return;\\n}\\n\",\"\\nvoid load_custom_texture_layers() {\\n vec4 _e1 = effect_value(7u);\\n custom_texture_layers[0] = int(_e1.w);\\n custom_texture_layers[1] = int(_e1.z);\\n return;\\n}\\n\",\"\\nvec4 effect(vec4 param_1, vec2 param_2, vec2 param_3, vec2 param_4, float param_5, highp uint param_6) {\\n float pulse = 1.0;\\n vec2 _e8 = effectPassUv(param_2);\\n highp int _e11 = custom_texture_layers[0];\\n vec4 _e15 = textureLod(_group_1_binding_0_fs, vec3(_e8, _e11), 0.0);\\n highp int _e18 = custom_texture_layers[0];\\n vec4 edge = ((_e18 >= 0) ? _e15 : vec4(1.0));\\n vec2 _e24 = effectPassUv(param_2);\\n highp int _e27 = custom_texture_layers[1];\\n vec4 _e31 = textureLod(_group_1_binding_1_fs, vec3(_e24, _e27), 0.0);\\n highp int _e34 = custom_texture_layers[1];\\n vec4 glow = ((_e34 >= 0) ? _e31 : vec4(1.0));\\n float _e40 = uniforms_0_.z;\\n if ((_e40 > 0.0)) {\\n float _e47 = uniforms_0_.z;\\n pulse = (0.625 + (0.375 * cos(((param_5 * 10.0) / _e47))));\\n }\\n float _e59 = uniforms_0_.y;\\n float _e64 = uniforms_0_.x;\\n float _e65 = pulse;\\n vec3 light = ((edge.xyz + (glow.xyz * _e59)) * ((_e64 * _e65) * edge.w));\\n return vec4((param_1.xyz + light), param_1.w);\\n}\\n\",\"\\nvoid main() {\\n vec4 position = gl_FragCoord;\\n vec4 local = vec4(0.0);\\n vec4 local_1 = vec4(0.0);\\n vec2 local_2 = vec2(0.0);\\n vec2 local_3 = vec2(0.0);\\n vec2 local_4 = vec2(0.0);\\n float local_5 = 0.0;\\n highp uint local_6 = 0u;\\n load_effect_uniforms(local);\\n vec4 _e2 = local;\\n uniforms_0_ = _e2;\\n load_custom_texture_layers();\\n float _e25 = _group_0_binding_0_fs.clock.x;\\n local_5 = _e25;\\n local_6 = 0u;\\n vec4 drawn = _group_0_binding_0_fs.drawn;\\n if ((drawn.w > 0.5)) {\\n vec2 from_top = vec2(position.x, (drawn.z - position.y));\\n local_4 = drawn.xy;\\n local_3 = from_top;\\n local_2 = (from_top / drawn.xy);\\n vec2 _e54 = local_2;\\n vec4 _e55 = effectColor(_e54);\\n local_1 = _e55;\\n local_6 = (uint(drawn.w) - 1u);\\n vec4 _e73 = local_1;\\n vec2 _e75 = local_2;\\n vec2 _e77 = local_3;\\n vec2 _e79 = local_4;\\n float _e81 = local_5;\\n highp uint _e83 = local_6;\\n vec4 _e84 = effect(_e73, _e75, _e77, _e79, _e81, _e83);\\n _fs2p_location0 = _e84;\\n return;\\n }\\n float _e101 = _group_0_binding_0_fs.size.w;\\n vec2 from_top_1 = vec2(position.x, (_e101 - position.y));\\n vec4 _e109 = texelFetch(_group_0_binding_1_fs, ivec2(position.xy), 0);\\n local_1 = _e109;\\n vec4 _e124 = _group_0_binding_0_fs.size;\\n local_4 = _e124.xy;\\n local_3 = from_top_1;\\n vec4 _e140 = _group_0_binding_0_fs.size;\\n local_2 = (from_top_1 / _e140.xy);\\n vec4 _e156 = local_1;\\n vec2 _e158 = local_2;\\n vec2 _e160 = local_3;\\n vec2 _e162 = local_4;\\n float _e164 = local_5;\\n highp uint _e166 = local_6;\\n vec4 _e167 = effect(_e156, _e158, _e160, _e162, _e164, _e166);\\n _fs2p_location0 = _e167;\\n return;\\n}\\n\"],\"lists\":[[0,1,2,3,4,5],[6,2,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]]}"].map((json) => ({ json })));
|
|
5
|
+
const sourceOf = (n) => {
|
|
6
|
+
const path = paths[n < 0 ? 1 : 0];
|
|
7
|
+
const tables = path.tables || (path.tables = JSON.parse(path.json));
|
|
8
|
+
return tables.lists[n < 0 ? -1 - n : n].map((block) => tables.blocks[block]).join('');
|
|
9
|
+
};
|
|
10
|
+
const walk = (item) => {
|
|
11
|
+
for (const key in item) {
|
|
12
|
+
const field = item[key];
|
|
13
|
+
if (key === "source" && typeof field === 'number')
|
|
14
|
+
Object.defineProperty(item, key, { get: () => sourceOf(field), enumerable: true });
|
|
15
|
+
else if (field !== null && typeof field === 'object') walk(field);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const shader = JSON.parse(text);
|
|
19
|
+
walk(shader);
|
|
20
|
+
if (hot !== undefined) shader.hot = hot;
|
|
21
|
+
if (load !== undefined)
|
|
22
|
+
shader.builds = (target, set) => load(kind, target, set).then((module) => module.default[index] || {});
|
|
23
|
+
return shader;
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default __null3dShader("[{\"webgpu\":{\"permutation\":0,\"wgsl\":{\"source\":0,\"pipelines\":{\"main\":{\"vertex\":\"effect_vs\",\"fragment\":\"effect_fs\"}}},\"glsl\":null}}]");
|
|
2
|
+
|
|
3
|
+
function __null3dShader(text, hot, load, index, kind) {
|
|
4
|
+
const paths = __null3dShader.paths || (__null3dShader.paths = ["{\"blocks\":[\"struct EffectBlock {\\n size: vec4<f32>,\\n clock: vec4<f32>,\\n inverse_projection: mat4x4<f32>,\\n u0_: vec4<f32>,\\n u1_: vec4<f32>,\\n u2_: vec4<f32>,\\n u3_: vec4<f32>,\\n u4_: vec4<f32>,\\n u5_: vec4<f32>,\\n u6_: vec4<f32>,\\n u7_: vec4<f32>,\\n drawn: vec4<f32>,\\n bloom: vec4<f32>,\\n}\\n\",\"\\nstruct EffectInput {\\n color: vec4<f32>,\\n uv: vec2<f32>,\\n pixel: vec2<f32>,\\n size: vec2<f32>,\\n time: f32,\\n layer: u32,\\n}\\n\",\"\\nstruct Uniforms {\\n settings: vec4<f32>,\\n}\\n\",\"\\n@group(0) @binding(0)\",\"\\nvar<uniform> effect_block: EffectBlock;\",\"\\n@group(0) @binding(1)\",\"\\nvar effect_source: texture_2d<f32>;\",\"\\n@group(0) @binding(2)\",\"\\nvar effect_sampler: sampler;\",\"\\nvar<private> uniforms: Uniforms;\",\"\\nvar<private> custom_texture_layers: array<i32, 2>;\",\"\\n@group(1) @binding(0)\",\"\\nvar edges: texture_2d_array<f32>;\",\"\\n@group(1) @binding(8)\",\"\\nvar edgesSampler: sampler;\",\"\\n@group(1) @binding(1)\",\"\\nvar halo: texture_2d_array<f32>;\",\"\\n@group(1) @binding(9)\",\"\\nvar haloSampler: sampler;\\n\",\"\\nfn triangle(vertex_1: u32) -> vec4<f32> {\\n let x = ((f32(((vertex_1 << 1u) & 2u)) * 2f) - 1f);\\n let y = ((f32((vertex_1 & 2u)) * 2f) - 1f);\\n return vec4<f32>(x, y, 0.5f, 1f);\\n}\\n\",\"\\nfn effect_value(part: u32) -> vec4<f32> {\\n switch part {\\n case 0u: {\\n let _e3 = effect_block.u0_;\\n return _e3;\\n }\\n case 1u: {\\n let _e6 = effect_block.u1_;\\n return _e6;\\n }\\n case 2u: {\\n let _e9 = effect_block.u2_;\\n return _e9;\\n }\\n case 3u: {\\n let _e12 = effect_block.u3_;\\n return _e12;\\n }\\n case 4u: {\\n let _e15 = effect_block.u4_;\\n return _e15;\\n }\\n case 5u: {\\n let _e18 = effect_block.u5_;\\n return _e18;\\n }\\n case 6u: {\\n let _e21 = effect_block.u6_;\\n return _e21;\\n }\\n default: {\\n let _e24 = effect_block.u7_;\\n return _e24;\\n }\\n }\\n}\\n\",\"\\nfn effectPassUv(uv: vec2<f32>) -> vec2<f32> {\\n return vec2<f32>(uv.x, (1f - uv.y));\\n}\\n\",\"\\nfn effectColor(uv_1: vec2<f32>) -> vec4<f32> {\\n var at: vec2<f32>;\\n\\n let _e2 = effect_block.size;\\n let render = _e2.xy;\\n at = clamp((uv_1 * render), vec2(0.5f), (render - vec2(0.5f)));\\n let _e13 = at;\\n let _e16 = effect_block.size;\\n let _e22 = textureSampleLevel(effect_source, effect_sampler, (_e13 / _e16.zw), 0f);\\n return _e22;\\n}\\n\",\"\\nfn load_effect_uniforms() -> Uniforms {\\n var u: Uniforms;\\n\\n let _e1 = effect_value(0u);\\n u.settings = _e1.xyzw;\\n let _e5 = u;\\n return _e5;\\n}\\n\",\"\\nfn load_custom_texture_layers() {\\n let _e1 = effect_value(7u);\\n custom_texture_layers[0] = i32(_e1.w);\\n custom_texture_layers[1] = i32(_e1.z);\\n return;\\n}\\n\",\"\\nfn effect(input_1: EffectInput) -> vec4<f32> {\\n var pulse: f32 = 1f;\\n\\n let _e5 = effectPassUv(input_1.uv);\\n let _e8 = custom_texture_layers[0];\\n let _e12 = textureSampleLevel(edges, edgesSampler, _e5, _e8, 0f);\\n let _e15 = custom_texture_layers[0];\\n let edge = select(vec4(1f), _e12, (_e15 >= 0i));\\n let _e22 = effectPassUv(input_1.uv);\\n let _e25 = custom_texture_layers[1];\\n let _e29 = textureSampleLevel(halo, haloSampler, _e22, _e25, 0f);\\n let _e32 = custom_texture_layers[1];\\n let glow = select(vec4(1f), _e29, (_e32 >= 0i));\\n let _e39 = uniforms.settings.z;\\n if (_e39 > 0f) {\\n let _e48 = uniforms.settings.z;\\n pulse = (0.625f + (0.375f * cos(((input_1.time * 10f) / _e48))));\\n }\\n let _e61 = uniforms.settings.y;\\n let _e67 = uniforms.settings.x;\\n let _e68 = pulse;\\n let light = ((edge.xyz + (glow.xyz * _e61)) * ((_e67 * _e68) * edge.w));\\n return vec4<f32>((input_1.color.xyz + light), input_1.color.w);\\n}\\n\",\"\\n@vertex\",\"\\nfn effect_vs(@builtin(vertex_index) vertex: u32) -> @builtin(position) vec4<f32> {\\n let _e1 = triangle(vertex);\\n return _e1;\\n}\\n\",\"\\n@fragment\",\"\\nfn effect_fs(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {\\n var input: EffectInput;\\n\\n let _e0 = load_effect_uniforms();\\n uniforms = _e0;\\n load_custom_texture_layers();\\n let _e7 = effect_block.clock.x;\\n input.time = _e7;\\n input.layer = 0u;\\n let drawn = effect_block.drawn;\\n if (drawn.w > 0.5f) {\\n let from_top = vec2<f32>(position.x, (drawn.z - position.y));\\n input.size = drawn.xy;\\n input.pixel = from_top;\\n input.uv = (from_top / drawn.xy);\\n let _e30 = input.uv;\\n let _e31 = effectColor(_e30);\\n input.color = _e31;\\n input.layer = (u32(drawn.w) - 1u);\\n let _e37 = input;\\n let _e38 = effect(_e37);\\n return _e38;\\n }\\n let from_top_1 = position.xy;\\n let _e45 = textureLoad(effect_source, vec2<i32>(position.xy), 0i);\\n input.color = _e45;\\n let _e49 = effect_block.size;\\n input.size = _e49.xy;\\n input.pixel = from_top_1;\\n let _e55 = effect_block.size;\\n input.uv = (from_top_1 / _e55.xy);\\n let _e58 = input;\\n let _e59 = effect(_e58);\\n return _e59;\\n}\\n\"],\"lists\":[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29]]}", "{\"blocks\":[],\"lists\":[]}"].map((json) => ({ json })));
|
|
5
|
+
const sourceOf = (n) => {
|
|
6
|
+
const path = paths[n < 0 ? 1 : 0];
|
|
7
|
+
const tables = path.tables || (path.tables = JSON.parse(path.json));
|
|
8
|
+
return tables.lists[n < 0 ? -1 - n : n].map((block) => tables.blocks[block]).join('');
|
|
9
|
+
};
|
|
10
|
+
const walk = (item) => {
|
|
11
|
+
for (const key in item) {
|
|
12
|
+
const field = item[key];
|
|
13
|
+
if (key === "source" && typeof field === 'number')
|
|
14
|
+
Object.defineProperty(item, key, { get: () => sourceOf(field), enumerable: true });
|
|
15
|
+
else if (field !== null && typeof field === 'object') walk(field);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const shader = JSON.parse(text);
|
|
19
|
+
walk(shader);
|
|
20
|
+
if (hot !== undefined) shader.hot = hot;
|
|
21
|
+
if (load !== undefined)
|
|
22
|
+
shader.builds = (target, set) => load(kind, target, set).then((module) => module.default[index] || {});
|
|
23
|
+
return shader;
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The types of outline-composite.wgsl, which the null3D Vite plugin writes when it compiles the file.
|
|
2
|
+
// Edit the WGSL, not this file.
|
|
3
|
+
import type { CompiledEffect } from '@null3d/vite-plugin';
|
|
4
|
+
|
|
5
|
+
declare const shader: CompiledEffect<
|
|
6
|
+
{
|
|
7
|
+
readonly settings: 'vec4f';
|
|
8
|
+
},
|
|
9
|
+
'edges' | 'halo'
|
|
10
|
+
>;
|
|
11
|
+
export default shader;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default __null3dShader("{\"kind\":\"effect\",\"uniforms\":[{\"name\":\"settings\",\"type\":\"vec4f\",\"offset\":0}],\"depth\":false,\"bloom\":false,\"joins\":false,\"textures\":[{\"name\":\"edges\",\"offset\":31,\"array\":false},{\"name\":\"halo\",\"offset\":30,\"array\":false}],\"variants\":{},\"pieces\":{\"group\":{},\"fold\":{}},\"permutations\":0}", undefined, __null3dBuilds, 0, "effect");
|
|
2
|
+
|
|
3
|
+
function __null3dShader(text, hot, load, index, kind) {
|
|
4
|
+
const paths = __null3dShader.paths || (__null3dShader.paths = ["{\"blocks\":[],\"lists\":[]}", "{\"blocks\":[],\"lists\":[]}"].map((json) => ({ json })));
|
|
5
|
+
const sourceOf = (n) => {
|
|
6
|
+
const path = paths[n < 0 ? 1 : 0];
|
|
7
|
+
const tables = path.tables || (path.tables = JSON.parse(path.json));
|
|
8
|
+
return tables.lists[n < 0 ? -1 - n : n].map((block) => tables.blocks[block]).join('');
|
|
9
|
+
};
|
|
10
|
+
const walk = (item) => {
|
|
11
|
+
for (const key in item) {
|
|
12
|
+
const field = item[key];
|
|
13
|
+
if (key === "source" && typeof field === 'number')
|
|
14
|
+
Object.defineProperty(item, key, { get: () => sourceOf(field), enumerable: true });
|
|
15
|
+
else if (field !== null && typeof field === 'object') walk(field);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const shader = JSON.parse(text);
|
|
19
|
+
walk(shader);
|
|
20
|
+
if (hot !== undefined) shader.hot = hot;
|
|
21
|
+
if (load !== undefined)
|
|
22
|
+
shader.builds = (target, set) => load(kind, target, set).then((module) => module.default[index] || {});
|
|
23
|
+
return shader;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function __null3dBuilds(kind, target, set) {
|
|
27
|
+
const load = {
|
|
28
|
+
"effect wgsl 0": () => import("./outline-composite.wgsl-effect-wgsl-0-299e4470a8cc82ed.js"),
|
|
29
|
+
"effect glsl 0": () => import("./outline-composite.wgsl-effect-glsl-0-ec3ad62a51888ba2.js"),
|
|
30
|
+
}[kind + ' ' + target + ' ' + set];
|
|
31
|
+
return load ? load() : Promise.resolve({ default: [] });
|
|
32
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default __null3dShader("[{\"webgl2\":{\"permutation\":0,\"wgsl\":null,\"glsl\":{\"main\":{\"vertex\":{\"source\":-1,\"uniformBlocks\":[],\"textures\":[]},\"fragment\":{\"source\":-2,\"uniformBlocks\":[{\"name\":\"EffectBlock_block_0Fragment\",\"group\":0,\"binding\":0}],\"textures\":[{\"name\":\"_group_0_binding_1_fs\",\"group\":0,\"binding\":1,\"sampler\":{\"group\":0,\"binding\":2}}]}}}}}]");
|
|
2
|
+
|
|
3
|
+
function __null3dShader(text, hot, load, index, kind) {
|
|
4
|
+
const paths = __null3dShader.paths || (__null3dShader.paths = ["{\"blocks\":[],\"lists\":[]}", "{\"blocks\":[\"#version 300 es\",\"\\nuniform vec2 null3d_depth_mapping;\\n\",\"\\nprecision highp float;\",\"\\nprecision highp int;\\n\\n\",\"\\nvec4 triangle(highp uint vertex_1) {\\n float x = ((float(((vertex_1 << 1u) & 2u)) * 2.0) - 1.0);\\n float y = ((float((vertex_1 & 2u)) * 2.0) - 1.0);\\n return vec4(x, y, 0.5, 1.0);\\n}\\n\",\"\\nvoid main() {\\n highp uint vertex = uint(gl_VertexID);\\n vec4 _e1 = triangle(vertex);\\n gl_Position = _e1;\\n gl_Position.z = gl_Position.z * null3d_depth_mapping.x + gl_Position.w * null3d_depth_mapping.y;\\n return;\\n}\\n\",\"#version 300 es\\n\",\"\\nprecision highp int;\\n\",\"\\nstruct EffectBlock {\\n vec4 size;\\n vec4 clock;\\n mat4x4 inverse_projection;\\n vec4 u0_;\\n vec4 u1_;\\n vec4 u2_;\\n vec4 u3_;\\n vec4 u4_;\\n vec4 u5_;\\n vec4 u6_;\\n vec4 u7_;\\n vec4 drawn;\\n vec4 bloom;\\n};\",\"\\nstruct EffectInput {\\n vec4 color;\\n vec2 uv;\\n vec2 pixel;\\n vec2 size;\\n float time;\\n highp uint layer;\\n};\",\"\\nstruct Uniforms {\\n vec3 visibleColor;\\n vec3 hiddenColor;\\n};\",\"\\nlayout(std140) uniform EffectBlock_block_0Fragment { EffectBlock _group_0_binding_0_fs; };\\n\",\"\\nuniform highp sampler2D _group_0_binding_1_fs;\\n\",\"\\nvec3 uniforms_0_ = vec3(0.0);\\n\",\"\\nvec3 uniforms_1_ = vec3(0.0);\\n\",\"\\nlayout(location = 0) out vec4 _fs2p_location0;\\n\",\"\\nvec4 effect_value(highp uint part) {\\n switch(part) {\\n case 0u: {\\n vec4 _e15 = _group_0_binding_0_fs.u0_;\\n return _e15;\\n }\\n case 1u: {\\n vec4 _e30 = _group_0_binding_0_fs.u1_;\\n return _e30;\\n }\\n case 2u: {\\n vec4 _e45 = _group_0_binding_0_fs.u2_;\\n return _e45;\\n }\\n case 3u: {\\n vec4 _e60 = _group_0_binding_0_fs.u3_;\\n return _e60;\\n }\\n case 4u: {\\n vec4 _e75 = _group_0_binding_0_fs.u4_;\\n return _e75;\\n }\\n case 5u: {\\n vec4 _e90 = _group_0_binding_0_fs.u5_;\\n return _e90;\\n }\\n case 6u: {\\n vec4 _e105 = _group_0_binding_0_fs.u6_;\\n return _e105;\\n }\\n default: {\\n vec4 _e120 = _group_0_binding_0_fs.u7_;\\n return _e120;\\n }\\n }\\n}\\n\",\"\\nvec4 effectColor(vec2 uv) {\\n vec2 at = vec2(0.0);\\n vec4 _e14 = _group_0_binding_0_fs.size;\\n vec2 render = _e14.xy;\\n at = clamp((uv * render), vec2(0.5), (render - vec2(0.5)));\\n float _e41 = _group_0_binding_0_fs.size.w;\\n float _e43 = at.y;\\n at.y = (_e41 - _e43);\\n vec2 _e45 = at;\\n vec4 _e60 = _group_0_binding_0_fs.size;\\n vec4 _e66 = textureLod(_group_0_binding_1_fs, vec2((_e45 / _e60.zw)), 0.0);\\n return _e66;\\n}\\n\",\"\\nvoid load_effect_uniforms(inout vec3 param, inout vec3 param_1) {\\n vec3 local_8 = vec3(0.0);\\n vec3 local_9 = vec3(0.0);\\n vec4 _e1 = effect_value(0u);\\n local_8 = _e1.xyz;\\n vec4 _e6 = effect_value(1u);\\n local_9 = _e6.xyz;\\n vec3 _e9 = local_8;\\n vec3 _e11 = local_9;\\n param = _e9;\\n param_1 = _e11;\\n return;\\n}\\n\",\"\\nvec4 effect(vec4 param_2, vec2 param_3, vec2 param_4, vec2 param_5, float param_6, highp uint param_7) {\\n vec2 texel = (vec2(1.0) / param_5);\\n vec4 _e9 = effectColor(param_3);\\n vec4 _e14 = effectColor((param_3 - vec2(texel.x, 0.0)));\\n vec4 _e19 = effectColor((param_3 + vec2(texel.x, 0.0)));\\n vec4 _e24 = effectColor((param_3 - vec2(0.0, texel.y)));\\n vec4 _e29 = effectColor((param_3 + vec2(0.0, texel.y)));\\n vec2 d = vec2(((_e19.x - _e14.x) * 0.5), ((_e29.x - _e24.x) * 0.5));\\n float visibility = min(min(_e14.y, _e19.y), min(_e24.y, _e29.y));\\n vec3 _e50 = uniforms_1_;\\n vec3 _e53 = uniforms_0_;\\n vec3 shown = (((1.0 - visibility) > 0.001) ? _e53 : _e50);\\n return vec4((shown * length(d)), (1.0 - _e9.x));\\n}\\n\",\"\\nvoid main() {\\n vec4 position = gl_FragCoord;\\n vec3 local = vec3(0.0);\\n vec3 local_1 = vec3(0.0);\\n vec4 local_2 = vec4(0.0);\\n vec2 local_3 = vec2(0.0);\\n vec2 local_4 = vec2(0.0);\\n vec2 local_5 = vec2(0.0);\\n float local_6 = 0.0;\\n highp uint local_7 = 0u;\\n load_effect_uniforms(local, local_1);\\n vec3 _e3 = local;\\n vec3 _e5 = local_1;\\n uniforms_0_ = _e3;\\n uniforms_1_ = _e5;\\n float _e29 = _group_0_binding_0_fs.clock.x;\\n local_6 = _e29;\\n local_7 = 0u;\\n vec4 drawn = _group_0_binding_0_fs.drawn;\\n if ((drawn.w > 0.5)) {\\n vec2 from_top = vec2(position.x, (drawn.z - position.y));\\n local_5 = drawn.xy;\\n local_4 = from_top;\\n local_3 = (from_top / drawn.xy);\\n vec2 _e58 = local_3;\\n vec4 _e59 = effectColor(_e58);\\n local_2 = _e59;\\n local_7 = (uint(drawn.w) - 1u);\\n vec4 _e77 = local_2;\\n vec2 _e79 = local_3;\\n vec2 _e81 = local_4;\\n vec2 _e83 = local_5;\\n float _e85 = local_6;\\n highp uint _e87 = local_7;\\n vec4 _e88 = effect(_e77, _e79, _e81, _e83, _e85, _e87);\\n _fs2p_location0 = _e88;\\n return;\\n }\\n float _e105 = _group_0_binding_0_fs.size.w;\\n vec2 from_top_1 = vec2(position.x, (_e105 - position.y));\\n vec4 _e113 = texelFetch(_group_0_binding_1_fs, ivec2(position.xy), 0);\\n local_2 = _e113;\\n vec4 _e128 = _group_0_binding_0_fs.size;\\n local_5 = _e128.xy;\\n local_4 = from_top_1;\\n vec4 _e144 = _group_0_binding_0_fs.size;\\n local_3 = (from_top_1 / _e144.xy);\\n vec4 _e160 = local_2;\\n vec2 _e162 = local_3;\\n vec2 _e164 = local_4;\\n vec2 _e166 = local_5;\\n float _e168 = local_6;\\n highp uint _e170 = local_7;\\n vec4 _e171 = effect(_e160, _e162, _e164, _e166, _e168, _e170);\\n _fs2p_location0 = _e171;\\n return;\\n}\\n\"],\"lists\":[[0,1,2,3,4,5],[6,2,7,8,9,10,11,12,13,14,15,16,17,18,19,20]]}"].map((json) => ({ json })));
|
|
5
|
+
const sourceOf = (n) => {
|
|
6
|
+
const path = paths[n < 0 ? 1 : 0];
|
|
7
|
+
const tables = path.tables || (path.tables = JSON.parse(path.json));
|
|
8
|
+
return tables.lists[n < 0 ? -1 - n : n].map((block) => tables.blocks[block]).join('');
|
|
9
|
+
};
|
|
10
|
+
const walk = (item) => {
|
|
11
|
+
for (const key in item) {
|
|
12
|
+
const field = item[key];
|
|
13
|
+
if (key === "source" && typeof field === 'number')
|
|
14
|
+
Object.defineProperty(item, key, { get: () => sourceOf(field), enumerable: true });
|
|
15
|
+
else if (field !== null && typeof field === 'object') walk(field);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const shader = JSON.parse(text);
|
|
19
|
+
walk(shader);
|
|
20
|
+
if (hot !== undefined) shader.hot = hot;
|
|
21
|
+
if (load !== undefined)
|
|
22
|
+
shader.builds = (target, set) => load(kind, target, set).then((module) => module.default[index] || {});
|
|
23
|
+
return shader;
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default __null3dShader("[{\"webgpu\":{\"permutation\":0,\"wgsl\":{\"source\":0,\"pipelines\":{\"main\":{\"vertex\":\"effect_vs\",\"fragment\":\"effect_fs\"}}},\"glsl\":null}}]");
|
|
2
|
+
|
|
3
|
+
function __null3dShader(text, hot, load, index, kind) {
|
|
4
|
+
const paths = __null3dShader.paths || (__null3dShader.paths = ["{\"blocks\":[\"struct EffectBlock {\\n size: vec4<f32>,\\n clock: vec4<f32>,\\n inverse_projection: mat4x4<f32>,\\n u0_: vec4<f32>,\\n u1_: vec4<f32>,\\n u2_: vec4<f32>,\\n u3_: vec4<f32>,\\n u4_: vec4<f32>,\\n u5_: vec4<f32>,\\n u6_: vec4<f32>,\\n u7_: vec4<f32>,\\n drawn: vec4<f32>,\\n bloom: vec4<f32>,\\n}\\n\",\"\\nstruct EffectInput {\\n color: vec4<f32>,\\n uv: vec2<f32>,\\n pixel: vec2<f32>,\\n size: vec2<f32>,\\n time: f32,\\n layer: u32,\\n}\\n\",\"\\nstruct Uniforms {\\n visibleColor: vec3<f32>,\\n hiddenColor: vec3<f32>,\\n}\\n\",\"\\n@group(0) @binding(0)\",\"\\nvar<uniform> effect_block: EffectBlock;\",\"\\n@group(0) @binding(1)\",\"\\nvar effect_source: texture_2d<f32>;\",\"\\n@group(0) @binding(2)\",\"\\nvar effect_sampler: sampler;\",\"\\nvar<private> uniforms: Uniforms;\\n\",\"\\nfn triangle(vertex_1: u32) -> vec4<f32> {\\n let x = ((f32(((vertex_1 << 1u) & 2u)) * 2f) - 1f);\\n let y = ((f32((vertex_1 & 2u)) * 2f) - 1f);\\n return vec4<f32>(x, y, 0.5f, 1f);\\n}\\n\",\"\\nfn effect_value(part: u32) -> vec4<f32> {\\n switch part {\\n case 0u: {\\n let _e3 = effect_block.u0_;\\n return _e3;\\n }\\n case 1u: {\\n let _e6 = effect_block.u1_;\\n return _e6;\\n }\\n case 2u: {\\n let _e9 = effect_block.u2_;\\n return _e9;\\n }\\n case 3u: {\\n let _e12 = effect_block.u3_;\\n return _e12;\\n }\\n case 4u: {\\n let _e15 = effect_block.u4_;\\n return _e15;\\n }\\n case 5u: {\\n let _e18 = effect_block.u5_;\\n return _e18;\\n }\\n case 6u: {\\n let _e21 = effect_block.u6_;\\n return _e21;\\n }\\n default: {\\n let _e24 = effect_block.u7_;\\n return _e24;\\n }\\n }\\n}\\n\",\"\\nfn effectColor(uv: vec2<f32>) -> vec4<f32> {\\n var at: vec2<f32>;\\n\\n let _e2 = effect_block.size;\\n let render = _e2.xy;\\n at = clamp((uv * render), vec2(0.5f), (render - vec2(0.5f)));\\n let _e13 = at;\\n let _e16 = effect_block.size;\\n let _e22 = textureSampleLevel(effect_source, effect_sampler, (_e13 / _e16.zw), 0f);\\n return _e22;\\n}\\n\",\"\\nfn load_effect_uniforms() -> Uniforms {\\n var u: Uniforms;\\n\\n let _e1 = effect_value(0u);\\n u.visibleColor = _e1.xyz;\\n let _e6 = effect_value(1u);\\n u.hiddenColor = _e6.xyz;\\n let _e9 = u;\\n return _e9;\\n}\\n\",\"\\nfn effect(input_1: EffectInput) -> vec4<f32> {\\n let texel = (vec2(1f) / input_1.size);\\n let _e6 = effectColor(input_1.uv);\\n let _e12 = effectColor((input_1.uv - vec2<f32>(texel.x, 0f)));\\n let _e18 = effectColor((input_1.uv + vec2<f32>(texel.x, 0f)));\\n let _e24 = effectColor((input_1.uv - vec2<f32>(0f, texel.y)));\\n let _e30 = effectColor((input_1.uv + vec2<f32>(0f, texel.y)));\\n let d = vec2<f32>(((_e18.x - _e12.x) * 0.5f), ((_e30.x - _e24.x) * 0.5f));\\n let visibility = min(min(_e12.y, _e18.y), min(_e24.y, _e30.y));\\n let _e51 = uniforms.hiddenColor;\\n let _e54 = uniforms.visibleColor;\\n let shown = select(_e51, _e54, ((1f - visibility) > 1e-3f));\\n return vec4<f32>((shown * length(d)), (1f - _e6.x));\\n}\\n\",\"\\n@vertex\",\"\\nfn effect_vs(@builtin(vertex_index) vertex: u32) -> @builtin(position) vec4<f32> {\\n let _e1 = triangle(vertex);\\n return _e1;\\n}\\n\",\"\\n@fragment\",\"\\nfn effect_fs(@builtin(position) position: vec4<f32>) -> @location(0) vec4<f32> {\\n var input: EffectInput;\\n\\n let _e0 = load_effect_uniforms();\\n uniforms = _e0;\\n let _e7 = effect_block.clock.x;\\n input.time = _e7;\\n input.layer = 0u;\\n let drawn = effect_block.drawn;\\n if (drawn.w > 0.5f) {\\n let from_top = vec2<f32>(position.x, (drawn.z - position.y));\\n input.size = drawn.xy;\\n input.pixel = from_top;\\n input.uv = (from_top / drawn.xy);\\n let _e30 = input.uv;\\n let _e31 = effectColor(_e30);\\n input.color = _e31;\\n input.layer = (u32(drawn.w) - 1u);\\n let _e37 = input;\\n let _e38 = effect(_e37);\\n return _e38;\\n }\\n let from_top_1 = position.xy;\\n let _e45 = textureLoad(effect_source, vec2<i32>(position.xy), 0i);\\n input.color = _e45;\\n let _e49 = effect_block.size;\\n input.size = _e49.xy;\\n input.pixel = from_top_1;\\n let _e55 = effect_block.size;\\n input.uv = (from_top_1 / _e55.xy);\\n let _e58 = input;\\n let _e59 = effect(_e58);\\n return _e59;\\n}\\n\"],\"lists\":[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]]}", "{\"blocks\":[],\"lists\":[]}"].map((json) => ({ json })));
|
|
5
|
+
const sourceOf = (n) => {
|
|
6
|
+
const path = paths[n < 0 ? 1 : 0];
|
|
7
|
+
const tables = path.tables || (path.tables = JSON.parse(path.json));
|
|
8
|
+
return tables.lists[n < 0 ? -1 - n : n].map((block) => tables.blocks[block]).join('');
|
|
9
|
+
};
|
|
10
|
+
const walk = (item) => {
|
|
11
|
+
for (const key in item) {
|
|
12
|
+
const field = item[key];
|
|
13
|
+
if (key === "source" && typeof field === 'number')
|
|
14
|
+
Object.defineProperty(item, key, { get: () => sourceOf(field), enumerable: true });
|
|
15
|
+
else if (field !== null && typeof field === 'object') walk(field);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const shader = JSON.parse(text);
|
|
19
|
+
walk(shader);
|
|
20
|
+
if (hot !== undefined) shader.hot = hot;
|
|
21
|
+
if (load !== undefined)
|
|
22
|
+
shader.builds = (target, set) => load(kind, target, set).then((module) => module.default[index] || {});
|
|
23
|
+
return shader;
|
|
24
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// The types of outline-edge.wgsl, which the null3D Vite plugin writes when it compiles the file.
|
|
2
|
+
// Edit the WGSL, not this file.
|
|
3
|
+
import type { CompiledEffect } from '@null3d/vite-plugin';
|
|
4
|
+
|
|
5
|
+
declare const shader: CompiledEffect<
|
|
6
|
+
{
|
|
7
|
+
readonly visibleColor: 'vec3f';
|
|
8
|
+
readonly hiddenColor: 'vec3f';
|
|
9
|
+
},
|
|
10
|
+
never
|
|
11
|
+
>;
|
|
12
|
+
export default shader;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export default __null3dShader("{\"kind\":\"effect\",\"uniforms\":[{\"name\":\"visibleColor\",\"type\":\"vec3f\",\"offset\":0},{\"name\":\"hiddenColor\",\"type\":\"vec3f\",\"offset\":4}],\"depth\":false,\"bloom\":false,\"joins\":false,\"textures\":[],\"variants\":{},\"pieces\":{\"group\":{\"webgl2\":{\"permutation\":0,\"wgsl\":null,\"glsl\":{\"items\":[\"struct fxef576473_Uniforms {\\n vec3 visibleColor;\\n vec3 hiddenColor;\\n};\\n\",\"vec3 fxef576473_uniforms_0_ = vec3(0.0);\\n\",\"vec3 fxef576473_uniforms_1_ = vec3(0.0);\\n\",\"vec4 effect_value_at(highp uint effect_value_at_slot, highp uint effect_value_at_part) {\\n vec4 _e24 = _group_0_binding_0_fs.blocks[effect_value_at_slot].u0_;\\n vec4 _e26 = _group_0_binding_0_fs.blocks[effect_value_at_slot].u1_;\\n vec4 _e28 = _group_0_binding_0_fs.blocks[effect_value_at_slot].u2_;\\n vec4 _e30 = _group_0_binding_0_fs.blocks[effect_value_at_slot].u3_;\\n vec4 _e32 = _group_0_binding_0_fs.blocks[effect_value_at_slot].u4_;\\n vec4 _e34 = _group_0_binding_0_fs.blocks[effect_value_at_slot].u5_;\\n vec4 _e36 = _group_0_binding_0_fs.blocks[effect_value_at_slot].u6_;\\n vec4 _e38 = _group_0_binding_0_fs.blocks[effect_value_at_slot].u7_;\\n switch(effect_value_at_part) {\\n case 0u: {\\n return _e24;\\n }\\n case 1u: {\\n return _e26;\\n }\\n case 2u: {\\n return _e28;\\n }\\n case 3u: {\\n return _e30;\\n }\\n case 4u: {\\n return _e32;\\n }\\n case 5u: {\\n return _e34;\\n }\\n case 6u: {\\n return _e36;\\n }\\n default: {\\n return _e38;\\n }\\n }\\n}\\n\",\"vec4 effectColor(vec2 effectColor_uv) {\\n vec2 effectColor_at = vec2(0.0);\\n vec4 _e16 = _group_0_binding_0_fs.blocks[0].size;\\n vec2 effectColor_render = _e16.xy;\\n effectColor_at = clamp((effectColor_uv * effectColor_render), vec2(0.5), (effectColor_render - vec2(0.5)));\\n float _e45 = _group_0_binding_0_fs.blocks[0].size.w;\\n float _e47 = effectColor_at.y;\\n effectColor_at.y = (_e45 - _e47);\\n vec2 _e49 = effectColor_at;\\n vec4 _e66 = _group_0_binding_0_fs.blocks[0].size;\\n vec4 _e72 = textureLod(_group_0_binding_1_fs, vec2((_e49 / _e66.zw)), 0.0);\\n return _e72;\\n}\\n\",\"void fxef576473_load_effect_piece_uniforms(highp uint fxef576473_load_effect_piece_uniforms_slot, inout vec3 param, inout vec3 param_1) {\\n vec3 local_6 = vec3(0.0);\\n vec3 local_7 = vec3(0.0);\\n vec4 _e2 = effect_value_at(fxef576473_load_effect_piece_uniforms_slot, 0u);\\n local_6 = _e2.xyz;\\n vec4 _e7 = effect_value_at(fxef576473_load_effect_piece_uniforms_slot, 1u);\\n local_7 = _e7.xyz;\\n vec3 _e10 = local_6;\\n vec3 _e12 = local_7;\\n param = _e10;\\n param_1 = _e12;\\n return;\\n}\\n\",\"vec4 fxef576473_effect(vec4 param_2, vec2 param_3, vec2 param_4, vec2 param_5, float param_6, highp uint param_7) {\\n vec2 fxef576473_effect_texel = (vec2(1.0) / param_5);\\n vec4 _e9 = effectColor(param_3);\\n vec4 _e14 = effectColor((param_3 - vec2(fxef576473_effect_texel.x, 0.0)));\\n vec4 _e19 = effectColor((param_3 + vec2(fxef576473_effect_texel.x, 0.0)));\\n vec4 _e24 = effectColor((param_3 - vec2(0.0, fxef576473_effect_texel.y)));\\n vec4 _e29 = effectColor((param_3 + vec2(0.0, fxef576473_effect_texel.y)));\\n vec2 fxef576473_effect_d = vec2(((_e19.x - _e14.x) * 0.5), ((_e29.x - _e24.x) * 0.5));\\n float fxef576473_effect_visibility = min(min(_e14.y, _e19.y), min(_e24.y, _e29.y));\\n vec3 _e50 = fxef576473_uniforms_1_;\\n vec3 _e53 = fxef576473_uniforms_0_;\\n vec3 fxef576473_effect_shown = (((1.0 - fxef576473_effect_visibility) > 0.001) ? _e53 : _e50);\\n return vec4((fxef576473_effect_shown * length(fxef576473_effect_d)), (1.0 - _e9.x));\\n}\\n\",\"vec4 fxef576473_effect_piece_main(vec4 param_8, vec2 param_9, vec2 param_10, vec2 param_11, float param_12, highp uint param_13, highp uint fxef576473_effect_piece_main_slot) {\\n vec3 local_8 = vec3(0.0);\\n vec3 local_9 = vec3(0.0);\\n fxef576473_load_effect_piece_uniforms(fxef576473_effect_piece_main_slot, local_8, local_9);\\n vec3 _e4 = local_8;\\n vec3 _e6 = local_9;\\n fxef576473_uniforms_0_ = _e4;\\n fxef576473_uniforms_1_ = _e6;\\n vec4 _e15 = fxef576473_effect(param_8, param_9, param_10, param_11, param_12, param_13);\\n return _e15;\\n}\\n\"],\"run\":\"fxef576473_effect_piece_main\",\"uniformBlocks\":[],\"textures\":[{\"name\":\"_group_0_binding_1_fs\",\"group\":0,\"binding\":1,\"sampler\":{\"group\":0,\"binding\":2}}]}},\"webgpu\":{\"permutation\":0,\"wgsl\":{\"items\":[\"struct fxef576473_Uniforms {\\n visibleColor: vec3<f32>,\\n hiddenColor: vec3<f32>,\\n}\\n\",\"@group(0) @binding(2)\\nvar effect_sampler: sampler;\\n\",\"var<private> fxef576473_uniforms: fxef576473_Uniforms;\\n\",\"fn effect_value_at(effect_value_at_slot: u32, effect_value_at_part: u32) -> vec4<f32> {\\n let effect_value_at_block = effect_blocks.blocks[effect_value_at_slot];\\n switch effect_value_at_part {\\n case 0u: {\\n return effect_value_at_block.u0_;\\n }\\n case 1u: {\\n return effect_value_at_block.u1_;\\n }\\n case 2u: {\\n return effect_value_at_block.u2_;\\n }\\n case 3u: {\\n return effect_value_at_block.u3_;\\n }\\n case 4u: {\\n return effect_value_at_block.u4_;\\n }\\n case 5u: {\\n return effect_value_at_block.u5_;\\n }\\n case 6u: {\\n return effect_value_at_block.u6_;\\n }\\n default: {\\n return effect_value_at_block.u7_;\\n }\\n }\\n}\\n\",\"fn effectColor(effectColor_uv: vec2<f32>) -> vec4<f32> {\\n var effectColor_at: vec2<f32>;\\n\\n let _e4 = effect_blocks.blocks[0].size;\\n let effectColor_render = _e4.xy;\\n effectColor_at = clamp((effectColor_uv * effectColor_render), vec2(0.5f), (effectColor_render - vec2(0.5f)));\\n let _e15 = effectColor_at;\\n let _e20 = effect_blocks.blocks[0].size;\\n let _e26 = textureSampleLevel(effect_source, effect_sampler, (_e15 / _e20.zw), 0f);\\n return _e26;\\n}\\n\",\"fn fxef576473_load_effect_piece_uniforms(fxef576473_load_effect_piece_uniforms_slot: u32) -> fxef576473_Uniforms {\\n var fxef576473_load_effect_piece_uniforms_u: fxef576473_Uniforms;\\n\\n let _e2 = effect_value_at(fxef576473_load_effect_piece_uniforms_slot, 0u);\\n fxef576473_load_effect_piece_uniforms_u.visibleColor = _e2.xyz;\\n let _e7 = effect_value_at(fxef576473_load_effect_piece_uniforms_slot, 1u);\\n fxef576473_load_effect_piece_uniforms_u.hiddenColor = _e7.xyz;\\n let _e10 = fxef576473_load_effect_piece_uniforms_u;\\n return _e10;\\n}\\n\",\"fn fxef576473_effect(fxef576473_effect_input: EffectInput) -> vec4<f32> {\\n let fxef576473_effect_texel = (vec2(1f) / fxef576473_effect_input.size);\\n let _e6 = effectColor(fxef576473_effect_input.uv);\\n let _e12 = effectColor((fxef576473_effect_input.uv - vec2<f32>(fxef576473_effect_texel.x, 0f)));\\n let _e18 = effectColor((fxef576473_effect_input.uv + vec2<f32>(fxef576473_effect_texel.x, 0f)));\\n let _e24 = effectColor((fxef576473_effect_input.uv - vec2<f32>(0f, fxef576473_effect_texel.y)));\\n let _e30 = effectColor((fxef576473_effect_input.uv + vec2<f32>(0f, fxef576473_effect_texel.y)));\\n let fxef576473_effect_d = vec2<f32>(((_e18.x - _e12.x) * 0.5f), ((_e30.x - _e24.x) * 0.5f));\\n let fxef576473_effect_visibility = min(min(_e12.y, _e18.y), min(_e24.y, _e30.y));\\n let _e51 = fxef576473_uniforms.hiddenColor;\\n let _e54 = fxef576473_uniforms.visibleColor;\\n let fxef576473_effect_shown = select(_e51, _e54, ((1f - fxef576473_effect_visibility) > 1e-3f));\\n return vec4<f32>((fxef576473_effect_shown * length(fxef576473_effect_d)), (1f - _e6.x));\\n}\\n\",\"fn fxef576473_effect_piece_main(fxef576473_effect_piece_main_input: EffectInput, fxef576473_effect_piece_main_slot: u32) -> vec4<f32> {\\n let _e1 = fxef576473_load_effect_piece_uniforms(fxef576473_effect_piece_main_slot);\\n fxef576473_uniforms = _e1;\\n let _e4 = fxef576473_effect(fxef576473_effect_piece_main_input);\\n return _e4;\\n}\\n\"],\"run\":\"fxef576473_effect_piece_main\"},\"glsl\":null}},\"fold\":{\"webgl2\":{\"permutation\":0,\"wgsl\":null,\"glsl\":{\"items\":[\"struct fxef576473_Uniforms {\\n vec3 visibleColor;\\n vec3 hiddenColor;\\n};\\n\",\"vec3 fxef576473_uniforms_0_ = vec3(0.0);\\n\",\"vec3 fxef576473_uniforms_1_ = vec3(0.0);\\n\",\"vec4 effect_value_at(highp uint effect_value_at_slot, highp uint effect_value_at_part) {\\n vec4 _e24 = _group_0_binding_4_fs.blocks[effect_value_at_slot].u0_;\\n vec4 _e26 = _group_0_binding_4_fs.blocks[effect_value_at_slot].u1_;\\n vec4 _e28 = _group_0_binding_4_fs.blocks[effect_value_at_slot].u2_;\\n vec4 _e30 = _group_0_binding_4_fs.blocks[effect_value_at_slot].u3_;\\n vec4 _e32 = _group_0_binding_4_fs.blocks[effect_value_at_slot].u4_;\\n vec4 _e34 = _group_0_binding_4_fs.blocks[effect_value_at_slot].u5_;\\n vec4 _e36 = _group_0_binding_4_fs.blocks[effect_value_at_slot].u6_;\\n vec4 _e38 = _group_0_binding_4_fs.blocks[effect_value_at_slot].u7_;\\n switch(effect_value_at_part) {\\n case 0u: {\\n return _e24;\\n }\\n case 1u: {\\n return _e26;\\n }\\n case 2u: {\\n return _e28;\\n }\\n case 3u: {\\n return _e30;\\n }\\n case 4u: {\\n return _e32;\\n }\\n case 5u: {\\n return _e34;\\n }\\n case 6u: {\\n return _e36;\\n }\\n default: {\\n return _e38;\\n }\\n }\\n}\\n\",\"vec4 effectColor(vec2 effectColor_uv) {\\n vec2 effectColor_at = vec2(0.0);\\n vec4 _e16 = _group_0_binding_4_fs.blocks[0].size;\\n vec2 effectColor_render = _e16.xy;\\n effectColor_at = clamp((effectColor_uv * effectColor_render), vec2(0.5), (effectColor_render - vec2(0.5)));\\n float _e45 = _group_0_binding_4_fs.blocks[0].size.w;\\n float _e47 = effectColor_at.y;\\n effectColor_at.y = (_e45 - _e47);\\n vec2 _e49 = effectColor_at;\\n vec4 _e66 = _group_0_binding_4_fs.blocks[0].size;\\n vec4 _e72 = textureLod(_group_0_binding_1_fs, vec2((_e49 / _e66.zw)), 0.0);\\n return _e72;\\n}\\n\",\"void fxef576473_load_effect_piece_uniforms(highp uint fxef576473_load_effect_piece_uniforms_slot, inout vec3 param_4, inout vec3 param_5) {\\n vec3 local_1 = vec3(0.0);\\n vec3 local_2 = vec3(0.0);\\n vec4 _e2 = effect_value_at(fxef576473_load_effect_piece_uniforms_slot, 0u);\\n local_1 = _e2.xyz;\\n vec4 _e7 = effect_value_at(fxef576473_load_effect_piece_uniforms_slot, 1u);\\n local_2 = _e7.xyz;\\n vec3 _e10 = local_1;\\n vec3 _e12 = local_2;\\n param_4 = _e10;\\n param_5 = _e12;\\n return;\\n}\\n\",\"vec4 fxef576473_effect(vec4 param_6, vec2 param_7, vec2 param_8, vec2 param_9, float param_10, highp uint param_11) {\\n vec2 fxef576473_effect_texel = (vec2(1.0) / param_9);\\n vec4 _e9 = effectColor(param_7);\\n vec4 _e14 = effectColor((param_7 - vec2(fxef576473_effect_texel.x, 0.0)));\\n vec4 _e19 = effectColor((param_7 + vec2(fxef576473_effect_texel.x, 0.0)));\\n vec4 _e24 = effectColor((param_7 - vec2(0.0, fxef576473_effect_texel.y)));\\n vec4 _e29 = effectColor((param_7 + vec2(0.0, fxef576473_effect_texel.y)));\\n vec2 fxef576473_effect_d = vec2(((_e19.x - _e14.x) * 0.5), ((_e29.x - _e24.x) * 0.5));\\n float fxef576473_effect_visibility = min(min(_e14.y, _e19.y), min(_e24.y, _e29.y));\\n vec3 _e50 = fxef576473_uniforms_1_;\\n vec3 _e53 = fxef576473_uniforms_0_;\\n vec3 fxef576473_effect_shown = (((1.0 - fxef576473_effect_visibility) > 0.001) ? _e53 : _e50);\\n return vec4((fxef576473_effect_shown * length(fxef576473_effect_d)), (1.0 - _e9.x));\\n}\\n\",\"vec4 fxef576473_effect_piece_main(vec4 param_12, vec2 param_13, vec2 param_14, vec2 param_15, float param_16, highp uint param_17, highp uint fxef576473_effect_piece_main_slot) {\\n vec3 local_3 = vec3(0.0);\\n vec3 local_4 = vec3(0.0);\\n fxef576473_load_effect_piece_uniforms(fxef576473_effect_piece_main_slot, local_3, local_4);\\n vec3 _e4 = local_3;\\n vec3 _e6 = local_4;\\n fxef576473_uniforms_0_ = _e4;\\n fxef576473_uniforms_1_ = _e6;\\n vec4 _e15 = fxef576473_effect(param_12, param_13, param_14, param_15, param_16, param_17);\\n return _e15;\\n}\\n\"],\"run\":\"fxef576473_effect_piece_main\",\"uniformBlocks\":[],\"textures\":[{\"name\":\"_group_0_binding_1_fs\",\"group\":0,\"binding\":1,\"sampler\":{\"group\":0,\"binding\":10}}]}},\"webgpu\":{\"permutation\":0,\"wgsl\":{\"items\":[\"struct fxef576473_Uniforms {\\n visibleColor: vec3<f32>,\\n hiddenColor: vec3<f32>,\\n}\\n\",\"var<private> fxef576473_uniforms: fxef576473_Uniforms;\\n\",\"fn effect_value_at(effect_value_at_slot: u32, effect_value_at_part: u32) -> vec4<f32> {\\n let effect_value_at_block = effect_blocks.blocks[effect_value_at_slot];\\n switch effect_value_at_part {\\n case 0u: {\\n return effect_value_at_block.u0_;\\n }\\n case 1u: {\\n return effect_value_at_block.u1_;\\n }\\n case 2u: {\\n return effect_value_at_block.u2_;\\n }\\n case 3u: {\\n return effect_value_at_block.u3_;\\n }\\n case 4u: {\\n return effect_value_at_block.u4_;\\n }\\n case 5u: {\\n return effect_value_at_block.u5_;\\n }\\n case 6u: {\\n return effect_value_at_block.u6_;\\n }\\n default: {\\n return effect_value_at_block.u7_;\\n }\\n }\\n}\\n\",\"fn effectColor(effectColor_uv: vec2<f32>) -> vec4<f32> {\\n var effectColor_at: vec2<f32>;\\n\\n let _e4 = effect_blocks.blocks[0].size;\\n let effectColor_render = _e4.xy;\\n effectColor_at = clamp((effectColor_uv * effectColor_render), vec2(0.5f), (effectColor_render - vec2(0.5f)));\\n let _e15 = effectColor_at;\\n let _e20 = effect_blocks.blocks[0].size;\\n let _e26 = textureSampleLevel(scene_color, lut_sampler, (_e15 / _e20.zw), 0f);\\n return _e26;\\n}\\n\",\"fn fxef576473_load_effect_piece_uniforms(fxef576473_load_effect_piece_uniforms_slot: u32) -> fxef576473_Uniforms {\\n var fxef576473_load_effect_piece_uniforms_u: fxef576473_Uniforms;\\n\\n let _e2 = effect_value_at(fxef576473_load_effect_piece_uniforms_slot, 0u);\\n fxef576473_load_effect_piece_uniforms_u.visibleColor = _e2.xyz;\\n let _e7 = effect_value_at(fxef576473_load_effect_piece_uniforms_slot, 1u);\\n fxef576473_load_effect_piece_uniforms_u.hiddenColor = _e7.xyz;\\n let _e10 = fxef576473_load_effect_piece_uniforms_u;\\n return _e10;\\n}\\n\",\"fn fxef576473_effect(fxef576473_effect_input: EffectInput) -> vec4<f32> {\\n let fxef576473_effect_texel = (vec2(1f) / fxef576473_effect_input.size);\\n let _e6 = effectColor(fxef576473_effect_input.uv);\\n let _e12 = effectColor((fxef576473_effect_input.uv - vec2<f32>(fxef576473_effect_texel.x, 0f)));\\n let _e18 = effectColor((fxef576473_effect_input.uv + vec2<f32>(fxef576473_effect_texel.x, 0f)));\\n let _e24 = effectColor((fxef576473_effect_input.uv - vec2<f32>(0f, fxef576473_effect_texel.y)));\\n let _e30 = effectColor((fxef576473_effect_input.uv + vec2<f32>(0f, fxef576473_effect_texel.y)));\\n let fxef576473_effect_d = vec2<f32>(((_e18.x - _e12.x) * 0.5f), ((_e30.x - _e24.x) * 0.5f));\\n let fxef576473_effect_visibility = min(min(_e12.y, _e18.y), min(_e24.y, _e30.y));\\n let _e51 = fxef576473_uniforms.hiddenColor;\\n let _e54 = fxef576473_uniforms.visibleColor;\\n let fxef576473_effect_shown = select(_e51, _e54, ((1f - fxef576473_effect_visibility) > 1e-3f));\\n return vec4<f32>((fxef576473_effect_shown * length(fxef576473_effect_d)), (1f - _e6.x));\\n}\\n\",\"fn fxef576473_effect_piece_main(fxef576473_effect_piece_main_input: EffectInput, fxef576473_effect_piece_main_slot: u32) -> vec4<f32> {\\n let _e1 = fxef576473_load_effect_piece_uniforms(fxef576473_effect_piece_main_slot);\\n fxef576473_uniforms = _e1;\\n let _e4 = fxef576473_effect(fxef576473_effect_piece_main_input);\\n return _e4;\\n}\\n\"],\"run\":\"fxef576473_effect_piece_main\"},\"glsl\":null}}},\"permutations\":0}", undefined, __null3dBuilds, 0, "effect");
|
|
2
|
+
|
|
3
|
+
function __null3dShader(text, hot, load, index, kind) {
|
|
4
|
+
const paths = __null3dShader.paths || (__null3dShader.paths = ["{\"blocks\":[],\"lists\":[]}", "{\"blocks\":[],\"lists\":[]}"].map((json) => ({ json })));
|
|
5
|
+
const sourceOf = (n) => {
|
|
6
|
+
const path = paths[n < 0 ? 1 : 0];
|
|
7
|
+
const tables = path.tables || (path.tables = JSON.parse(path.json));
|
|
8
|
+
return tables.lists[n < 0 ? -1 - n : n].map((block) => tables.blocks[block]).join('');
|
|
9
|
+
};
|
|
10
|
+
const walk = (item) => {
|
|
11
|
+
for (const key in item) {
|
|
12
|
+
const field = item[key];
|
|
13
|
+
if (key === "source" && typeof field === 'number')
|
|
14
|
+
Object.defineProperty(item, key, { get: () => sourceOf(field), enumerable: true });
|
|
15
|
+
else if (field !== null && typeof field === 'object') walk(field);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const shader = JSON.parse(text);
|
|
19
|
+
walk(shader);
|
|
20
|
+
if (hot !== undefined) shader.hot = hot;
|
|
21
|
+
if (load !== undefined)
|
|
22
|
+
shader.builds = (target, set) => load(kind, target, set).then((module) => module.default[index] || {});
|
|
23
|
+
return shader;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function __null3dBuilds(kind, target, set) {
|
|
27
|
+
const load = {
|
|
28
|
+
"effect wgsl 0": () => import("./outline-edge.wgsl-effect-wgsl-0-81e9ba5df0070101.js"),
|
|
29
|
+
"effect glsl 0": () => import("./outline-edge.wgsl-effect-glsl-0-3504093a25fda552.js"),
|
|
30
|
+
}[kind + ' ' + target + ' ' + set];
|
|
31
|
+
return load ? load() : Promise.resolve({ default: [] });
|
|
32
|
+
}
|
package/lib/outline.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ColorInput, SketchContext } from '@null3d/engine';
|
|
2
|
+
/**
|
|
3
|
+
* The settings of an outline, with three.js's `OutlinePass` names and defaults. A setting that a
|
|
4
|
+
* call leaves out keeps its value.
|
|
5
|
+
*
|
|
6
|
+
* @category api/three-compat
|
|
7
|
+
*/
|
|
8
|
+
export interface OutlinePassOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The color of the edge around the parts that nothing hides, as `visibleEdgeColor` is. A hex
|
|
11
|
+
* string is sRGB; an array of three numbers is linear. It is white by default.
|
|
12
|
+
*/
|
|
13
|
+
color?: ColorInput;
|
|
14
|
+
/**
|
|
15
|
+
* The color of the edge around the parts that other objects hide, as `hiddenEdgeColor` is. It
|
|
16
|
+
* is `[0.1, 0.04, 0.02]` in linear color by default, which is three.js's dark brown.
|
|
17
|
+
*/
|
|
18
|
+
hiddenColor?: ColorInput;
|
|
19
|
+
/**
|
|
20
|
+
* The edge's brightness, as `edgeStrength` is: 0 or more, and 3 by default.
|
|
21
|
+
*/
|
|
22
|
+
strength?: number;
|
|
23
|
+
/**
|
|
24
|
+
* The gaussian blur's radius at half the render size, as `edgeThickness` is: above 0, and 1 by
|
|
25
|
+
* default. A wider radius softens the edge over more pixels.
|
|
26
|
+
*/
|
|
27
|
+
thickness?: number;
|
|
28
|
+
/**
|
|
29
|
+
* How much of the wider, quarter-size blur joins the edge, as `edgeGlow` is: 0 or more, and 0 by
|
|
30
|
+
* default. A glow is a soft halo that spreads past the edge.
|
|
31
|
+
*/
|
|
32
|
+
glow?: number;
|
|
33
|
+
/**
|
|
34
|
+
* The seconds that the pulse takes to rise and fall, as `pulsePeriod` is, or 0 for none, which
|
|
35
|
+
* is the default. The pulse fades the edge to a quarter of its strength and back.
|
|
36
|
+
*/
|
|
37
|
+
pulsePeriod?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* An outline that `createOutlinePass` made. A call to `set` changes its settings from the next
|
|
41
|
+
* frame on.
|
|
42
|
+
*
|
|
43
|
+
* @category api/three-compat
|
|
44
|
+
*/
|
|
45
|
+
export interface OutlinePass {
|
|
46
|
+
/**
|
|
47
|
+
* Changes the settings from the next frame on. It throws for a number outside its range, and
|
|
48
|
+
* throws for a color that the engine does not take.
|
|
49
|
+
*/
|
|
50
|
+
set(options: OutlinePassOptions): void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Draws an outline with three.js's `OutlinePass` look: a soft edge around the meshes that
|
|
54
|
+
* `mesh.setOutlined(true)` marks, its glow, and its pulse. Settings turn it on, and the core draws
|
|
55
|
+
* the mask that it reads.
|
|
56
|
+
*
|
|
57
|
+
* The edge is soft, and the core's crisp line is off. A scene that also wants the crisp line sets
|
|
58
|
+
* `post.set({ outline: { width } })` after this call.
|
|
59
|
+
*
|
|
60
|
+
* @category api/three-compat
|
|
61
|
+
*/
|
|
62
|
+
export declare function createOutlinePass(ctx: SketchContext, options?: OutlinePassOptions): OutlinePass;
|
package/lib/outline.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import blurShader from './outline-blur.wgsl.js';
|
|
2
|
+
import compositeShader from './outline-composite.wgsl.js';
|
|
3
|
+
import edgeShader from './outline-edge.wgsl.js';
|
|
4
|
+
/** Three.js's `OutlinePass` defaults, which three.js's own constructor gives. */
|
|
5
|
+
const DEFAULTS = {
|
|
6
|
+
color: [1, 1, 1],
|
|
7
|
+
hiddenColor: [0.1, 0.04, 0.02],
|
|
8
|
+
strength: 3,
|
|
9
|
+
thickness: 1,
|
|
10
|
+
glow: 0,
|
|
11
|
+
pulsePeriod: 0,
|
|
12
|
+
};
|
|
13
|
+
/** The radius of the wider blur, in texels of the quarter-size pass, as three.js's `MAX_EDGE_GLOW`. */
|
|
14
|
+
const MAX_EDGE_GLOW = 4;
|
|
15
|
+
/** How many outlines the page made, which names each pass's texture apart. */
|
|
16
|
+
let made = 0;
|
|
17
|
+
/** Throws for a number that is not finite, or is below `least`, with the call and the range. */
|
|
18
|
+
function checkAtLeast(call, name, value, least) {
|
|
19
|
+
if (!Number.isFinite(value) || value < least)
|
|
20
|
+
throw new Error(`${call}() got ${value} for ${name}, which takes a number of at least ${least}.`);
|
|
21
|
+
}
|
|
22
|
+
/** Throws for a number that is not finite, or is not above `least`, with the call and the range. */
|
|
23
|
+
function checkAbove(call, name, value, least) {
|
|
24
|
+
if (!Number.isFinite(value) || value <= least)
|
|
25
|
+
throw new Error(`${call}() got ${value} for ${name}, which takes a number above ${least}.`);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Checks each option, and gives the settings that `base` and the options that `call` gave make. A
|
|
29
|
+
* setting that the call leaves out keeps the value in `base`.
|
|
30
|
+
*/
|
|
31
|
+
function merge(base, options, call) {
|
|
32
|
+
const next = { ...base };
|
|
33
|
+
if (options.color !== undefined)
|
|
34
|
+
next.color = options.color;
|
|
35
|
+
if (options.hiddenColor !== undefined)
|
|
36
|
+
next.hiddenColor = options.hiddenColor;
|
|
37
|
+
if (options.strength !== undefined)
|
|
38
|
+
next.strength = options.strength;
|
|
39
|
+
if (options.thickness !== undefined)
|
|
40
|
+
next.thickness = options.thickness;
|
|
41
|
+
if (options.glow !== undefined)
|
|
42
|
+
next.glow = options.glow;
|
|
43
|
+
if (options.pulsePeriod !== undefined)
|
|
44
|
+
next.pulsePeriod = options.pulsePeriod;
|
|
45
|
+
checkAtLeast(call, 'strength', next.strength, 0);
|
|
46
|
+
checkAbove(call, 'thickness', next.thickness, 0);
|
|
47
|
+
checkAtLeast(call, 'glow', next.glow, 0);
|
|
48
|
+
checkAtLeast(call, 'pulsePeriod', next.pulsePeriod, 0);
|
|
49
|
+
return next;
|
|
50
|
+
}
|
|
51
|
+
/** Writes the settings that the passes and the effect read, from `settings`. */
|
|
52
|
+
function apply(ctx, parts, settings, previous) {
|
|
53
|
+
if (settings.color !== previous.color)
|
|
54
|
+
ctx.render.setPassUniform(parts.edge, 'visibleColor', settings.color);
|
|
55
|
+
if (settings.hiddenColor !== previous.hiddenColor)
|
|
56
|
+
ctx.render.setPassUniform(parts.edge, 'hiddenColor', settings.hiddenColor);
|
|
57
|
+
if (settings.thickness !== previous.thickness) {
|
|
58
|
+
ctx.render.setPassUniform(parts.blurX, 'kernelRadius', settings.thickness);
|
|
59
|
+
ctx.render.setPassUniform(parts.blurY, 'kernelRadius', settings.thickness);
|
|
60
|
+
}
|
|
61
|
+
if (settings.strength !== previous.strength ||
|
|
62
|
+
settings.glow !== previous.glow ||
|
|
63
|
+
settings.pulsePeriod !== previous.pulsePeriod) {
|
|
64
|
+
ctx.post.setEffectUniform(parts.effect, 'settings', [
|
|
65
|
+
settings.strength,
|
|
66
|
+
settings.glow,
|
|
67
|
+
settings.pulsePeriod,
|
|
68
|
+
0,
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Draws an outline with three.js's `OutlinePass` look: a soft edge around the meshes that
|
|
74
|
+
* `mesh.setOutlined(true)` marks, its glow, and its pulse. Settings turn it on, and the core draws
|
|
75
|
+
* the mask that it reads.
|
|
76
|
+
*
|
|
77
|
+
* The edge is soft, and the core's crisp line is off. A scene that also wants the crisp line sets
|
|
78
|
+
* `post.set({ outline: { width } })` after this call.
|
|
79
|
+
*
|
|
80
|
+
* @category api/three-compat
|
|
81
|
+
*/
|
|
82
|
+
export function createOutlinePass(ctx, options = {}) {
|
|
83
|
+
const settings = merge(DEFAULTS, options, 'createOutlinePass');
|
|
84
|
+
const name = `three-compat-outline-${++made}`;
|
|
85
|
+
const { render, post, textures } = ctx;
|
|
86
|
+
// The mask draws while the core's outline is on, and a width of 0 keeps its crisp line off.
|
|
87
|
+
post.set({ outline: { width: 0 } });
|
|
88
|
+
const edge = render.addPass({
|
|
89
|
+
kind: 'fullscreen',
|
|
90
|
+
wgsl: edgeShader,
|
|
91
|
+
writes: `${name}-edge`,
|
|
92
|
+
scale: 0.5,
|
|
93
|
+
input: 'outlineMask',
|
|
94
|
+
uniforms: { visibleColor: settings.color, hiddenColor: settings.hiddenColor },
|
|
95
|
+
});
|
|
96
|
+
// The graph runs a full-screen pass that names no input image before the scene, and the edge
|
|
97
|
+
// and the mask draw after it. So each blur names the scene's color as its input, which places
|
|
98
|
+
// it after the camera's passes, and reads its own texture through the textures option.
|
|
99
|
+
const blurX = render.addPass({
|
|
100
|
+
kind: 'fullscreen',
|
|
101
|
+
wgsl: blurShader,
|
|
102
|
+
writes: `${name}-edge-x`,
|
|
103
|
+
scale: 0.5,
|
|
104
|
+
input: 'sceneColor',
|
|
105
|
+
uniforms: { direction: [1, 0], kernelRadius: settings.thickness },
|
|
106
|
+
textures: { source: textures.fromPass(edge) },
|
|
107
|
+
});
|
|
108
|
+
const blurY = render.addPass({
|
|
109
|
+
kind: 'fullscreen',
|
|
110
|
+
wgsl: blurShader,
|
|
111
|
+
writes: `${name}-edge-y`,
|
|
112
|
+
scale: 0.5,
|
|
113
|
+
input: 'sceneColor',
|
|
114
|
+
uniforms: { direction: [0, 1], kernelRadius: settings.thickness },
|
|
115
|
+
textures: { source: textures.fromPass(blurX) },
|
|
116
|
+
});
|
|
117
|
+
const glowX = render.addPass({
|
|
118
|
+
kind: 'fullscreen',
|
|
119
|
+
wgsl: blurShader,
|
|
120
|
+
writes: `${name}-glow-x`,
|
|
121
|
+
scale: 0.25,
|
|
122
|
+
input: 'sceneColor',
|
|
123
|
+
uniforms: { direction: [1, 0], kernelRadius: MAX_EDGE_GLOW },
|
|
124
|
+
textures: { source: textures.fromPass(blurY) },
|
|
125
|
+
});
|
|
126
|
+
const glowY = render.addPass({
|
|
127
|
+
kind: 'fullscreen',
|
|
128
|
+
wgsl: blurShader,
|
|
129
|
+
writes: `${name}-glow-y`,
|
|
130
|
+
scale: 0.25,
|
|
131
|
+
input: 'sceneColor',
|
|
132
|
+
uniforms: { direction: [0, 1], kernelRadius: MAX_EDGE_GLOW },
|
|
133
|
+
textures: { source: textures.fromPass(glowX) },
|
|
134
|
+
});
|
|
135
|
+
const effect = post.addEffect({
|
|
136
|
+
wgsl: compositeShader,
|
|
137
|
+
uniforms: {
|
|
138
|
+
settings: [settings.strength, settings.glow, settings.pulsePeriod, 0],
|
|
139
|
+
},
|
|
140
|
+
textures: {
|
|
141
|
+
edges: textures.fromPass(blurY),
|
|
142
|
+
halo: textures.fromPass(glowY),
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
const parts = { edge, blurX, blurY, effect };
|
|
146
|
+
return {
|
|
147
|
+
set(changed) {
|
|
148
|
+
const next = merge(settings, changed, 'OutlinePass.set');
|
|
149
|
+
apply(ctx, parts, next, settings);
|
|
150
|
+
Object.assign(settings, next);
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|