This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathTODO
83 lines (74 loc) · 2.79 KB
/
TODO
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Bool_Array : vectorized boolean operators
- vectorize `!a`
* `and`, `or` and `xor` are vectorized boolean monoids.
* <, <=, >, >= work elementwise on arrays.
* `are_equal(a,b)`: elementwise variant of a==b
* `are_unequal(a,b)`: elementwise variant of a!=b.
Elements are scalars (non-list values).
Equivalent to xor(a,b) when applied to boolean arrays.
* `select`: vectorized version of `if`
* vectorize `bit`. Maybe `bit b = select(b, 1, 0)`.
* SubCurv supports bool[2-4] and vectorized boolean ops
* unit tests for operations on reactive values
Bool32: ops on boolean vectors of size 32 -- for noise library
* All of the Bool_Array ops, plus the `Bool32` module.
* SubCurv supports bool32 type (represented as `unsigned`).
Libcurv builtins API
* Too much boilerplate to write this kind of code.
* Do more experiments with C++ before abandoning C++ for another language.
* Can builtins be implemented in Curv?
* The `and` project. What's the shortest, simplest implementation?
* Implement "full boilerplate" version in C++.
* Add bool[2-4] to SubCurv.
* Add bool32 to SubCurv.
* Now simplify and generalize the code.
* Create a generalized `monoid` constructor.
A macro call expands to a template call expands to a class.
Fix colour rendering (needs Bool_Array)
---------------------------------------
* colour_picker: convert between sRGB in the uniform variable,
and linear RGB in the Curv parameter.
* Use mathematically correct conversion between linRGB and sRGB.
* fragment shader outputs linear RGB, OpenGL converts to sRGB in hardware.
https://stackoverflow.com/questions/56204242/do-i-need-output-gamma-correction-in-a-fragment-shader
glEnable(GL_FRAMEBUFFER_SRGB);
https://www.khronos.org/opengl/wiki/Framebuffer#Colorspace
// from Blender (GLSL)
float linearrgb_to_srgb(float c)
{
if (c < 0.0031308) {
return (c < 0.0) ? 0.0 : c * 12.92;
}
else {
return 1.055 * pow(c, 1.0 / 2.4) - 0.055;
}
}
//// stack exchange:
float sRGB(float x) {
if (x <= 0.00031308)
return 12.92 * x;
else
return 1.055*pow(x,(1.0 / 2.4) ) - 0.055;
}
vec3 sRGB_v3(vec3 c) {
return vec3(sRGB(c.x),sRGB(c.y),sRGB(c.z));
}
//// stack exchange:
// Converts a color from linear light gamma to sRGB gamma
vec4 fromLinear(vec4 linearRGB)
{
bvec4 cutoff = lessThan(linearRGB, vec4(0.0031308));
vec4 higher = vec4(1.055)*pow(linearRGB, vec4(1.0/2.4)) - vec4(0.055);
vec4 lower = linearRGB * vec4(12.92);
return mix(higher, lower, cutoff);
}
// Converts a color from sRGB gamma to linear light gamma
vec4 toLinear(vec4 sRGB)
{
bvec4 cutoff = lessThan(sRGB, vec4(0.04045));
vec4 higher = pow((sRGB + vec4(0.055))/vec4(1.055), vec4(2.4));
vec4 lower = sRGB/vec4(12.92);
return mix(higher, lower, cutoff);
}
lessThan: all versions of GLSL
mix with bvec4 3rd argument: GLSL 4.5