lygia 1.4.0 → 1.4.1
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/CMakeLists.txt +28 -0
- package/README.md +1 -0
- package/bundle.py +108 -0
- package/color/mixBox.glsl +121 -0
- package/color/palette/fire.wesl +14 -0
- package/color/palette/macbeth.wesl +250 -0
- package/color/palette/pigments.wesl +34 -0
- package/color/palette/spectral/gems.wesl +18 -0
- package/color/palette/spectral/geoffrey.wesl +12 -0
- package/color/palette/spectral/soft.wesl +22 -0
- package/color/palette/spectral/zucconi.wesl +23 -0
- package/color/palette/spectral/zucconi6.wesl +27 -0
- package/color/palette/spectral.wesl +40 -0
- package/color/palette/spyder.wesl +105 -0
- package/color/palette/water.wesl +16 -0
- package/color/palette/zorn.wesl +29 -0
- package/dist/color/palette/fire/weslBundle.js +10 -0
- package/dist/color/palette/macbeth/weslBundle.js +10 -0
- package/dist/color/palette/pigments/weslBundle.js +10 -0
- package/dist/color/palette/spectral/gems/weslBundle.js +13 -0
- package/dist/color/palette/spectral/geoffrey/weslBundle.js +10 -0
- package/dist/color/palette/spectral/soft/weslBundle.js +13 -0
- package/dist/color/palette/spectral/weslBundle.js +13 -0
- package/dist/color/palette/spectral/zucconi/weslBundle.js +13 -0
- package/dist/color/palette/spectral/zucconi6/weslBundle.js +13 -0
- package/dist/color/palette/spyder/weslBundle.js +10 -0
- package/dist/color/palette/water/weslBundle.js +13 -0
- package/dist/color/palette/zorn/weslBundle.js +13 -0
- package/dist/lighting/fresnelReflection/weslBundle.js +1 -1
- package/dist/math/bump/weslBundle.js +4 -1
- package/dist/version/weslBundle.js +1 -1
- package/lighting/fresnelReflection.wesl +1 -1
- package/math/bump.wesl +14 -4
- package/package.json +29 -23
- package/pnpm-workspace.yaml +1 -1
- package/prune.py +4 -0
- package/version.glsl +1 -1
- package/version.hlsl +1 -1
- package/version.wesl +1 -1
- package/version.wgsl +1 -1
- package/dist/test/wesl/shaders/brick-tile/weslBundle.js +0 -14
- package/dist/test/wesl/shaders/checker-tile/weslBundle.js +0 -13
- package/dist/test/wesl/shaders/draw-aa/weslBundle.js +0 -23
- package/dist/test/wesl/shaders/draw-shapes/weslBundle.js +0 -47
- package/dist/test/wesl/shaders/draw-stroke/weslBundle.js +0 -13
- package/dist/test/wesl/shaders/hex-tile/weslBundle.js +0 -14
- package/dist/test/wesl/shaders/kaleidoscope/weslBundle.js +0 -13
- package/dist/test/wesl/shaders/mirror-tile/weslBundle.js +0 -13
- package/dist/test/wesl/shaders/perlin-noise-fbm/weslBundle.js +0 -13
- package/dist/test/wesl/shaders/pnoise-tiling/weslBundle.js +0 -13
- package/dist/test/wesl/shaders/snoise-fbm/weslBundle.js +0 -13
- package/dist/test/wesl/shaders/sprite-megaman/weslBundle.js +0 -14
- package/dist/test/wesl/shaders/tri-tile/weslBundle.js +0 -14
- package/dist/test/wesl/shaders/wavelet-vorticity/weslBundle.js +0 -13
- package/dist/test/wesl/shaders/windmill-tile/weslBundle.js +0 -13
- package/dist/test/wesl/shaders/worley-cellular/weslBundle.js +0 -13
- package/dist/test/wesl_util/blendInputs/weslBundle.js +0 -10
- package/dist/test/wesl_util/sampleQuantized/weslBundle.js +0 -10
package/CMakeLists.txt
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.10)
|
|
2
|
+
|
|
3
|
+
project(lygia)
|
|
4
|
+
|
|
5
|
+
find_package(Python3 COMPONENTS Interpreter REQUIRED)
|
|
6
|
+
|
|
7
|
+
set(LYGIA_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
|
|
8
|
+
set(LYGIA_HEADER "${LYGIA_GENERATED_DIR}/lygia.h")
|
|
9
|
+
set(LYGIA_SOURCE "${LYGIA_GENERATED_DIR}/lygia.cpp")
|
|
10
|
+
set(LYGIA_BUNDLE_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/bundle.py")
|
|
11
|
+
|
|
12
|
+
# Glob all GLSL files to ensure rebuilds when they change
|
|
13
|
+
file(GLOB_RECURSE GLSL_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.glsl")
|
|
14
|
+
|
|
15
|
+
# Create the generated directory
|
|
16
|
+
file(MAKE_DIRECTORY ${LYGIA_GENERATED_DIR})
|
|
17
|
+
|
|
18
|
+
add_custom_command(
|
|
19
|
+
OUTPUT ${LYGIA_HEADER} ${LYGIA_SOURCE}
|
|
20
|
+
COMMAND ${Python3_EXECUTABLE} "${LYGIA_BUNDLE_SCRIPT}" "${CMAKE_CURRENT_SOURCE_DIR}" "${LYGIA_GENERATED_DIR}"
|
|
21
|
+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
22
|
+
DEPENDS "${LYGIA_BUNDLE_SCRIPT}" ${GLSL_FILES}
|
|
23
|
+
COMMENT "Bundling lygia shaders"
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
add_library(lygia STATIC ${LYGIA_SOURCE} ${LYGIA_HEADER})
|
|
27
|
+
|
|
28
|
+
target_include_directories(lygia PUBLIC "${LYGIA_GENERATED_DIR}")
|
package/README.md
CHANGED
|
@@ -63,6 +63,7 @@ LYGIA have been integrated into the following Engines, Frameworks, Creative Tool
|
|
|
63
63
|
<a href="https://www.npmjs.com/package/lygia"><img src="https://lygia.xyz/imgs/npm.png" alt="npm" title="npm" width="64" /></a>
|
|
64
64
|
<a href="https://codesandbox.io/s/lygia-react-starter-fftx6p"><img src="https://lygia.xyz/imgs/r3f.png" alt="r3rf" title="r3rf" width="64" /></a>
|
|
65
65
|
<a href="https://cycling74.com/packages/jitlygia"><img src="https://lygia.xyz/imgs/max.png" alt="max" title="max" width="64" /></a>
|
|
66
|
+
<a href="https://github.com/Fabric-Project/Fabric"><img src="https://lygia.xyz/imgs/fabric.png" alt="fabric" title="fabric" width="64" /></a>
|
|
66
67
|
</p>
|
|
67
68
|
|
|
68
69
|
<p style="text-align: center;" >
|
package/bundle.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import re
|
|
4
|
+
|
|
5
|
+
def remove_comments(text):
|
|
6
|
+
def replacer(match):
|
|
7
|
+
s = match.group(0)
|
|
8
|
+
if s.startswith('/'):
|
|
9
|
+
return " " # note: a space and not an empty string
|
|
10
|
+
else:
|
|
11
|
+
return s
|
|
12
|
+
pattern = re.compile(
|
|
13
|
+
r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
|
|
14
|
+
re.DOTALL | re.MULTILINE
|
|
15
|
+
)
|
|
16
|
+
return re.sub(pattern, replacer, text)
|
|
17
|
+
|
|
18
|
+
def generate_bundle(root_dir, output_dir):
|
|
19
|
+
header_path = os.path.join(output_dir, 'lygia.h')
|
|
20
|
+
source_path = os.path.join(output_dir, 'lygia.cpp')
|
|
21
|
+
|
|
22
|
+
files_map = {}
|
|
23
|
+
|
|
24
|
+
# Walk through the directory
|
|
25
|
+
for dirpath, dirnames, filenames in os.walk(root_dir):
|
|
26
|
+
# Exclude hidden directories/files and build artifacts if present
|
|
27
|
+
if '/.' in dirpath or '\\.' in dirpath:
|
|
28
|
+
continue
|
|
29
|
+
|
|
30
|
+
for filename in filenames:
|
|
31
|
+
if filename.endswith('.glsl'):
|
|
32
|
+
full_path = os.path.join(dirpath, filename)
|
|
33
|
+
# Calculate relative path from root_dir
|
|
34
|
+
rel_path = os.path.relpath(full_path, root_dir)
|
|
35
|
+
# Ensure forward slashes and prepend 'lygia/'
|
|
36
|
+
key_path = 'lygia/' + rel_path.replace(os.path.sep, '/')
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
with open(full_path, 'r', encoding='utf-8') as f:
|
|
40
|
+
content = f.read()
|
|
41
|
+
content = remove_comments(content)
|
|
42
|
+
files_map[key_path] = content
|
|
43
|
+
except Exception as e:
|
|
44
|
+
print(f"Skipping {full_path}: {e}")
|
|
45
|
+
|
|
46
|
+
# Write Header
|
|
47
|
+
with open(header_path, 'w') as f:
|
|
48
|
+
f.write('#pragma once\n')
|
|
49
|
+
f.write('#include <string>\n\n')
|
|
50
|
+
f.write('// LYGIA, Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0\n')
|
|
51
|
+
f.write('// LYGIA, Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license\n')
|
|
52
|
+
f.write('std::string getLygiaFile(const std::string& _path);\n')
|
|
53
|
+
|
|
54
|
+
# Write Source
|
|
55
|
+
with open(source_path, 'w') as f:
|
|
56
|
+
f.write('#include "lygia.h"\n')
|
|
57
|
+
f.write('#include <map>\n')
|
|
58
|
+
f.write('#include <vector>\n')
|
|
59
|
+
f.write('#include <cstring>\n')
|
|
60
|
+
f.write('#include <initializer_list>\n\n')
|
|
61
|
+
|
|
62
|
+
f.write('static std::string _join(const std::initializer_list<const char*>& _parts) {\n')
|
|
63
|
+
f.write(' std::string result;\n')
|
|
64
|
+
f.write(' size_t len = 0;\n')
|
|
65
|
+
f.write(' for (const auto* p : _parts) len += std::strlen(p);\n')
|
|
66
|
+
f.write(' result.reserve(len);\n')
|
|
67
|
+
f.write(' for (const auto* p : _parts) result += p;\n')
|
|
68
|
+
f.write(' return result;\n')
|
|
69
|
+
f.write('}\n\n')
|
|
70
|
+
|
|
71
|
+
f.write('std::string getLygiaFile(const std::string& _path) {\n')
|
|
72
|
+
f.write(' static const std::map<std::string, std::string> files = {\n')
|
|
73
|
+
|
|
74
|
+
for key, content in files_map.items():
|
|
75
|
+
# Use raw string literal with a unique delimiter to avoid conflicts
|
|
76
|
+
# content might contain anything, so we use a delimiter unlikely to be found in GLSL
|
|
77
|
+
delimiter = "LYGIA_CONTENT"
|
|
78
|
+
while delimiter in content:
|
|
79
|
+
delimiter += "_"
|
|
80
|
+
|
|
81
|
+
# Split content into chunks to avoid C2026 on MSVC (limit around 16k-64k)
|
|
82
|
+
chunk_size = 2048
|
|
83
|
+
chunks = [content[i:i+chunk_size] for i in range(0, len(content), chunk_size)]
|
|
84
|
+
|
|
85
|
+
if len(chunks) == 0:
|
|
86
|
+
f.write(f' {{"{key}", ""}},\n')
|
|
87
|
+
elif len(chunks) == 1:
|
|
88
|
+
f.write(f' {{"{key}", R"{delimiter}({chunks[0]}){delimiter}"}},\n')
|
|
89
|
+
else:
|
|
90
|
+
f.write(f' {{"{key}", _join({{ \n')
|
|
91
|
+
for chunk in chunks:
|
|
92
|
+
f.write(f' R"{delimiter}({chunk}){delimiter}",\n')
|
|
93
|
+
f.write(f' }}) }},\n')
|
|
94
|
+
|
|
95
|
+
f.write(' };\n')
|
|
96
|
+
f.write(' auto it = files.find(_path);\n')
|
|
97
|
+
f.write(' if (it != files.end()) {\n')
|
|
98
|
+
f.write(' return it->second;\n')
|
|
99
|
+
f.write(' }\n')
|
|
100
|
+
f.write(' return "";\n')
|
|
101
|
+
f.write('}\n')
|
|
102
|
+
|
|
103
|
+
if __name__ == "__main__":
|
|
104
|
+
if len(sys.argv) < 3:
|
|
105
|
+
print("Usage: python bundle.py <root_dir> <output_dir>")
|
|
106
|
+
sys.exit(1)
|
|
107
|
+
|
|
108
|
+
generate_bundle(sys.argv[1], sys.argv[2])
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#include "../math/saturate.glsl"
|
|
2
|
+
#include "../math/sum.glsl"
|
|
3
|
+
#include "../sampler.glsl"
|
|
4
|
+
#include "space/srgb2rgb.glsl"
|
|
5
|
+
#include "space/rgb2srgb.glsl"
|
|
6
|
+
#include "space/linear2gamma.glsl"
|
|
7
|
+
#include "space/gamma2linear.glsl"
|
|
8
|
+
|
|
9
|
+
#ifdef MIXBOX_LUT_FLIP_Y
|
|
10
|
+
#define SAMPLE2DCUBE_FLIP_Z
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
#include "../sample/2DCube.glsl"
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
original_author: Secret Weapons (@scrtwpns)
|
|
17
|
+
description: |
|
|
18
|
+
Blending method for natural color mixing. It produces saturated gradients with hue shifts
|
|
19
|
+
and natural secondary colors during blending. Yellow and blue make green. The interface is
|
|
20
|
+
simple - RGB in, RGB out. Internally, Mixbox treats colors as real-life pigments using the
|
|
21
|
+
Kubelka & Munk theory to predict realistic color behavior. That way, colors act like actual
|
|
22
|
+
paints and bring more vibrance and intuition into digital painting. Learn more about it
|
|
23
|
+
by checking [Secret Weapons repository](https://github.com/scrtwpns/mixbox). Also notice that
|
|
24
|
+
this code is for non-commercial use only. And you need to get in touch with them to download
|
|
25
|
+
the LUT texture.
|
|
26
|
+
use: <vec3\vec4> mixBox(<vec3|vec4> colA, <vec3|vec4> colB, float pct)
|
|
27
|
+
options:
|
|
28
|
+
- SAMPLER_FNC(TEX, UV): optional depending the target version of GLSL (texture2D(...) or texture(...))
|
|
29
|
+
- MIXBOX_LUT: name of the texture uniform which you can find here https://github.com/scrtwpns/mixbox
|
|
30
|
+
- MIXBOX_LUT_FLIP_Y: when defined it expects a vertically flipled texture
|
|
31
|
+
- MIXBOX_LUT_SAMPLER_FNC: sampler function. Default, texture2D(MIXBOX_LUT, POS_UV).rgb
|
|
32
|
+
- MIXBOX_LUT_CELL_SIZE: Default 256
|
|
33
|
+
- MIXBOX_SRGB: by default colorA and colorB are linear RGB. If you want to use sRGB colors, define this flag.
|
|
34
|
+
license: |
|
|
35
|
+
Copyright (c) 2022, Secret Weapons. All rights reserved.
|
|
36
|
+
This code is for non-commercial use only. It is provided for research and evaluation purposes.
|
|
37
|
+
If you wish to obtain commercial license, please contact: mixbox@scrtwpns.com
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
#ifndef MIXBOX_LUT
|
|
41
|
+
#define MIXBOX_LUT u_tex0
|
|
42
|
+
#endif
|
|
43
|
+
|
|
44
|
+
#ifndef MIXBOX_LUT_SAMPLER_FNC
|
|
45
|
+
#define MIXBOX_LUT_SAMPLER_FNC(TEX, UV) SAMPLER_FNC(TEX, UV).rgb
|
|
46
|
+
#endif
|
|
47
|
+
|
|
48
|
+
#ifndef MIXBOX_LATENT_TYPE
|
|
49
|
+
#define MIXBOX_LATENT_TYPE mat3
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
#ifndef FNC_MIXBOX
|
|
54
|
+
#define FNC_MIXBOX
|
|
55
|
+
|
|
56
|
+
vec3 mixBox(vec3 c) {
|
|
57
|
+
vec4 C = vec4(c, 1.0 - sum(c));
|
|
58
|
+
vec4 S = C * C;
|
|
59
|
+
vec3 V = C.xxy * C.yzz;
|
|
60
|
+
return (C.x*S.x) * vec3( 0.07717053, 0.02826978, 0.24832992) +
|
|
61
|
+
(C.y*S.y) * vec3( 0.95912302, 0.80256528, 0.03561839) +
|
|
62
|
+
(C.z*S.z) * vec3( 0.74683774, 0.04868586, 0.00000000) +
|
|
63
|
+
(C.w*S.w) * vec3( 0.99518138, 0.99978149, 0.99704802) +
|
|
64
|
+
(S.x*C.y) * vec3( 0.04819146, 0.83363781, 0.32515377) +
|
|
65
|
+
(V.x*C.y) * vec3(-0.68146950, 1.46107803, 1.06980936) +
|
|
66
|
+
(S.x*C.z) * vec3( 0.27058419, -0.15324870, 1.98735057) +
|
|
67
|
+
(V.y*C.z) * vec3( 0.80478189, 0.67093710, 0.18424500) +
|
|
68
|
+
(S.x*C.w) * vec3(-0.35031003, 1.37855826, 3.68865000) +
|
|
69
|
+
(C.x*S.w) * vec3( 1.05128046, 1.97815239, 2.82989073) +
|
|
70
|
+
(S.y*C.z) * vec3( 3.21607125, 0.81270228, 1.03384539) +
|
|
71
|
+
(C.y*S.z) * vec3( 2.78893374, 0.41565549, -0.04487295) +
|
|
72
|
+
(S.y*C.w) * vec3( 3.02162577, 2.55374103, 0.32766114) +
|
|
73
|
+
(C.y*S.w) * vec3( 2.95124691, 2.81201112, 1.17578442) +
|
|
74
|
+
(S.z*C.w) * vec3( 2.82677043, 0.79933038, 1.81715262) +
|
|
75
|
+
(C.z*S.w) * vec3( 2.99691099, 1.22593053, 1.80653661) +
|
|
76
|
+
(V.x*C.z) * vec3( 1.87394106, 2.05027182, -0.29835996) +
|
|
77
|
+
(V.x*C.w) * vec3( 2.56609566, 7.03428198, 0.62575374) +
|
|
78
|
+
(V.y*C.w) * vec3( 4.08329484, -1.40408358, 2.14995522) +
|
|
79
|
+
(V.z*C.w) * vec3( 6.00078678, 2.55552042, 1.90739502);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
MIXBOX_LATENT_TYPE mixBox_rgb2latent(vec3 rgb) {
|
|
83
|
+
rgb = saturate(rgb);
|
|
84
|
+
#ifndef MIXBOX_SRGB
|
|
85
|
+
rgb = rgb2srgb(rgb);
|
|
86
|
+
#endif
|
|
87
|
+
vec3 lut = sample2DCube(MIXBOX_LUT, rgb).xyz;
|
|
88
|
+
return MIXBOX_LATENT_TYPE(lut, rgb - mixBox(lut), vec3(0.0, 0.0, 0.0));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
vec3 mixBox_latent2rgb(MIXBOX_LATENT_TYPE latent) {
|
|
92
|
+
vec3 srgb = saturate( mixBox(latent[0]) + latent[1] );
|
|
93
|
+
#ifdef MIXBOX_SRGB
|
|
94
|
+
return srgb;
|
|
95
|
+
#else
|
|
96
|
+
return srgb2rgb(srgb);
|
|
97
|
+
#endif
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
vec3 mixBox(vec3 colA, vec3 colB, float t) {
|
|
101
|
+
return mixBox_latent2rgb((1.0-t) * mixBox_rgb2latent(colA) + t * mixBox_rgb2latent(colB));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
vec3 mixBox(vec3 colA, vec3 colB, vec3 colC, vec3 t) {
|
|
105
|
+
MIXBOX_LATENT_TYPE cA = mixBox_rgb2latent(colA);
|
|
106
|
+
MIXBOX_LATENT_TYPE cB = mixBox_rgb2latent(colB);
|
|
107
|
+
MIXBOX_LATENT_TYPE cC = mixBox_rgb2latent(colC);
|
|
108
|
+
return mixBox_latent2rgb( cA * t.x + cB * t.y + cC * t.z );
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
vec4 mixBox(vec4 colA, vec4 colB, float t) {
|
|
112
|
+
return vec4(mixBox(colA.rgb, colB.rgb, t), mix(colA.a, colB.a, t));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
vec4 mixBox(vec4 colA, vec4 colB, vec4 colC) {
|
|
116
|
+
MIXBOX_LATENT_TYPE cA = mixBox_rgb2latent(colA.rgb);
|
|
117
|
+
MIXBOX_LATENT_TYPE cB = mixBox_rgb2latent(colB.rgb);
|
|
118
|
+
MIXBOX_LATENT_TYPE cC = mixBox_rgb2latent(colC.rgb);
|
|
119
|
+
return vec4(mixBox_latent2rgb( cA * colA.a + cB * colB.a + cC * colC.a ), colA.a + colB.a + colC.a);
|
|
120
|
+
}
|
|
121
|
+
#endif
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
contributors: Patricio Gonzalez Vivo
|
|
3
|
+
description: Simpler fire color ramp
|
|
4
|
+
use: <vec3f> fire(<f32> value)
|
|
5
|
+
examples:
|
|
6
|
+
- https://raw.githubusercontent.com/eduardfossas/lygia-study-examples/main/color/palette/fire.frag
|
|
7
|
+
license:
|
|
8
|
+
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
|
|
9
|
+
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
fn fire(x: f32) -> vec3f {
|
|
13
|
+
return vec3f(1.0, 0.25, 0.0625) * exp(4.0 * x - 1.0);
|
|
14
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/*
|
|
2
|
+
contributors: Patricio Gonzalez Vivo
|
|
3
|
+
description: |
|
|
4
|
+
MacBeth ColorChecker values from:
|
|
5
|
+
- http://en.wikipedia.org/wiki/ColorChecker
|
|
6
|
+
- http://kurtmunger.com/color_checkerid277.html
|
|
7
|
+
- http://www.rags-int-inc.com/phototechstuff/macbethtarget/
|
|
8
|
+
- https://babelcolor.com/index_htm_files/RGB%20Coordinates%20of%20the%20Macbeth%20ColorChecker.pdf
|
|
9
|
+
|
|
10
|
+
WESL conditionals:
|
|
11
|
+
- @if(CIE_D50): Use D50 illuminant for XYZ/LAB/LCH values (default: D65)
|
|
12
|
+
use:
|
|
13
|
+
- <vec3f> macbeth(<i32> index)
|
|
14
|
+
- <vec3f> macbethXYZ(<i32> index)
|
|
15
|
+
- <vec3f> macbethLAB(<i32> index)
|
|
16
|
+
- <vec3f> macbethLCH(<i32> index)
|
|
17
|
+
examples:
|
|
18
|
+
- https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/draw_colorChecker.frag
|
|
19
|
+
license:
|
|
20
|
+
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
|
|
21
|
+
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const MACBETH_TOTAL: u32 = 24u;
|
|
25
|
+
|
|
26
|
+
// Row 1: Natural colors (sRGB)
|
|
27
|
+
const DARK_SKIN: vec3f = vec3f(0.46017, 0.33059, 0.27477);
|
|
28
|
+
const LIGHT_SKIN: vec3f = vec3f(0.769, 0.576, 0.506);
|
|
29
|
+
const BLUE_SKY: vec3f = vec3f(0.356, 0.472, 0.609);
|
|
30
|
+
const FOLIAGE: vec3f = vec3f(0.357, 0.427, 0.247);
|
|
31
|
+
const BLUE_FLOWER: vec3f = vec3f(0.518, 0.506, 0.694);
|
|
32
|
+
const BLUISH_GREEN: vec3f = vec3f(0.384, 0.749, 0.675);
|
|
33
|
+
|
|
34
|
+
// Row 2: Miscellaneous colors (sRGB)
|
|
35
|
+
const ORANGE: vec3f = vec3f(0.867, 0.487, 0.184);
|
|
36
|
+
const PURPLISH_BLUE: vec3f = vec3f(0.290, 0.357, 0.671);
|
|
37
|
+
const MODERATE_RED: vec3f = vec3f(0.769, 0.333, 0.384);
|
|
38
|
+
const PURPLE: vec3f = vec3f(0.365, 0.231, 0.420);
|
|
39
|
+
const YELLOW_GREEN: vec3f = vec3f(0.624, 0.745, 0.227);
|
|
40
|
+
const ORANGE_YELLOW: vec3f = vec3f(0.894, 0.635, 0.160);
|
|
41
|
+
|
|
42
|
+
// Row 3: Primary and secondary colors (sRGB)
|
|
43
|
+
const BLUE: vec3f = vec3f(0.176, 0.247, 0.584);
|
|
44
|
+
const GREEN: vec3f = vec3f(0.239, 0.588, 0.290);
|
|
45
|
+
const RED: vec3f = vec3f(0.690, 0.224, 0.227);
|
|
46
|
+
const YELLOW: vec3f = vec3f(0.925, 0.784, 0.094);
|
|
47
|
+
const MAGENTA: vec3f = vec3f(0.749, 0.309, 0.598);
|
|
48
|
+
const CYAN: vec3f = vec3f(0.000, 0.537, 0.659);
|
|
49
|
+
|
|
50
|
+
// Row 4: Grayscale (sRGB)
|
|
51
|
+
const WHITE: vec3f = vec3f(0.956, 0.956, 0.945);
|
|
52
|
+
const NEUTRAL_80: vec3f = vec3f(0.789, 0.797, 0.797);
|
|
53
|
+
const NEUTRAL_65: vec3f = vec3f(0.635, 0.643, 0.643);
|
|
54
|
+
const NEUTRAL_50: vec3f = vec3f(0.475, 0.478, 0.478);
|
|
55
|
+
const NEUTRAL_35: vec3f = vec3f(0.329, 0.333, 0.337);
|
|
56
|
+
const BLACK: vec3f = vec3f(0.200, 0.200, 0.204);
|
|
57
|
+
|
|
58
|
+
// XYZ color space (D50 vs D65 illuminant)
|
|
59
|
+
@if(CIE_D50) const DARK_SKIN_XYZ: vec3f = vec3f(12.354, 10.896, 5.498);
|
|
60
|
+
@else const DARK_SKIN_XYZ: vec3f = vec3f(11.684, 10.637, 7.242);
|
|
61
|
+
@if(CIE_D50) const LIGHT_SKIN_XYZ: vec3f = vec3f(39.602, 35.073, 19.617);
|
|
62
|
+
@else const LIGHT_SKIN_XYZ: vec3f = vec3f(37.29, 34.404, 25.454);
|
|
63
|
+
@if(CIE_D50) const BLUE_SKY_XYZ: vec3f = vec3f(17.275, 18.663, 26.177);
|
|
64
|
+
@else const BLUE_SKY_XYZ: vec3f = vec3f(17.916, 19.032, 34.703);
|
|
65
|
+
@if(CIE_D50) const FOLIAGE_XYZ: vec3f = vec3f(11.284, 13.786, 5.479);
|
|
66
|
+
@else const FOLIAGE_XYZ: vec3f = vec3f(10.906, 13.784, 7.155);
|
|
67
|
+
@if(CIE_D50) const BLUE_FLOWER_XYZ: vec3f = vec3f(24.969, 23.688, 33.857);
|
|
68
|
+
@else const BLUE_FLOWER_XYZ: vec3f = vec3f(25.42, 23.896, 44.94);
|
|
69
|
+
@if(CIE_D50) const BLUISH_GREEN_XYZ: vec3f = vec3f(30.838, 42.168, 35.407);
|
|
70
|
+
@else const BLUISH_GREEN_XYZ: vec3f = vec3f(31.342, 43.112, 46.048);
|
|
71
|
+
@if(CIE_D50) const ORANGE_XYZ: vec3f = vec3f(41.4, 32.052, 5.12);
|
|
72
|
+
@else const ORANGE_XYZ: vec3f = vec3f(38.041, 30.531, 6.671);
|
|
73
|
+
@if(CIE_D50) const PURPLISH_BLUE_XYZ: vec3f = vec3f(12.767, 11.597, 30.374);
|
|
74
|
+
@else const PURPLISH_BLUE_XYZ: vec3f = vec3f(14.025, 12.012, 40.373);
|
|
75
|
+
@if(CIE_D50) const MODERATE_RED_XYZ: vec3f = vec3f(30.96, 20.368, 10.532);
|
|
76
|
+
@else const MODERATE_RED_XYZ: vec3f = vec3f(28.491, 19.254, 13.978);
|
|
77
|
+
@if(CIE_D50) const PURPLE_XYZ: vec3f = vec3f(8.795, 6.668, 10.99);
|
|
78
|
+
@else const PURPLE_XYZ: vec3f = vec3f(8.81, 6.597, 14.816);
|
|
79
|
+
@if(CIE_D50) const YELLOW_GREEN_XYZ: vec3f = vec3f(35.701, 45.082, 9.377);
|
|
80
|
+
@else const YELLOW_GREEN_XYZ: vec3f = vec3f(33.992, 44.969, 11.835);
|
|
81
|
+
@if(CIE_D50) const ORANGE_YELLOW_XYZ: vec3f = vec3f(49.37, 44.438, 6.215);
|
|
82
|
+
@else const ORANGE_YELLOW_XYZ: vec3f = vec3f(45.74, 42.941, 8.056);
|
|
83
|
+
@if(CIE_D50) const BLUE_XYZ: vec3f = vec3f(7.305, 6.022, 22.182);
|
|
84
|
+
@else const BLUE_XYZ: vec3f = vec3f(8.374, 6.347, 29.467);
|
|
85
|
+
@if(CIE_D50) const GREEN_XYZ: vec3f = vec3f(15.229, 23.542, 8.222);
|
|
86
|
+
@else const GREEN_XYZ: vec3f = vec3f(14.881, 23.932, 10.401);
|
|
87
|
+
@if(CIE_D50) const RED_XYZ: vec3f = vec3f(22.59, 13.543, 4.08);
|
|
88
|
+
@else const RED_XYZ: vec3f = vec3f(20.197, 12.553, 5.383);
|
|
89
|
+
@if(CIE_D50) const YELLOW_XYZ: vec3f = vec3f(60.014, 60.949, 7.554);
|
|
90
|
+
@else const YELLOW_XYZ: vec3f = vec3f(55.779, 59.612, 9.448);
|
|
91
|
+
@if(CIE_D50) const MAGENTA_XYZ: vec3f = vec3f(32.305, 20.971, 23.891);
|
|
92
|
+
@else const MAGENTA_XYZ: vec3f = vec3f(30.689, 20.117, 32.074);
|
|
93
|
+
@if(CIE_D50) const CYAN_XYZ: vec3f = vec3f(13.964, 19.428, 31.039);
|
|
94
|
+
@else const CYAN_XYZ: vec3f = vec3f(15.131, 20.357, 40.473);
|
|
95
|
+
@if(CIE_D50) const WHITE_XYZ: vec3f = vec3f(87.473, 90.892, 73.275);
|
|
96
|
+
@else const WHITE_XYZ: vec3f = vec3f(86.047, 90.868, 96.433);
|
|
97
|
+
@if(CIE_D50) const NEUTRAL_80_XYZ: vec3f = vec3f(57.342, 59.788, 49.481);
|
|
98
|
+
@else const NEUTRAL_80_XYZ: vec3f = vec3f(56.562, 59.821, 65.218);
|
|
99
|
+
@if(CIE_D50) const NEUTRAL_65_XYZ: vec3f = vec3f(35.589, 37.181, 30.911);
|
|
100
|
+
@else const NEUTRAL_65_XYZ: vec3f = vec3f(35.144, 37.209, 40.764);
|
|
101
|
+
@if(CIE_D50) const NEUTRAL_50_XYZ: vec3f = vec3f(18.752, 19.493, 16.152);
|
|
102
|
+
@else const NEUTRAL_50_XYZ: vec3f = vec3f(18.505, 19.497, 21.306);
|
|
103
|
+
@if(CIE_D50) const NEUTRAL_35_XYZ: vec3f = vec3f(8.833, 9.223, 7.82);
|
|
104
|
+
@else const NEUTRAL_35_XYZ: vec3f = vec3f(8.737, 9.233, 10.323);
|
|
105
|
+
@if(CIE_D50) const BLACK_XYZ: vec3f = vec3f(3.225, 3.34, 2.822);
|
|
106
|
+
@else const BLACK_XYZ: vec3f = vec3f(3.185, 3.342, 3.727);
|
|
107
|
+
|
|
108
|
+
// LAB color space (D50 vs D65 illuminant)
|
|
109
|
+
@if(CIE_D50) const DARK_SKIN_LAB: vec3f = vec3f(39.4, 13.26, 14.44);
|
|
110
|
+
@else const DARK_SKIN_LAB: vec3f = vec3f(38.96, 11.7, 13.73);
|
|
111
|
+
@if(CIE_D50) const LIGHT_SKIN_LAB: vec3f = vec3f(65.81, 19.06, 17.15);
|
|
112
|
+
@else const LIGHT_SKIN_LAB: vec3f = vec3f(65.28, 15.68, 16.94);
|
|
113
|
+
@if(CIE_D50) const BLUE_SKY_LAB: vec3f = vec3f(50.29, -3.86, -22.11);
|
|
114
|
+
@else const BLUE_SKY_LAB: vec3f = vec3f(50.73, -0.92, -21.57);
|
|
115
|
+
@if(CIE_D50) const FOLIAGE_LAB: vec3f = vec3f(43.92, -13.73, 22.33);
|
|
116
|
+
@else const FOLIAGE_LAB: vec3f = vec3f(43.92, -15.31, 22.61);
|
|
117
|
+
@if(CIE_D50) const BLUE_FLOWER_LAB: vec3f = vec3f(55.77, 9.33, -24.86);
|
|
118
|
+
@else const BLUE_FLOWER_LAB: vec3f = vec3f(55.98, 11.87, -24.81);
|
|
119
|
+
@if(CIE_D50) const BLUISH_GREEN_LAB: vec3f = vec3f(70.99, -33.01, -0.87);
|
|
120
|
+
@else const BLUISH_GREEN_LAB: vec3f = vec3f(71.63, -32.29, 0.96);
|
|
121
|
+
@if(CIE_D50) const ORANGE_LAB: vec3f = vec3f(63.39, 35.03, 57.69);
|
|
122
|
+
@else const ORANGE_LAB: vec3f = vec3f(62.11, 31.79, 55.83);
|
|
123
|
+
@if(CIE_D50) const PURPLISH_BLUE_LAB: vec3f = vec3f(40.57, 11.01, -45.8);
|
|
124
|
+
@else const PURPLISH_BLUE_LAB: vec3f = vec3f(41.23, 17.51, -45.0);
|
|
125
|
+
@if(CIE_D50) const MODERATE_RED_LAB: vec3f = vec3f(52.25, 48.2, 16.989);
|
|
126
|
+
@else const MODERATE_RED_LAB: vec3f = vec3f(50.98, 45.91, 14.6);
|
|
127
|
+
@if(CIE_D50) const PURPLE_LAB: vec3f = vec3f(31.04, 22.31, -21.03);
|
|
128
|
+
@else const PURPLE_LAB: vec3f = vec3f(30.87, 24.25, -22.06);
|
|
129
|
+
@if(CIE_D50) const YELLOW_GREEN_LAB: vec3f = vec3f(72.95, -24.35, 56.48);
|
|
130
|
+
@else const YELLOW_GREEN_LAB: vec3f = vec3f(72.87, -28.16, 57.78);
|
|
131
|
+
@if(CIE_D50) const ORANGE_YELLOW_LAB: vec3f = vec3f(72.52, 18.45, 68.16);
|
|
132
|
+
@else const ORANGE_YELLOW_LAB: vec3f = vec3f(71.51, 14.6, 66.93);
|
|
133
|
+
@if(CIE_D50) const BLUE_LAB: vec3f = vec3f(29.47, 15.59, -50.68);
|
|
134
|
+
@else const BLUE_LAB: vec3f = vec3f(30.27, 23.04, -49.59);
|
|
135
|
+
@if(CIE_D50) const GREEN_LAB: vec3f = vec3f(55.63, -38.46, 30.77);
|
|
136
|
+
@else const GREEN_LAB: vec3f = vec3f(56.02, -40.94, 32.75);
|
|
137
|
+
@if(CIE_D50) const RED_LAB: vec3f = vec3f(43.57, 51.47, 29.3);
|
|
138
|
+
@else const RED_LAB: vec3f = vec3f(42.08, 48.02, 26.74);
|
|
139
|
+
@if(CIE_D50) const YELLOW_LAB: vec3f = vec3f(82.35, 2.97, 79.44);
|
|
140
|
+
@else const YELLOW_LAB: vec3f = vec3f(81.63, -2.19, 79.78);
|
|
141
|
+
@if(CIE_D50) const MAGENTA_LAB: vec3f = vec3f(52.92, 50.21, -13.48);
|
|
142
|
+
@else const MAGENTA_LAB: vec3f = vec3f(51.97, 50.05, -15.89);
|
|
143
|
+
@if(CIE_D50) const CYAN_LAB: vec3f = vec3f(51.18, -27.02, -28.54);
|
|
144
|
+
@else const CYAN_LAB: vec3f = vec3f(52.24, -23.14, -26.15);
|
|
145
|
+
@if(CIE_D50) const WHITE_LAB: vec3f = vec3f(96.37, -0.31, 1.5);
|
|
146
|
+
@else const WHITE_LAB: vec3f = vec3f(96.36, -0.6, 1.65);
|
|
147
|
+
@if(CIE_D50) const NEUTRAL_80_LAB: vec3f = vec3f(81.72, -0.75, -0.16);
|
|
148
|
+
@else const NEUTRAL_80_LAB: vec3f = vec3f(81.74, -0.73, -0.07);
|
|
149
|
+
@if(CIE_D50) const NEUTRAL_65_LAB: vec3f = vec3f(67.41, -0.88, -0.36);
|
|
150
|
+
@else const NEUTRAL_65_LAB: vec3f = vec3f(67.43, -0.75, -0.29);
|
|
151
|
+
@if(CIE_D50) const NEUTRAL_50_LAB: vec3f = vec3f(51.26, -0.22, -0.16);
|
|
152
|
+
@else const NEUTRAL_50_LAB: vec3f = vec3f(51.26, -0.14, -0.14);
|
|
153
|
+
@if(CIE_D50) const NEUTRAL_35_LAB: vec3f = vec3f(36.41, -0.5, -0.82);
|
|
154
|
+
@else const NEUTRAL_35_LAB: vec3f = vec3f(36.43, -0.33, -0.8);
|
|
155
|
+
@if(CIE_D50) const BLACK_LAB: vec3f = vec3f(21.36, 0.07, -0.5);
|
|
156
|
+
@else const BLACK_LAB: vec3f = vec3f(21.36, 0.14, -0.51);
|
|
157
|
+
|
|
158
|
+
// LCH color space (D50 vs D65 illuminant)
|
|
159
|
+
@if(CIE_D50) const DARK_SKIN_LCH: vec3f = vec3f(39.4, 19.61, 47.45);
|
|
160
|
+
@else const DARK_SKIN_LCH: vec3f = vec3f(38.96, 18.04, 49.57);
|
|
161
|
+
@if(CIE_D50) const LIGHT_SKIN_LCH: vec3f = vec3f(65.81, 25.64, 41.99);
|
|
162
|
+
@else const LIGHT_SKIN_LCH: vec3f = vec3f(65.28, 23.08, 47.21);
|
|
163
|
+
@if(CIE_D50) const BLUE_SKY_LCH: vec3f = vec3f(50.29, 22.44, 260.08);
|
|
164
|
+
@else const BLUE_SKY_LCH: vec3f = vec3f(50.73, 21.59, 267.55);
|
|
165
|
+
@if(CIE_D50) const FOLIAGE_LCH: vec3f = vec3f(43.92, 26.22, 121.59);
|
|
166
|
+
@else const FOLIAGE_LCH: vec3f = vec3f(43.92, 27.31, 124.12);
|
|
167
|
+
@if(CIE_D50) const BLUE_FLOWER_LCH: vec3f = vec3f(55.77, 26.56, 290.56);
|
|
168
|
+
@else const BLUE_FLOWER_LCH: vec3f = vec3f(55.98, 27.5, 295.57);
|
|
169
|
+
@if(CIE_D50) const BLUISH_GREEN_LCH: vec3f = vec3f(70.99, 33.02, 181.51);
|
|
170
|
+
@else const BLUISH_GREEN_LCH: vec3f = vec3f(71.63, 32.3, 178.29);
|
|
171
|
+
@if(CIE_D50) const ORANGE_LCH: vec3f = vec3f(63.39, 67.49, 58.74);
|
|
172
|
+
@else const ORANGE_LCH: vec3f = vec3f(62.11, 64.24, 60.34);
|
|
173
|
+
@if(CIE_D50) const PURPLISH_BLUE_LCH: vec3f = vec3f(40.57, 47.1, 283.528);
|
|
174
|
+
@else const PURPLISH_BLUE_LCH: vec3f = vec3f(41.23, 48.29, 291.26);
|
|
175
|
+
@if(CIE_D50) const MODERATE_RED_LCH: vec3f = vec3f(52.25, 51.1, 19.4);
|
|
176
|
+
@else const MODERATE_RED_LCH: vec3f = vec3f(50.98, 48.17, 17.64);
|
|
177
|
+
@if(CIE_D50) const PURPLE_LCH: vec3f = vec3f(31.04, 30.66, 316.69);
|
|
178
|
+
@else const PURPLE_LCH: vec3f = vec3f(30.87, 32.78, 317.71);
|
|
179
|
+
@if(CIE_D50) const YELLOW_GREEN_LCH: vec3f = vec3f(72.95, 61.51, 113.32);
|
|
180
|
+
@else const YELLOW_GREEN_LCH: vec3f = vec3f(72.87, 64.28, 115.98);
|
|
181
|
+
@if(CIE_D50) const ORANGE_YELLOW_LCH: vec3f = vec3f(72.52, 70.62, 74.85);
|
|
182
|
+
@else const ORANGE_YELLOW_LCH: vec3f = vec3f(71.51, 68.5, 77.69);
|
|
183
|
+
@if(CIE_D50) const BLUE_LCH: vec3f = vec3f(29.47, 53.03, 287.1);
|
|
184
|
+
@else const BLUE_LCH: vec3f = vec3f(30.27, 54.68, 294.92);
|
|
185
|
+
@if(CIE_D50) const GREEN_LCH: vec3f = vec3f(55.63, 49.26, 141.34);
|
|
186
|
+
@else const GREEN_LCH: vec3f = vec3f(56.02, 52.43, 141.35);
|
|
187
|
+
@if(CIE_D50) const RED_LCH: vec3f = vec3f(43.57, 59.22, 29.65);
|
|
188
|
+
@else const RED_LCH: vec3f = vec3f(42.08, 54.96, 29.11);
|
|
189
|
+
@if(CIE_D50) const YELLOW_LCH: vec3f = vec3f(82.35, 79.49, 87.86);
|
|
190
|
+
@else const YELLOW_LCH: vec3f = vec3f(81.63, 79.81, 91.57);
|
|
191
|
+
@if(CIE_D50) const MAGENTA_LCH: vec3f = vec3f(52.92, 51.99, 344.97);
|
|
192
|
+
@else const MAGENTA_LCH: vec3f = vec3f(51.97, 52.51, 342.39);
|
|
193
|
+
@if(CIE_D50) const CYAN_LCH: vec3f = vec3f(51.18, 39.29, 226.57);
|
|
194
|
+
@else const CYAN_LCH: vec3f = vec3f(52.24, 34.92, 228.49);
|
|
195
|
+
@if(CIE_D50) const WHITE_LCH: vec3f = vec3f(96.37, 1.53, 101.57);
|
|
196
|
+
@else const WHITE_LCH: vec3f = vec3f(96.36, 1.76, 109.99);
|
|
197
|
+
@if(CIE_D50) const NEUTRAL_80_LCH: vec3f = vec3f(81.72, 0.77, 192.3);
|
|
198
|
+
@else const NEUTRAL_80_LCH: vec3f = vec3f(81.74, 0.74, 185.65);
|
|
199
|
+
@if(CIE_D50) const NEUTRAL_65_LCH: vec3f = vec3f(67.41, 0.95, 202.11);
|
|
200
|
+
@else const NEUTRAL_65_LCH: vec3f = vec3f(67.43, 0.81, 201.35);
|
|
201
|
+
@if(CIE_D50) const NEUTRAL_50_LCH: vec3f = vec3f(51.26, 0.28, 215.6);
|
|
202
|
+
@else const NEUTRAL_50_LCH: vec3f = vec3f(51.26, 0.2, 225.42);
|
|
203
|
+
@if(CIE_D50) const NEUTRAL_35_LCH: vec3f = vec3f(36.41, 0.96, 238.548);
|
|
204
|
+
@else const NEUTRAL_35_LCH: vec3f = vec3f(36.43, 0.87, 247.43);
|
|
205
|
+
@if(CIE_D50) const BLACK_LCH: vec3f = vec3f(21.36, 0.51, 278.09);
|
|
206
|
+
@else const BLACK_LCH: vec3f = vec3f(21.36, 0.53, 285.38);
|
|
207
|
+
|
|
208
|
+
fn macbeth(index: i32) -> vec3f {
|
|
209
|
+
var rgb = array<vec3f, MACBETH_TOTAL>(
|
|
210
|
+
DARK_SKIN, LIGHT_SKIN, BLUE_SKY, FOLIAGE, BLUE_FLOWER, BLUISH_GREEN,
|
|
211
|
+
ORANGE, PURPLISH_BLUE, MODERATE_RED, PURPLE, YELLOW_GREEN, ORANGE_YELLOW,
|
|
212
|
+
BLUE, GREEN, RED, YELLOW, MAGENTA, CYAN,
|
|
213
|
+
WHITE, NEUTRAL_80, NEUTRAL_65, NEUTRAL_50, NEUTRAL_35, BLACK
|
|
214
|
+
);
|
|
215
|
+
let idx = index % i32(MACBETH_TOTAL);
|
|
216
|
+
return rgb[idx];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
fn macbethXYZ(index: i32) -> vec3f {
|
|
220
|
+
var xyz = array<vec3f, MACBETH_TOTAL>(
|
|
221
|
+
DARK_SKIN_XYZ, LIGHT_SKIN_XYZ, BLUE_SKY_XYZ, FOLIAGE_XYZ, BLUE_FLOWER_XYZ, BLUISH_GREEN_XYZ,
|
|
222
|
+
ORANGE_XYZ, PURPLISH_BLUE_XYZ, MODERATE_RED_XYZ, PURPLE_XYZ, YELLOW_GREEN_XYZ, ORANGE_YELLOW_XYZ,
|
|
223
|
+
BLUE_XYZ, GREEN_XYZ, RED_XYZ, YELLOW_XYZ, MAGENTA_XYZ, CYAN_XYZ,
|
|
224
|
+
WHITE_XYZ, NEUTRAL_80_XYZ, NEUTRAL_65_XYZ, NEUTRAL_50_XYZ, NEUTRAL_35_XYZ, BLACK_XYZ
|
|
225
|
+
);
|
|
226
|
+
let idx = index % i32(MACBETH_TOTAL);
|
|
227
|
+
return xyz[idx];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
fn macbethLAB(index: i32) -> vec3f {
|
|
231
|
+
var lab = array<vec3f, MACBETH_TOTAL>(
|
|
232
|
+
DARK_SKIN_LAB, LIGHT_SKIN_LAB, BLUE_SKY_LAB, FOLIAGE_LAB, BLUE_FLOWER_LAB, BLUISH_GREEN_LAB,
|
|
233
|
+
ORANGE_LAB, PURPLISH_BLUE_LAB, MODERATE_RED_LAB, PURPLE_LAB, YELLOW_GREEN_LAB, ORANGE_YELLOW_LAB,
|
|
234
|
+
BLUE_LAB, GREEN_LAB, RED_LAB, YELLOW_LAB, MAGENTA_LAB, CYAN_LAB,
|
|
235
|
+
WHITE_LAB, NEUTRAL_80_LAB, NEUTRAL_65_LAB, NEUTRAL_50_LAB, NEUTRAL_35_LAB, BLACK_LAB
|
|
236
|
+
);
|
|
237
|
+
let idx = index % i32(MACBETH_TOTAL);
|
|
238
|
+
return lab[idx];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
fn macbethLCH(index: i32) -> vec3f {
|
|
242
|
+
var lch = array<vec3f, MACBETH_TOTAL>(
|
|
243
|
+
DARK_SKIN_LCH, LIGHT_SKIN_LCH, BLUE_SKY_LCH, FOLIAGE_LCH, BLUE_FLOWER_LCH, BLUISH_GREEN_LCH,
|
|
244
|
+
ORANGE_LCH, PURPLISH_BLUE_LCH, MODERATE_RED_LCH, PURPLE_LCH, YELLOW_GREEN_LCH, ORANGE_YELLOW_LCH,
|
|
245
|
+
BLUE_LCH, GREEN_LCH, RED_LCH, YELLOW_LCH, MAGENTA_LCH, CYAN_LCH,
|
|
246
|
+
WHITE_LCH, NEUTRAL_80_LCH, NEUTRAL_65_LCH, NEUTRAL_50_LCH, NEUTRAL_35_LCH, BLACK_LCH
|
|
247
|
+
);
|
|
248
|
+
let idx = index % i32(MACBETH_TOTAL);
|
|
249
|
+
return lch[idx];
|
|
250
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*
|
|
2
|
+
contributors: Patricio Gonzalez Vivo
|
|
3
|
+
description: |
|
|
4
|
+
Basic default color pigments. For specific manufacturer pigments you can use the following:
|
|
5
|
+
- winsor_oil
|
|
6
|
+
- rembrandt_oil
|
|
7
|
+
- gamblin_oil
|
|
8
|
+
- winsor_acrylics
|
|
9
|
+
- golden_acrylics
|
|
10
|
+
- liquitex_acrylics
|
|
11
|
+
- winsor_gouache
|
|
12
|
+
examples:
|
|
13
|
+
- https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/color_pigments.frag
|
|
14
|
+
license:
|
|
15
|
+
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
|
|
16
|
+
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const TITANIUM_WHITE: vec3f = vec3f(0.973, 0.961, 0.929);
|
|
20
|
+
const CADMIUM_YELLOW: vec3f = vec3f(0.996, 0.925, 0.000);
|
|
21
|
+
const HANSA_YELLOW: vec3f = vec3f(0.988, 0.827, 0.000);
|
|
22
|
+
const YELLOW_OCHRE: vec3f = vec3f(0.706, 0.486, 0.188);
|
|
23
|
+
const CADMIUM_ORANGE: vec3f = vec3f(1.000, 0.412, 0.000);
|
|
24
|
+
const CADMIUM_RED: vec3f = vec3f(1.000, 0.153, 0.008);
|
|
25
|
+
const QUINACRIDONE_MAGENTA: vec3f = vec3f(0.502, 0.008, 0.180);
|
|
26
|
+
const COBALT_VIOLET: vec3f = vec3f(0.306, 0.000, 0.259);
|
|
27
|
+
const ULTRAMARINE_BLUE: vec3f = vec3f(0.098, 0.000, 0.349);
|
|
28
|
+
const COBALTE_BLUE: vec3f = vec3f(0.000, 0.129, 0.522);
|
|
29
|
+
const PHTHALO_BLUE: vec3f = vec3f(0.051, 0.106, 0.267);
|
|
30
|
+
const PHTHALO_GREEN: vec3f = vec3f(0.000, 0.235, 0.196);
|
|
31
|
+
const PERMANENT_GREEN: vec3f = vec3f(0.027, 0.427, 0.086);
|
|
32
|
+
const SAP_GREEN: vec3f = vec3f(0.420, 0.580, 0.016);
|
|
33
|
+
const BURNT_SIENNA: vec3f = vec3f(0.482, 0.282, 0.000);
|
|
34
|
+
const IVORY_BLACK: vec3f = vec3f(0.180, 0.180, 0.180);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
contributors: ["Jos Stam", "Alias Systems"]
|
|
3
|
+
description: |
|
|
4
|
+
From Chap 8 Simulating Diffraction from GPU Gems https://developer.nvidia.com/gpugems/gpugems/part-i-natural-effects/chapter-8-simulating-diffraction
|
|
5
|
+
use: <vec3f> spectral_gems(<f32> x)
|
|
6
|
+
examples:
|
|
7
|
+
- https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/color_wavelength.frag
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import lygia::math::bump::bumpDefault3;
|
|
11
|
+
|
|
12
|
+
fn spectral_gems(x: f32) -> vec3f {
|
|
13
|
+
return bumpDefault3(vec3f(
|
|
14
|
+
4.0 * (x - 0.75), // Red
|
|
15
|
+
4.0 * (x - 0.5), // Green
|
|
16
|
+
4.0 * (x - 0.25) // Blue
|
|
17
|
+
));
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
contributors: none
|
|
3
|
+
description: attempt attempt spectrum approximation
|
|
4
|
+
use: <vec3f> spectral_geoffrey(<f32> x)
|
|
5
|
+
examples:
|
|
6
|
+
- https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/color_wavelength.frag
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
fn spectral_geoffrey(t: f32) -> vec3f {
|
|
10
|
+
let r = (t * 2.0 - 0.5) * 2.1 - vec3f(1.8, 1.14, 0.3);
|
|
11
|
+
return 0.99 - r * r;
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
contributors: Patricio Gonzalez Vivo
|
|
3
|
+
description: Attempt chroma spectrum
|
|
4
|
+
use: <vec3f> spectral_soft(<f32> value)
|
|
5
|
+
examples:
|
|
6
|
+
- https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/color_wavelength.frag
|
|
7
|
+
license:
|
|
8
|
+
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
|
|
9
|
+
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import lygia::math::consts::PI;
|
|
13
|
+
|
|
14
|
+
fn spectral_soft(x: f32) -> vec3f {
|
|
15
|
+
let delta = 0.5;
|
|
16
|
+
let freq = x * PI;
|
|
17
|
+
var color = vec3f(1.0);
|
|
18
|
+
color.r = sin(freq - delta);
|
|
19
|
+
color.g = sin(freq);
|
|
20
|
+
color.b = sin(freq + delta);
|
|
21
|
+
return pow(color, vec3f(4.0));
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
contributors: Alan Zucconi
|
|
3
|
+
description: |
|
|
4
|
+
Spectral Colour Schemes. Convert visible wavelengths of light (400-700 nm) to RGB colours http://www.alanzucconi.com/?p=6703
|
|
5
|
+
Its faster version than spectral_zucconi6 advised for mobile applications.
|
|
6
|
+
Read "Improving the Rainbow" for more information http://www.alanzucconi.com/?p=6703
|
|
7
|
+
Based on GPU Gems: https://developer.nvidia.com/sites/all/modules/custom/gpugems/books/GPUGems/gpugems_ch08.html
|
|
8
|
+
But with values optimised to match as close as possible the visible spectrum
|
|
9
|
+
Fits this: https://commons.wikimedia.org/wiki/File:Linear_visible_spectrum.svg
|
|
10
|
+
With weighter MSE (RGB weights: 0.3, 0.59, 0.11)
|
|
11
|
+
use: <vec3f> spectral_zucconi(<f32> x)
|
|
12
|
+
examples:
|
|
13
|
+
- https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/color_wavelength.frag
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import lygia::math::bump::bump3;
|
|
17
|
+
|
|
18
|
+
fn spectral_zucconi(x: f32) -> vec3f {
|
|
19
|
+
const cs = vec3f(3.54541723, 2.86670055, 2.29421995);
|
|
20
|
+
const xs = vec3f(0.69548916, 0.49416934, 0.28269708);
|
|
21
|
+
const ys = vec3f(0.02320775, 0.15936245, 0.53520021);
|
|
22
|
+
return bump3(cs * (x - xs), ys);
|
|
23
|
+
}
|