-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGR_ColorBlindness_101
19 lines (19 loc) · 4.68 KB
/
GR_ColorBlindness_101
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
BlinkScript {
recompileCount 2
ProgramGroup 1
KernelDescription "2 \"color_blindnes_SIM\" iterate pixelWise 843417b0dac5c6f014e51ec41767a5592f7346eaf2c00b6d6e3753f164fe3025 2 \"src\" Read Point \"dst\" Write Point 4 \"_mode\" Int 1 AAAAAA== \"_invert\" Bool 1 AA== \"_mix\" Float 1 AAAAAA== \"_custom_M\" Float 9 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 4 \"_mode\" 1 1 \"_invert\" 1 1 \"_mix\" 1 1 \"_custom_M\" 9 1 0"
kernelSource "// color blindnes matrix 3x3 by \" http://www.colorjack.com/labs/colormatrix/\"\n// Normal:\{ R:\[100, 0, 0], G:\[0, 100, 0], B:\[0, 100, 0]\},\n// Protanopia:\{ R:\[56.667, 43.333, 0], G:\[55.833, 44.167, 0], B:\[0, 24.167, 75.833]\},\n// Protanomaly:\{ R:\[81.667, 18.333, 0], G:\[33.333, 66.667, 0], B:\[0, 12.5, 87.5]\},\n// Deuteranopia:\{ R:\[62.5, 37.5, 0], G:\[70, 30, 0], B:\[0, 30, 70]\},\n// Deuteranomaly:\{ R:\[80, 20, 0], G:\[25.833, 74.167, 0], B:\[0, 14.167, 85.833]\},\n// Tritanopia:\{ R:\[95, 5, 0], G:\[0, 43.333, 56.667], B:\[0, 47.5, 52.5]\},\n// Tritanomaly:\{ R:\[96.667, 3.333, 0], G:\[0, 73.333, 26.667], B:\[0, 18.333, 81.667]\},\n// Achromatopsia:\{ R:\[29.9, 58.7, 11.4], G:\[29.9, 58.7, 11.4], B:\[29.9, 58.7, 11.4]\},\n// Achromatomaly:\{ R:\[61.8, 32, 6.2], G:\[16.3, 77.5, 6.2], B:\[16.3, 32.0, 51.6]\}\n\n\n#define _NORMAL float3x3( 1.00000f, 0.00000f, 0.00000f, 0.00000f, 1.00000f, 0.00000f, 0.00000f, 0.00000f, 1.00000f )\n#define _PROTANOPIA float3x3( 0.56667f, 0.43333f, 0.00000f, 0.55833f, 0.44167f, 0.00000f, 0.00000f, 0.24167f, 0.75833f )\n#define _PROTANOMALY float3x3( 0.81667f, 0.18333f, 0.00000f, 0.33333f, 0.66667f, 0.00000f, 0.00000f, 0.12500f, 0.87500f )\n#define _DEUTERANOPIA float3x3( 0.62500f, 0.37500f, 0.00000f, 0.70000f, 0.30000f, 0.00000f, 0.00000f, 0.30000f, 0.70000f )\n#define _DEUTERANOMALY float3x3( 0.80000f, 0.20000f, 0.00000f, 0.25833f, 0.74167f, 0.00000f, 0.00000f, 0.14167f, 0.85833f )\n#define _TRIANOPIA float3x3( 0.95000f, 0.05000f, 0.00000f, 0.00000f, 0.43333f, 0.56667f, 0.00000f, 0.47500f, 0.52500f )\n#define _TRIANOMALY float3x3( 0.96667f, 0.03333f, 0.00000f, 0.00000f, 0.73333f, 0.26667f, 0.00000f, 0.18333f, 0.81667f )\n#define _ACHROMATOPSIA float3x3( 0.29900f, 0.58700f, 0.11400f, 0.29900f, 0.58700f, 0.11400f, 0.29900f, 0.58700f, 0.11400f )\n#define _ACHROMATOMALY float3x3( 0.61800f, 0.32000f, 0.06200f, 0.16300f, 0.77500f, 0.06200f, 0.16300f, 0.32000f, 0.51600f )\n\n\n\nfloat3 ColorMatrixTransform(float3 _IN, float3x3 _MAT, bool invert)\{\n float3x3 _M = invert == true ? _MAT.invert() : _MAT;\n \n float3x3 _MATRIX = float3x3( _IN.x * _M\[0]\[0], _IN.y * _M\[0]\[1], _IN.z * _M\[0]\[2],\n _IN.x * _M\[1]\[0], _IN.y * _M\[1]\[1], _IN.z * _M\[1]\[2],\n _IN.x * _M\[2]\[0], _IN.y * _M\[2]\[1], _IN.z * _M\[2]\[2]\n );\n\n float3 _OUT = float3( ( _MATRIX\[0]\[0] + _MATRIX\[0]\[1] + _MATRIX\[0]\[2] ),\n ( _MATRIX\[1]\[0] + _MATRIX\[1]\[1] + _MATRIX\[1]\[2] ),\n ( _MATRIX\[2]\[0] + _MATRIX\[2]\[1] + _MATRIX\[2]\[2] )\n );\n return _OUT;\n\}\n\nfloat3 mix(float3 _X,float3 _Y,float _A)\{\n return _X*(1.0f-_A)+_Y*_A;\n\}\n\n\nkernel color_blindnes_SIM : public ImageComputationKernel<ePixelWise>\n\{\n Image<eRead, eAccessPoint, eEdgeClamped> src;\n Image<eWrite, eAccessPoint> dst;\n\n param:\n int _mode;\n bool _invert;\n float _mix;\n float3x3 _custom_M;\n\n void process() \{\n\n float3x3 CB_MODE;\n\n if (_mode == 1)\n \{\n CB_MODE = _PROTANOPIA;\n \}else if(_mode == 2)\n \{\n CB_MODE = _PROTANOMALY;\n \}else if(_mode == 3)\n \{\n CB_MODE = _DEUTERANOPIA;\n \}else if(_mode == 4)\n \{\n CB_MODE = _DEUTERANOMALY;\n \}else if(_mode == 5)\n \{\n CB_MODE = _TRIANOPIA;\n \}else if(_mode == 6)\n \{\n CB_MODE = _TRIANOMALY;\n \}else if(_mode == 7)\n \{\n CB_MODE = _ACHROMATOPSIA;\n \}else if(_mode == 8)\n \{\n CB_MODE = _ACHROMATOMALY;\n \}else if(_mode == 9)\n \{\n CB_MODE = _custom_M;\n \}else\{\n CB_MODE = _NORMAL;\n \}\n\n float3 in_RGB = float3( src(0),src(1),src(2));\n float3 cb_RGB= ColorMatrixTransform( in_RGB, CB_MODE, _invert);\n float3 out_RGB = mix(in_RGB, cb_RGB, _mix);\n\n dst() = float4(out_RGB.x, out_RGB.y, out_RGB.z, src(3));\n \}\n\};"
useGPUIfAvailable false
vectorize false
rebuild ""
color_blindnes_SIM__mode 1
color_blindnes_SIM__mix 1
group_color_blindnes_SIM__custom_M 1
color_blindnes_SIM__custom_M {
{0 0 1}
{0 1 0}
{1 0 0}
}
rebuild_finalise ""
name GR_ColorBlindness_BlinkScript
}