| @@ -392,7 +392,7 @@ void BtPhysTest::tick_game(float seconds) | |||||
| return; | return; | ||||
| } | } | ||||
| auto context = Debug::DrawContext::New(Color::white, 1.f); | |||||
| auto context = Debug::DrawContext::New(color::white, 1.f); | |||||
| Debug::DrawGrid(vec3::zero, vec3::axis_x, vec3::axis_y, vec3::axis_z, 10.f); | Debug::DrawGrid(vec3::zero, vec3::axis_x, vec3::axis_y, vec3::axis_z, 10.f); | ||||
| if (input::keyboard()->key_released(input::key::SC_Escape)) | if (input::keyboard()->key_released(input::key::SC_Escape)) | ||||
| @@ -1,9 +1,9 @@ | |||||
| // | // | ||||
| // Lol Engine — Bullet physics test | // Lol Engine — Bullet physics test | ||||
| // | // | ||||
| // Copyright © 2009—2013 Cédric Lecacheur <jordx@free.fr> | |||||
| // Copyright © 2012—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // © 2009—2013 Cédric Lecacheur <jordx@free.fr> | |||||
| // © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | // © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | ||||
| // © 2012—2018 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -36,6 +36,32 @@ using namespace lol::phys; | |||||
| #define USE_CAPSULE 1 | #define USE_CAPSULE 1 | ||||
| #endif | #endif | ||||
| static vec4 hex_to_color(std::string const &s) | |||||
| { | |||||
| std::string c = s[0] == '#' ? &s[1] : s; | |||||
| uint32_t tmp = std::strtol(c.c_str(), nullptr, 16); | |||||
| if (c.length() == 3) | |||||
| { | |||||
| tmp = 0x11000000u * (tmp >> 8) | |||||
| | 0x00110000u * ((tmp >> 4) & 0xf) | |||||
| | 0x00001100u * (tmp & 0xf) | |||||
| | 0x000000ffu; | |||||
| } | |||||
| else if (c.length() == 4) | |||||
| { | |||||
| tmp = 0x11000000u * (tmp >> 12) | |||||
| | 0x00110000u * ((tmp >> 8) & 0xf) | |||||
| | 0x00001100u * ((tmp >> 4) & 0xf) | |||||
| | 0x00000011u * (tmp & 0xf); | |||||
| } | |||||
| else if (c.length() == 6) | |||||
| { | |||||
| tmp = 0xffu | 0x100u * tmp; | |||||
| } | |||||
| ivec4 v(tmp >> 24, (tmp >> 16) & 0xff, (tmp >> 8) & 0xff, tmp & 0xff); | |||||
| return vec4(v) * (1.f / 255.f); | |||||
| } | |||||
| class PhysicsObject : public WorldEntity | class PhysicsObject : public WorldEntity | ||||
| { | { | ||||
| public: | public: | ||||
| @@ -49,7 +75,7 @@ public: | |||||
| m_physics = new EasyPhysic(this); | m_physics = new EasyPhysic(this); | ||||
| //m_mesh.Compile("[sc#ddd afcb 60 1 60 -.1]"); | //m_mesh.Compile("[sc#ddd afcb 60 1 60 -.1]"); | ||||
| m_mesh.SetCurColor(Color::white); | |||||
| m_mesh.SetCurColor(color::white); | |||||
| m_mesh.AppendFlatChamfBox(vec3(60.f, 1.f, 60.f), -.1f); | m_mesh.AppendFlatChamfBox(vec3(60.f, 1.f, 60.f), -.1f); | ||||
| vec3 BoxSize = vec3(60.f, 1.f, 60.f); | vec3 BoxSize = vec3(60.f, 1.f, 60.f); | ||||
| @@ -155,12 +181,12 @@ public: | |||||
| while (colors.count()) | while (colors.count()) | ||||
| { | { | ||||
| EasyMesh m; | EasyMesh m; | ||||
| vec4 color = Color::C8BppHexString(colors.pop()); | |||||
| vec4 color = hex_to_color(colors.pop()); | |||||
| m.SetCurColor(color); | m.SetCurColor(color); | ||||
| m.AppendFlatChamfBox(vec3(1.7f), .4f); | m.AppendFlatChamfBox(vec3(1.7f), .4f); | ||||
| m.OpenBrace(); | m.OpenBrace(); | ||||
| { | { | ||||
| m.SetCurColor(Color::black); | |||||
| m.SetCurColor(color::black); | |||||
| m.ToggleScaleWinding(); | m.ToggleScaleWinding(); | ||||
| m.AppendFlatChamfBox(vec3(1.9f), .4f); | m.AppendFlatChamfBox(vec3(1.9f), .4f); | ||||
| m.ScaleX(-1.f); | m.ScaleX(-1.f); | ||||
| @@ -204,7 +230,7 @@ public: | |||||
| while (colors.count()) | while (colors.count()) | ||||
| { | { | ||||
| EasyMesh m; | EasyMesh m; | ||||
| vec4 color = Color::C8BppHexString(colors.pop()); | |||||
| vec4 color = hex_to_color(colors.pop()); | |||||
| m.SetCurColor(color); | m.SetCurColor(color); | ||||
| m.AppendSphere(1, 2.f); | m.AppendSphere(1, 2.f); | ||||
| MeshRand << m; | MeshRand << m; | ||||
| @@ -228,7 +254,7 @@ public: | |||||
| while (colors.count()) | while (colors.count()) | ||||
| { | { | ||||
| EasyMesh m; | EasyMesh m; | ||||
| vec4 color = Color::C8BppHexString(colors.pop()); | |||||
| vec4 color = hex_to_color(colors.pop()); | |||||
| m.SetCurColor(color); | m.SetCurColor(color); | ||||
| m.SetCurColorB(color); | m.SetCurColorB(color); | ||||
| m.AppendDisc(8, 2.f); | m.AppendDisc(8, 2.f); | ||||
| @@ -255,7 +281,7 @@ public: | |||||
| while (colors.count()) | while (colors.count()) | ||||
| { | { | ||||
| EasyMesh m; | EasyMesh m; | ||||
| vec4 color = Color::C8BppHexString(colors.pop()); | |||||
| vec4 color = hex_to_color(colors.pop()); | |||||
| m.SetCurColor(color); | m.SetCurColor(color); | ||||
| m.SetCurColorB(color); | m.SetCurColorB(color); | ||||
| m.AppendDisc(8, 2.f); | m.AppendDisc(8, 2.f); | ||||
| @@ -283,7 +309,7 @@ public: | |||||
| while (colors.count()) | while (colors.count()) | ||||
| { | { | ||||
| EasyMesh m; | EasyMesh m; | ||||
| vec4 color = Color::C8BppHexString(colors.pop()); | |||||
| vec4 color = hex_to_color(colors.pop()); | |||||
| m.SetCurColor(color); | m.SetCurColor(color); | ||||
| m.SetCurColorB(color); | m.SetCurColorB(color); | ||||
| m.AppendCapsule(1, 2.f, 1.f); | m.AppendCapsule(1, 2.f, 1.f); | ||||
| @@ -109,9 +109,9 @@ public: | |||||
| m_matrix = proj * view * model * anim; | m_matrix = proj * view * model * anim; | ||||
| { | { | ||||
| auto context0 = Debug::DrawContext::New(Color::red); | |||||
| auto context0 = Debug::DrawContext::New(color::red); | |||||
| { | { | ||||
| auto context1 = Debug::DrawContext::New(Color::blue); | |||||
| auto context1 = Debug::DrawContext::New(color::blue); | |||||
| Debug::DrawBox(box3(vec3(0.f), vec3(1.2f))); | Debug::DrawBox(box3(vec3(0.f), vec3(1.2f))); | ||||
| Debug::DrawGrid(vec3(0.f), vec3::axis_x, vec3::axis_y, vec3::axis_z, 10.0f); | Debug::DrawGrid(vec3(0.f), vec3::axis_x, vec3::axis_y, vec3::axis_z, 10.0f); | ||||
| { | { | ||||
| @@ -120,7 +120,7 @@ public: | |||||
| } | } | ||||
| { | { | ||||
| auto context2 = Debug::DrawContext::New(context0); | auto context2 = Debug::DrawContext::New(context0); | ||||
| context2.SetColor(Color::yellow); | |||||
| context2.SetColor(color::yellow); | |||||
| Debug::DrawBox(box3(vec3(-1.f), vec3(1.4f))); | Debug::DrawBox(box3(vec3(-1.f), vec3(1.4f))); | ||||
| } | } | ||||
| } | } | ||||
| @@ -74,7 +74,7 @@ public: | |||||
| vec3 hsv(lol::fmod(i * 0.001f, 1.f), | vec3 hsv(lol::fmod(i * 0.001f, 1.f), | ||||
| 0.3 * lol::sin(f * 0.27 + 2.0) + 0.3, | 0.3 * lol::sin(f * 0.27 + 2.0) + 0.3, | ||||
| 0.3 * lol::sin(f * 0.21 - 2.6) + 0.6); | 0.3 * lol::sin(f * 0.21 - 2.6) + 0.6); | ||||
| vec3 rgb = Color::HSVToRGB(hsv); | |||||
| vec3 rgb = color::hsv_to_rgb(hsv); | |||||
| if (f < 7.0) | if (f < 7.0) | ||||
| { | { | ||||
| @@ -1 +1 @@ | |||||
| Subproject commit 71d9bc1ec83979000547c5134a45d1ee8cb4b55e | |||||
| Subproject commit 02bb54bdf96af1ddacfa35b397c1caf7bf30e4e4 | |||||
| @@ -122,7 +122,6 @@ liblol_core_sources = \ | |||||
| image/codec/sdl-image.cpp image/codec/ios-image.cpp \ | image/codec/sdl-image.cpp image/codec/ios-image.cpp \ | ||||
| image/codec/zed-image.cpp image/codec/zed-palette-image.cpp \ | image/codec/zed-image.cpp image/codec/zed-palette-image.cpp \ | ||||
| image/codec/oric-image.cpp image/codec/dummy-image.cpp \ | image/codec/oric-image.cpp image/codec/dummy-image.cpp \ | ||||
| image/color/cie1931.cpp image/color/color.cpp \ | |||||
| image/dither/random.cpp image/dither/ediff.cpp image/dither/dbs.cpp \ | image/dither/random.cpp image/dither/ediff.cpp image/dither/dbs.cpp \ | ||||
| image/dither/ostromoukhov.cpp image/dither/ordered.cpp \ | image/dither/ostromoukhov.cpp image/dither/ordered.cpp \ | ||||
| image/filter/convolution.cpp image/filter/colors.cpp \ | image/filter/convolution.cpp image/filter/colors.cpp \ | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -75,15 +75,15 @@ void Debug::DrawLine(vec2 a, vec2 b, float az, float bz) { DrawLine(a, | |||||
| //-- GIZMO -------------------------------------------------------------------- | //-- GIZMO -------------------------------------------------------------------- | ||||
| void Debug::DrawGizmo(vec3 pos, vec3 x, vec3 y, vec3 z, float size) | void Debug::DrawGizmo(vec3 pos, vec3 x, vec3 y, vec3 z, float size) | ||||
| { | { | ||||
| Debug::DrawLine(pos, pos + x * size, Color::red); | |||||
| Debug::DrawLine(pos, pos + y * size, Color::green); | |||||
| Debug::DrawLine(pos, pos + z * size, Color::blue); | |||||
| Debug::DrawLine(pos, pos + x * size, color::red); | |||||
| Debug::DrawLine(pos, pos + y * size, color::green); | |||||
| Debug::DrawLine(pos, pos + z * size, color::blue); | |||||
| } | } | ||||
| void Debug::DrawGizmo(vec2 pos, vec3 x, vec3 y, vec3 z, float size, float posz) | void Debug::DrawGizmo(vec2 pos, vec3 x, vec3 y, vec3 z, float size, float posz) | ||||
| { | { | ||||
| Debug::DrawLine(pos, pos + x.xy * size, Color::red, posz, posz + x.z * size); | |||||
| Debug::DrawLine(pos, pos + y.xy * size, Color::green, posz, posz + y.z * size); | |||||
| Debug::DrawLine(pos, pos + z.xy * size, Color::blue, posz, posz + z.z * size); | |||||
| Debug::DrawLine(pos, pos + x.xy * size, color::red, posz, posz + x.z * size); | |||||
| Debug::DrawLine(pos, pos + y.xy * size, color::green, posz, posz + y.z * size); | |||||
| Debug::DrawLine(pos, pos + z.xy * size, color::blue, posz, posz + z.z * size); | |||||
| } | } | ||||
| //-- GRID --------------------------------------------------------------------- | //-- GRID --------------------------------------------------------------------- | ||||
| @@ -95,9 +95,9 @@ void Debug::DrawGrid(vec3 pos, vec3 x, vec3 y, vec3 z, float size, bool draw_3d) | |||||
| //Draw Gizmo | //Draw Gizmo | ||||
| Debug::DrawGizmo(pos, x, y, z, size); | Debug::DrawGizmo(pos, x, y, z, size); | ||||
| Debug::DrawLine(pos, pos - x * size, Color::gray); | |||||
| Debug::DrawLine(pos, pos - y * size, Color::gray); | |||||
| Debug::DrawLine(pos, pos - z * size, Color::gray); | |||||
| Debug::DrawLine(pos, pos - x * size, color::gray); | |||||
| Debug::DrawLine(pos, pos - y * size, color::gray); | |||||
| Debug::DrawLine(pos, pos - z * size, color::gray); | |||||
| //grid | //grid | ||||
| for (float i = (float)-seg_nb; i <= seg_nb; i++) | for (float i = (float)-seg_nb; i <= seg_nb; i++) | ||||
| @@ -105,16 +105,16 @@ void Debug::DrawGrid(vec3 pos, vec3 x, vec3 y, vec3 z, float size, bool draw_3d) | |||||
| if (i != 0) | if (i != 0) | ||||
| { | { | ||||
| float iter = seg_sz * ((float)i); | float iter = seg_sz * ((float)i); | ||||
| Debug::DrawLine(vec3(-size, 0, iter), vec3(size, 0, iter), Color::dark_gray); | |||||
| Debug::DrawLine(vec3(iter, 0, -size), vec3(iter, 0, size), Color::dark_gray); | |||||
| Debug::DrawLine(vec3(-size, 0, iter), vec3(size, 0, iter), color::dark_gray); | |||||
| Debug::DrawLine(vec3(iter, 0, -size), vec3(iter, 0, size), color::dark_gray); | |||||
| if (draw_3d) | if (draw_3d) | ||||
| { | { | ||||
| Debug::DrawLine(vec3(0, -size, iter), vec3(0, size, iter), Color::dark_gray); | |||||
| Debug::DrawLine(vec3(0, iter, -size), vec3(0, iter, size), Color::dark_gray); | |||||
| Debug::DrawLine(vec3(0, -size, iter), vec3(0, size, iter), color::dark_gray); | |||||
| Debug::DrawLine(vec3(0, iter, -size), vec3(0, iter, size), color::dark_gray); | |||||
| Debug::DrawLine(vec3(-size, iter, 0), vec3(size, iter, 0), Color::dark_gray); | |||||
| Debug::DrawLine(vec3(iter, -size, 0), vec3(iter, size, 0), Color::dark_gray); | |||||
| Debug::DrawLine(vec3(-size, iter, 0), vec3(size, iter, 0), color::dark_gray); | |||||
| Debug::DrawLine(vec3(iter, -size, 0), vec3(iter, size, 0), color::dark_gray); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,13 +1,15 @@ | |||||
| // | // | ||||
| // EasyMesh-Cursor: The code belonging to Cursor operations | |||||
| // EasyMesh-Cursor — Cursor operations | |||||
| // | // | ||||
| // Copyright: (c) 2010-2015 Sam Hocevar <sam@hocevar.net> | |||||
| // (c) 2009-2015 Cédric Lecacheur <jordx@free.fr> | |||||
| // (c) 2009-2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com> | |||||
| // This program is free software; you can redistribute it and/or | |||||
| // modify it under the terms of the Do What The Fuck You Want To | |||||
| // Public License, Version 2, as published by Sam Hocevar. See | |||||
| // http://www.wtfpl.net/ for more details. | |||||
| // Copyright © 2012—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // © 2009—2015 Cédric Lecacheur <jordx@free.fr> | |||||
| // © 2009—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||||
| // | |||||
| // Lol Engine is free software. It comes without any warranty, to | |||||
| // the extent permitted by applicable law. You can redistribute it | |||||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||||
| // See http://www.wtfpl.net/ for more details. | |||||
| // | // | ||||
| #include <lol/engine-internal.h> | #include <lol/engine-internal.h> | ||||
| @@ -129,50 +131,50 @@ void EasyMesh::ToggleVerticeNoCleanup() | |||||
| } | } | ||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
| void EasyMesh::SetCurColor(vec4 const &color) | |||||
| void EasyMesh::SetCurColor(vec4 const &col) | |||||
| { | { | ||||
| SetCurColorA(color); | |||||
| SetCurColorB(color); | |||||
| SetCurColorA(col); | |||||
| SetCurColorB(col); | |||||
| } | } | ||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
| void EasyMesh::SetCurColorA(vec4 const &color) | |||||
| void EasyMesh::SetCurColorA(vec4 const &col) | |||||
| { | { | ||||
| if (BD()->IsEnabled(MeshBuildOperation::CommandRecording)) | if (BD()->IsEnabled(MeshBuildOperation::CommandRecording)) | ||||
| { | { | ||||
| BD()->CmdStack().AddCmd(EasyMeshCmdType::SetColorA); | BD()->CmdStack().AddCmd(EasyMeshCmdType::SetColorA); | ||||
| BD()->CmdStack() << color; | |||||
| BD()->CmdStack() << col; | |||||
| return; | return; | ||||
| } | } | ||||
| BD()->ColorA() = color; | |||||
| BD()->ColorA() = col; | |||||
| } | } | ||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
| void EasyMesh::SetCurColorB(vec4 const &color) | |||||
| void EasyMesh::SetCurColorB(vec4 const &col) | |||||
| { | { | ||||
| if (BD()->IsEnabled(MeshBuildOperation::CommandRecording)) | if (BD()->IsEnabled(MeshBuildOperation::CommandRecording)) | ||||
| { | { | ||||
| BD()->CmdStack().AddCmd(EasyMeshCmdType::SetColorB); | BD()->CmdStack().AddCmd(EasyMeshCmdType::SetColorB); | ||||
| BD()->CmdStack() << color; | |||||
| BD()->CmdStack() << col; | |||||
| return; | return; | ||||
| } | } | ||||
| BD()->ColorB() = color; | |||||
| BD()->ColorB() = col; | |||||
| } | } | ||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
| void EasyMesh::SetVertColor(vec4 const &color) | |||||
| void EasyMesh::SetVertColor(vec4 const &col) | |||||
| { | { | ||||
| if (BD()->IsEnabled(MeshBuildOperation::CommandRecording)) | if (BD()->IsEnabled(MeshBuildOperation::CommandRecording)) | ||||
| { | { | ||||
| BD()->CmdStack().AddCmd(EasyMeshCmdType::SetVertColor); | BD()->CmdStack().AddCmd(EasyMeshCmdType::SetVertColor); | ||||
| BD()->CmdStack() << color; | |||||
| BD()->CmdStack() << col; | |||||
| return; | return; | ||||
| } | } | ||||
| for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | for (int i = m_cursors.last().m1; i < m_vert.count(); i++) | ||||
| m_vert[i].m_color = color; | |||||
| m_vert[i].m_color = col; | |||||
| } | } | ||||
| } /* namespace lol */ | } /* namespace lol */ | ||||
| @@ -1,13 +1,15 @@ | |||||
| // | // | ||||
| // EasyMesh-Internal: The code belonging to internal operations | |||||
| // EasyMesh-Internal— Internal operations | |||||
| // | // | ||||
| // Copyright: (c) 2010-2015 Sam Hocevar <sam@hocevar.net> | |||||
| // (c) 2009-2015 Cédric Lecacheur <jordx@free.fr> | |||||
| // (c) 2009-2015 Benjamin "Touky" Huet <huet.benjamin@gmail.com> | |||||
| // This program is free software; you can redistribute it and/or | |||||
| // modify it under the terms of the Do What The Fuck You Want To | |||||
| // Public License, Version 2, as published by Sam Hocevar. See | |||||
| // http://www.wtfpl.net/ for more details. | |||||
| // Copyright © 2012—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // © 2009—2015 Cédric Lecacheur <jordx@free.fr> | |||||
| // © 2009—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||||
| // | |||||
| // Lol Engine is free software. It comes without any warranty, to | |||||
| // the extent permitted by applicable law. You can redistribute it | |||||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||||
| // See http://www.wtfpl.net/ for more details. | |||||
| // | // | ||||
| #include <lol/engine-internal.h> | #include <lol/engine-internal.h> | ||||
| @@ -480,9 +482,9 @@ void EasyMesh::SetCurVertNormal(vec3 const &normal) | |||||
| } | } | ||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
| void EasyMesh::SetCurVertColor(vec4 const &color) | |||||
| void EasyMesh::SetCurVertColor(vec4 const &col) | |||||
| { | { | ||||
| m_vert.last().m_color = color; | |||||
| m_vert.last().m_color = col; | |||||
| } | } | ||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -123,12 +123,12 @@ ibox2 render_context::viewport() | |||||
| return m_renderer->viewport(); | return m_renderer->viewport(); | ||||
| } | } | ||||
| void render_context::clear_color(vec4 color) | |||||
| void render_context::clear_color(vec4 c) | |||||
| { | { | ||||
| if (!m_data->m_clear_color.is_dirty()) | if (!m_data->m_clear_color.is_dirty()) | ||||
| m_data->m_clear_color.set(m_renderer->clear_color()); | m_data->m_clear_color.set(m_renderer->clear_color()); | ||||
| m_renderer->clear_color(color); | |||||
| m_renderer->clear_color(c); | |||||
| } | } | ||||
| vec4 render_context::clear_color() | vec4 render_context::clear_color() | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -172,14 +172,14 @@ float Renderer::yx_ratio() const | |||||
| * Clear color | * Clear color | ||||
| */ | */ | ||||
| void Renderer::clear_color(vec4 color) | |||||
| void Renderer::clear_color(vec4 c) | |||||
| { | { | ||||
| if (m_data->m_clear_color == color) | |||||
| if (m_data->m_clear_color == c) | |||||
| return; | return; | ||||
| glClearColor(color.r, color.g, color.b, color.a); | |||||
| glClearColor(c.r, c.g, c.b, c.a); | |||||
| m_data->m_clear_color = color; | |||||
| m_data->m_clear_color = c; | |||||
| } | } | ||||
| vec4 Renderer::clear_color() const | vec4 Renderer::clear_color() const | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -62,19 +62,19 @@ void Gradient::tick_draw(float seconds, Scene &scene) | |||||
| m_aabb.aa.x, m_aabb.bb.y, 0.0f, | m_aabb.aa.x, m_aabb.bb.y, 0.0f, | ||||
| m_aabb.bb.x, m_aabb.aa.y, 0.0f, }; | m_aabb.bb.x, m_aabb.aa.y, 0.0f, }; | ||||
| float const color[] = { 0.73f, 0.85f, 0.85f, 1.0f, | |||||
| 0.73f, 0.85f, 0.85f, 1.0f, | |||||
| 0.0f, 0.0f, 1.0f, 1.0f, | |||||
| 0.0f, 0.0f, 1.0f, 1.0f, | |||||
| 0.0f, 0.0f, 1.0f, 1.0f, | |||||
| 0.73f, 0.85f, 0.85f, 1.0f, }; | |||||
| float const colors[] = { 0.73f, 0.85f, 0.85f, 1.0f, | |||||
| 0.73f, 0.85f, 0.85f, 1.0f, | |||||
| 0.0f, 0.0f, 1.0f, 1.0f, | |||||
| 0.0f, 0.0f, 1.0f, 1.0f, | |||||
| 0.0f, 0.0f, 1.0f, 1.0f, | |||||
| 0.73f, 0.85f, 0.85f, 1.0f, }; | |||||
| if (!data->shader) | if (!data->shader) | ||||
| { | { | ||||
| data->shader = Shader::Create(LOLFX_RESOURCE_NAME(gradient)); | data->shader = Shader::Create(LOLFX_RESOURCE_NAME(gradient)); | ||||
| data->m_vbo = std::make_shared<VertexBuffer>(sizeof(vertex)); | data->m_vbo = std::make_shared<VertexBuffer>(sizeof(vertex)); | ||||
| data->m_cbo = std::make_shared<VertexBuffer>(sizeof(color)); | |||||
| data->m_cbo = std::make_shared<VertexBuffer>(sizeof(colors)); | |||||
| data->m_vdecl = std::make_shared<VertexDeclaration> | data->m_vdecl = std::make_shared<VertexDeclaration> | ||||
| (VertexStream<vec3>(VertexUsage::Position), | (VertexStream<vec3>(VertexUsage::Position), | ||||
| @@ -101,7 +101,7 @@ void Gradient::tick_draw(float seconds, Scene &scene) | |||||
| data->m_vdecl->Bind(); | data->m_vdecl->Bind(); | ||||
| data->m_vbo->set_data(vertex, sizeof(vertex)); | data->m_vbo->set_data(vertex, sizeof(vertex)); | ||||
| data->m_cbo->set_data(color, sizeof(color)); | |||||
| data->m_cbo->set_data(colors, sizeof(colors)); | |||||
| /* Bind vertex and color buffers */ | /* Bind vertex and color buffers */ | ||||
| data->m_vdecl->SetStream(data->m_vbo, attr_pos); | data->m_vdecl->SetStream(data->m_vbo, attr_pos); | ||||
| @@ -1,595 +0,0 @@ | |||||
| // | |||||
| // Lol Engine | |||||
| // | |||||
| // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||||
| // This program is free software; you can redistribute it and/or | |||||
| // modify it under the terms of the Do What The Fuck You Want To | |||||
| // Public License, Version 2, as published by Sam Hocevar. See | |||||
| // http://www.wtfpl.net/ for more details. | |||||
| // | |||||
| #include <lol/engine-internal.h> | |||||
| /* | |||||
| * This file contains code and data related to various CIE standards. | |||||
| * - the CIE-1931 Standard Colorimetric Observer data | |||||
| * - the CIE-1964 Standard Colorimetric Observer data | |||||
| * - the CIEDE2000 metric | |||||
| */ | |||||
| namespace lol | |||||
| { | |||||
| float Color::DistanceCIEDE2000(vec3 lab1, vec3 lab2) | |||||
| { | |||||
| float C1 = length(lab1.yz); | |||||
| float C2 = length(lab2.yz); | |||||
| float C_ = 0.5f * (C1 + C2); | |||||
| float L1 = lab1.x; | |||||
| float L2 = lab2.x; | |||||
| float dLp = L2 - L1; | |||||
| float L_ = 0.5f * (L1 + L2); | |||||
| float tmp1 = pow(C_, 7.f); | |||||
| float tmp2 = 1.5f - 0.5f * sqrt(tmp1 / (tmp1 + pow(25.f, 7.f))); | |||||
| float ap1 = lab1.y * tmp2; | |||||
| float ap2 = lab2.y * tmp2; | |||||
| float Cp1 = sqrt(ap1 * ap1 + lab1.z * lab1.z); | |||||
| float Cp2 = sqrt(ap2 * ap2 + lab2.z * lab2.z); | |||||
| float dCp = Cp2 - Cp1; | |||||
| float Cp_ = 0.5f * (Cp1 + Cp2); | |||||
| float hp1 = atan2(lab1.z, ap1); | |||||
| float hp2 = atan2(lab2.z, ap2); | |||||
| float dhp = fmod(hp2 - hp1 + 3.f * F_PI, 2.f * F_PI) - F_PI; /* -pi .. pi */ | |||||
| float dHp = 2.f * sqrt(Cp1 * Cp2) * sin(0.5f * dhp); | |||||
| float Hp_ = (Cp1 && Cp2) ? fmod(hp1 + 0.5f * dhp + 2.f * F_PI, 2.f * F_PI) : hp1 + hp2; /* 0 .. 2pi */ | |||||
| float T = 1.f - 0.17f * cos(Hp_ - F_PI / 6.f) | |||||
| + 0.24f * cos(2.f * Hp_) | |||||
| + 0.32f * cos(3.f * Hp_ + F_PI / 30.f) | |||||
| - 0.20f * cos(4.f * Hp_ - 0.35f * F_PI); | |||||
| float SL = 1.f + 0.015f * (L_ - 50) * (L_ - 50) | |||||
| / sqrt(20.f + (L_ - 50) * (L_ - 50)); | |||||
| float SC = 1.f + 0.045f * Cp_; | |||||
| float SH = 1.f + 0.015f * Cp_ * T; | |||||
| float RT = -2.f * sqrt(pow(Cp_, 7.f) / (pow(Cp_, 7.f) + pow(25.f, 7.f))) | |||||
| * sin(F_PI / 3.f * exp(-pow((Hp_ * 180.f / F_PI - 275.f) / 25.f, 2.f))); | |||||
| dLp /= SL; | |||||
| dCp /= SC; | |||||
| dHp /= SH; | |||||
| return sqrt(dLp * dLp + dCp * dCp + dHp * dHp + RT * dCp * dHp); | |||||
| } | |||||
| /* CIE 1931 Standard Colorimetric Observer, aka. 2º Observer | |||||
| * for wavelengths 360 to 830. */ | |||||
| static float cie_1931_xyz[] = | |||||
| { | |||||
| /* 360 — 399 nm */ | |||||
| 0.0001299f, 3.917e-06f, 0.0006061f, 0.0001458f, 4.394e-06f, 0.0006809f, | |||||
| 0.0001638f, 4.930e-06f, 0.0007651f, 0.0001840f, 5.532e-06f, 0.0008600f, | |||||
| 0.0002067f, 6.208e-06f, 0.0009666f, 0.0002321f, 6.965e-06f, 0.0010860f, | |||||
| 0.0002607f, 7.813e-06f, 0.0012206f, 0.0002931f, 8.767e-06f, 0.0013727f, | |||||
| 0.0003294f, 9.840e-06f, 0.0015436f, 0.0003699f, 1.104e-05f, 0.0017343f, | |||||
| 0.0004149f, 1.239e-05f, 0.0019460f, 0.0004642f, 1.389e-05f, 0.0021778f, | |||||
| 0.0005190f, 1.556e-05f, 0.0024358f, 0.0005819f, 1.744e-05f, 0.0027320f, | |||||
| 0.0006552f, 1.958e-05f, 0.0030781f, 0.0007416f, 2.202e-05f, 0.0034860f, | |||||
| 0.0008450f, 2.484e-05f, 0.0039752f, 0.0009645f, 2.804e-05f, 0.0045409f, | |||||
| 0.0010949f, 3.153e-05f, 0.0051583f, 0.0012312f, 3.522e-05f, 0.0058029f, | |||||
| 0.0013680f, 3.900e-05f, 0.0064500f, 0.0015021f, 4.283e-05f, 0.0070832f, | |||||
| 0.0016423f, 4.691e-05f, 0.0077455f, 0.0018024f, 5.159e-05f, 0.0085012f, | |||||
| 0.0019958f, 5.718e-05f, 0.0094145f, 0.0022360f, 6.400e-05f, 0.0105500f, | |||||
| 0.0025354f, 7.234e-05f, 0.0119658f, 0.0028926f, 8.221e-05f, 0.0136559f, | |||||
| 0.0033008f, 9.351e-05f, 0.0155881f, 0.0037532f, 0.0001061f, 0.0177302f, | |||||
| 0.0042430f, 0.0001200f, 0.0200500f, 0.0047624f, 0.0001350f, 0.0225114f, | |||||
| 0.0053300f, 0.0001515f, 0.0252029f, 0.0059787f, 0.0001702f, 0.0282797f, | |||||
| 0.0067411f, 0.0001918f, 0.0318970f, 0.0076500f, 0.0002170f, 0.0362100f, | |||||
| 0.0087514f, 0.0002469f, 0.0414377f, 0.0100289f, 0.0002812f, 0.0475037f, | |||||
| 0.0114217f, 0.0003185f, 0.0541199f, 0.0128690f, 0.0003573f, 0.0609980f, | |||||
| /* 400 — 439 nm */ | |||||
| 0.0143100f, 0.0003960f, 0.0678500f, 0.0157044f, 0.0004337f, 0.0744863f, | |||||
| 0.0171474f, 0.0004730f, 0.0813616f, 0.0187812f, 0.0005179f, 0.0891536f, | |||||
| 0.0207480f, 0.0005722f, 0.0985405f, 0.0231900f, 0.0006400f, 0.1102000f, | |||||
| 0.0262074f, 0.0007246f, 0.1246133f, 0.0297825f, 0.0008255f, 0.1417017f, | |||||
| 0.0338809f, 0.0009412f, 0.1613035f, 0.0384682f, 0.0010699f, 0.1832568f, | |||||
| 0.0435100f, 0.0012100f, 0.2074000f, 0.0489956f, 0.0013621f, 0.2336921f, | |||||
| 0.0550226f, 0.0015308f, 0.2626114f, 0.0617188f, 0.0017204f, 0.2947746f, | |||||
| 0.0692120f, 0.0019353f, 0.3307985f, 0.0776300f, 0.0021800f, 0.3713000f, | |||||
| 0.0869581f, 0.0024548f, 0.4162091f, 0.0971767f, 0.0027640f, 0.4654642f, | |||||
| 0.1084063f, 0.0031178f, 0.5196948f, 0.1207672f, 0.0035264f, 0.5795303f, | |||||
| 0.1343800f, 0.0040000f, 0.6456000f, 0.1493582f, 0.0045462f, 0.7184838f, | |||||
| 0.1653957f, 0.0051593f, 0.7967133f, 0.1819831f, 0.0058293f, 0.8778459f, | |||||
| 0.1986110f, 0.0065462f, 0.9594390f, 0.2147700f, 0.0073000f, 1.0390501f, | |||||
| 0.2301868f, 0.0080865f, 1.1153673f, 0.2448797f, 0.0089087f, 1.1884971f, | |||||
| 0.2587773f, 0.0097677f, 1.2581233f, 0.2718079f, 0.0106644f, 1.3239296f, | |||||
| 0.2839000f, 0.0116000f, 1.3856000f, 0.2949438f, 0.0125732f, 1.4426352f, | |||||
| 0.3048965f, 0.0135827f, 1.4948035f, 0.3137873f, 0.0146297f, 1.5421903f, | |||||
| 0.3216454f, 0.0157151f, 1.5848807f, 0.3285000f, 0.0168400f, 1.6229600f, | |||||
| 0.3343513f, 0.0180074f, 1.6564048f, 0.3392101f, 0.0192145f, 1.6852959f, | |||||
| 0.3431213f, 0.0204539f, 1.7098745f, 0.3461296f, 0.0217182f, 1.7303821f, | |||||
| /* 440 — 479 nm */ | |||||
| 0.3482800f, 0.0230000f, 1.7470600f, 0.3495999f, 0.0242946f, 1.7600446f, | |||||
| 0.3501474f, 0.0256102f, 1.7696233f, 0.3500130f, 0.0269586f, 1.7762637f, | |||||
| 0.3492870f, 0.0283513f, 1.7804334f, 0.3480600f, 0.0298000f, 1.7826000f, | |||||
| 0.3463733f, 0.0313108f, 1.7829682f, 0.3442624f, 0.0328837f, 1.7816998f, | |||||
| 0.3418088f, 0.0345211f, 1.7791982f, 0.3390941f, 0.0362257f, 1.7758671f, | |||||
| 0.3362000f, 0.0380000f, 1.7721100f, 0.3331977f, 0.0398467f, 1.7682589f, | |||||
| 0.3300411f, 0.0417680f, 1.7640390f, 0.3266357f, 0.0437660f, 1.7589438f, | |||||
| 0.3228868f, 0.0458427f, 1.7524663f, 0.3187000f, 0.0480000f, 1.7441000f, | |||||
| 0.3140251f, 0.0502437f, 1.7335595f, 0.3088840f, 0.0525730f, 1.7208581f, | |||||
| 0.3032904f, 0.0549806f, 1.7059369f, 0.2972579f, 0.0574587f, 1.6887372f, | |||||
| 0.2908000f, 0.0600000f, 1.6692000f, 0.2839701f, 0.0626020f, 1.6475287f, | |||||
| 0.2767214f, 0.0652775f, 1.6234127f, 0.2689178f, 0.0680421f, 1.5960223f, | |||||
| 0.2604227f, 0.0709111f, 1.5645280f, 0.2511000f, 0.0739000f, 1.5281000f, | |||||
| 0.2408475f, 0.0770160f, 1.4861114f, 0.2298512f, 0.0802664f, 1.4395215f, | |||||
| 0.2184072f, 0.0836668f, 1.3898799f, 0.2068115f, 0.0872328f, 1.3387362f, | |||||
| 0.1953600f, 0.0909800f, 1.2876400f, 0.1842136f, 0.0949176f, 1.2374223f, | |||||
| 0.1733273f, 0.0990458f, 1.1878243f, 0.1626881f, 0.1033674f, 1.1387611f, | |||||
| 0.1522833f, 0.1078846f, 1.0901480f, 0.1421000f, 0.1126000f, 1.0419000f, | |||||
| 0.1321786f, 0.1175320f, 0.9941976f, 0.1225696f, 0.1226744f, 0.9473473f, | |||||
| 0.1132752f, 0.1279928f, 0.9014531f, 0.1042979f, 0.1334528f, 0.8566193f, | |||||
| /* 480 — 519 nm */ | |||||
| 0.0956400f, 0.1390200f, 0.8129501f, 0.0872996f, 0.1446764f, 0.7705173f, | |||||
| 0.0793080f, 0.1504693f, 0.7294448f, 0.0717178f, 0.1564619f, 0.6899136f, | |||||
| 0.0645810f, 0.1627177f, 0.6521049f, 0.0579500f, 0.1693000f, 0.6162000f, | |||||
| 0.0518621f, 0.1762431f, 0.5823286f, 0.0462815f, 0.1835581f, 0.5504162f, | |||||
| 0.0411509f, 0.1912735f, 0.5203376f, 0.0364128f, 0.1994180f, 0.4919673f, | |||||
| 0.0320100f, 0.2080200f, 0.4651800f, 0.0279172f, 0.2171199f, 0.4399246f, | |||||
| 0.0241444f, 0.2267345f, 0.4161836f, 0.0206870f, 0.2368571f, 0.3938822f, | |||||
| 0.0175404f, 0.2474812f, 0.3729459f, 0.0147000f, 0.2586000f, 0.3533000f, | |||||
| 0.0121618f, 0.2701849f, 0.3348578f, 0.0099200f, 0.2822939f, 0.3175521f, | |||||
| 0.0079672f, 0.2950505f, 0.3013375f, 0.0062963f, 0.3085780f, 0.2861686f, | |||||
| 0.0049000f, 0.3230000f, 0.2720000f, 0.0037772f, 0.3384021f, 0.2588171f, | |||||
| 0.0029453f, 0.3546858f, 0.2464838f, 0.0024249f, 0.3716986f, 0.2347718f, | |||||
| 0.0022363f, 0.3892875f, 0.2234533f, 0.0024000f, 0.4073000f, 0.2123000f, | |||||
| 0.0029255f, 0.4256299f, 0.2011692f, 0.0038366f, 0.4443096f, 0.1901196f, | |||||
| 0.0051748f, 0.4633944f, 0.1792254f, 0.0069821f, 0.4829395f, 0.1685608f, | |||||
| 0.0093000f, 0.5030000f, 0.1582000f, 0.0121495f, 0.5235693f, 0.1481383f, | |||||
| 0.0155359f, 0.5445120f, 0.1383758f, 0.0194775f, 0.5656900f, 0.1289942f, | |||||
| 0.0239928f, 0.5869653f, 0.1200751f, 0.0291000f, 0.6082000f, 0.1117000f, | |||||
| 0.0348149f, 0.6293456f, 0.1039048f, 0.0411202f, 0.6503068f, 0.0966675f, | |||||
| 0.0479850f, 0.6708752f, 0.0899827f, 0.0553786f, 0.6908424f, 0.0838453f, | |||||
| /* 520 — 559 nm */ | |||||
| 0.0632700f, 0.7100000f, 0.0782500f, 0.0716350f, 0.7281852f, 0.0732090f, | |||||
| 0.0804622f, 0.7454636f, 0.0686782f, 0.0897400f, 0.7619694f, 0.0645678f, | |||||
| 0.0994565f, 0.7778368f, 0.0607884f, 0.1096000f, 0.7932000f, 0.0572500f, | |||||
| 0.1201674f, 0.8081104f, 0.0539044f, 0.1311145f, 0.8224962f, 0.0507466f, | |||||
| 0.1423679f, 0.8363068f, 0.0477528f, 0.1538542f, 0.8494916f, 0.0448986f, | |||||
| 0.1655000f, 0.8620000f, 0.0421600f, 0.1772571f, 0.8738108f, 0.0395073f, | |||||
| 0.1891400f, 0.8849624f, 0.0369356f, 0.2011694f, 0.8954936f, 0.0344584f, | |||||
| 0.2133658f, 0.9054432f, 0.0320887f, 0.2257499f, 0.9148501f, 0.0298400f, | |||||
| 0.2383209f, 0.9237348f, 0.0277118f, 0.2510668f, 0.9320924f, 0.0256944f, | |||||
| 0.2639922f, 0.9399226f, 0.0237872f, 0.2771017f, 0.9472252f, 0.0219893f, | |||||
| 0.2904000f, 0.9540000f, 0.0203000f, 0.3038912f, 0.9602561f, 0.0187181f, | |||||
| 0.3175726f, 0.9660074f, 0.0172404f, 0.3314384f, 0.9712606f, 0.0158636f, | |||||
| 0.3454828f, 0.9760225f, 0.0145846f, 0.3597000f, 0.9803000f, 0.0134000f, | |||||
| 0.3740839f, 0.9840924f, 0.0123072f, 0.3886396f, 0.9874182f, 0.0113019f, | |||||
| 0.4033784f, 0.9903128f, 0.0103779f, 0.4183115f, 0.9928116f, 0.0095293f, | |||||
| 0.4334499f, 0.9949501f, 0.0087500f, 0.4487953f, 0.9967108f, 0.0080352f, | |||||
| 0.4643360f, 0.9980983f, 0.0073816f, 0.4800640f, 0.9991120f, 0.0067854f, | |||||
| 0.4959713f, 0.9997482f, 0.0062428f, 0.5120501f, 1.0000000f, 0.0057500f, | |||||
| 0.5282959f, 0.9998567f, 0.0053036f, 0.5446916f, 0.9993046f, 0.0048998f, | |||||
| 0.5612094f, 0.9983255f, 0.0045342f, 0.5778215f, 0.9968987f, 0.0042024f, | |||||
| /* 560 — 599 nm */ | |||||
| 0.5945000f, 0.9950000f, 0.0039000f, 0.6112209f, 0.9926005f, 0.0036232f, | |||||
| 0.6279758f, 0.9897426f, 0.0033706f, 0.6447602f, 0.9864444f, 0.0031414f, | |||||
| 0.6615697f, 0.9827241f, 0.0029348f, 0.6784000f, 0.9786000f, 0.0027500f, | |||||
| 0.6952392f, 0.9740837f, 0.0025852f, 0.7120586f, 0.9691712f, 0.0024386f, | |||||
| 0.7288284f, 0.9638568f, 0.0023094f, 0.7455188f, 0.9581349f, 0.0021968f, | |||||
| 0.7621000f, 0.9520000f, 0.0021000f, 0.7785432f, 0.9454504f, 0.0020177f, | |||||
| 0.7948256f, 0.9384992f, 0.0019482f, 0.8109264f, 0.9311628f, 0.0018898f, | |||||
| 0.8268248f, 0.9234576f, 0.0018409f, 0.8425000f, 0.9154000f, 0.0018000f, | |||||
| 0.8579325f, 0.9070064f, 0.0017663f, 0.8730816f, 0.8982772f, 0.0017378f, | |||||
| 0.8878944f, 0.8892048f, 0.0017112f, 0.9023181f, 0.8797816f, 0.0016831f, | |||||
| 0.9163000f, 0.8700000f, 0.0016500f, 0.9297995f, 0.8598613f, 0.0016101f, | |||||
| 0.9427984f, 0.8493920f, 0.0015644f, 0.9552776f, 0.8386220f, 0.0015136f, | |||||
| 0.9672179f, 0.8275813f, 0.0014585f, 0.9786000f, 0.8163000f, 0.0014000f, | |||||
| 0.9893856f, 0.8047947f, 0.0013367f, 0.9995488f, 0.7930820f, 0.0012700f, | |||||
| 1.0090892f, 0.7811920f, 0.0012050f, 1.0180064f, 0.7691547f, 0.0011467f, | |||||
| 1.0263000f, 0.7570000f, 0.0011000f, 1.0339827f, 0.7447541f, 0.0010688f, | |||||
| 1.0409860f, 0.7324224f, 0.0010494f, 1.0471880f, 0.7200036f, 0.0010356f, | |||||
| 1.0524667f, 0.7074965f, 0.0010212f, 1.0567000f, 0.6949000f, 0.0010000f, | |||||
| 1.0597944f, 0.6822192f, 0.0009686f, 1.0617992f, 0.6694716f, 0.0009299f, | |||||
| 1.0628068f, 0.6566744f, 0.0008869f, 1.0629096f, 0.6438448f, 0.0008426f, | |||||
| /* 600 — 639 nm */ | |||||
| 1.0622000f, 0.6310000f, 0.0008000f, 1.0607352f, 0.6181555f, 0.0007610f, | |||||
| 1.0584436f, 0.6053144f, 0.0007237f, 1.0552244f, 0.5924756f, 0.0006859f, | |||||
| 1.0509768f, 0.5796379f, 0.0006454f, 1.0456000f, 0.5668000f, 0.0006000f, | |||||
| 1.0390369f, 0.5539611f, 0.0005479f, 1.0313608f, 0.5411372f, 0.0004916f, | |||||
| 1.0226662f, 0.5283528f, 0.0004354f, 1.0130477f, 0.5156323f, 0.0003835f, | |||||
| 1.0026000f, 0.5030000f, 0.0003400f, 0.9913675f, 0.4904688f, 0.0003073f, | |||||
| 0.9793314f, 0.4780304f, 0.0002832f, 0.9664916f, 0.4656776f, 0.0002654f, | |||||
| 0.9528479f, 0.4534032f, 0.0002518f, 0.9384000f, 0.4412000f, 0.0002400f, | |||||
| 0.9231940f, 0.4290800f, 0.0002295f, 0.9072440f, 0.4170360f, 0.0002206f, | |||||
| 0.8905020f, 0.4050320f, 0.0002120f, 0.8729200f, 0.3930320f, 0.0002022f, | |||||
| 0.8544499f, 0.3810000f, 0.0001900f, 0.8350840f, 0.3689184f, 0.0001742f, | |||||
| 0.8149460f, 0.3568272f, 0.0001556f, 0.7941860f, 0.3447768f, 0.0001360f, | |||||
| 0.7729540f, 0.3328176f, 0.0001169f, 0.7514000f, 0.3210000f, 0.0001000f, | |||||
| 0.7295836f, 0.3093381f, 8.613e-05f, 0.7075888f, 0.2978504f, 7.460e-05f, | |||||
| 0.6856022f, 0.2865936f, 6.500e-05f, 0.6638104f, 0.2756245f, 5.693e-05f, | |||||
| 0.6424000f, 0.2650000f, 5.000e-05f, 0.6215149f, 0.2547632f, 4.416e-05f, | |||||
| 0.6011138f, 0.2448896f, 3.948e-05f, 0.5811052f, 0.2353344f, 3.572e-05f, | |||||
| 0.5613977f, 0.2260528f, 3.264e-05f, 0.5419000f, 0.2170000f, 3.000e-05f, | |||||
| 0.5225995f, 0.2081616f, 2.765e-05f, 0.5035464f, 0.1995488f, 2.556e-05f, | |||||
| 0.4847436f, 0.1911552f, 2.364e-05f, 0.4661939f, 0.1829744f, 2.181e-05f, | |||||
| /* 640 — 679 nm */ | |||||
| 0.4479000f, 0.1750000f, 2.000e-05f, 0.4298613f, 0.1672235f, 1.813e-05f, | |||||
| 0.4120980f, 0.1596464f, 1.620e-05f, 0.3946440f, 0.1522776f, 1.420e-05f, | |||||
| 0.3775333f, 0.1451259f, 1.213e-05f, 0.3608000f, 0.1382000f, 1.000e-05f, | |||||
| 0.3444563f, 0.1315003f, 7.733e-06f, 0.3285168f, 0.1250248f, 5.400e-06f, | |||||
| 0.3130192f, 0.1187792f, 3.200e-06f, 0.2980011f, 0.1127691f, 1.333e-06f, | |||||
| 0.2835000f, 0.1070000f, 0.0000000f, 0.2695448f, 0.1014762f, 0.0000000f, | |||||
| 0.2561184f, 0.0961886f, 0.0000000f, 0.2431896f, 0.0911230f, 0.0000000f, | |||||
| 0.2307272f, 0.0862649f, 0.0000000f, 0.2187000f, 0.0816000f, 0.0000000f, | |||||
| 0.2070971f, 0.0771206f, 0.0000000f, 0.1959232f, 0.0728255f, 0.0000000f, | |||||
| 0.1851708f, 0.0687101f, 0.0000000f, 0.1748323f, 0.0647698f, 0.0000000f, | |||||
| 0.1649000f, 0.0610000f, 0.0000000f, 0.1553667f, 0.0573962f, 0.0000000f, | |||||
| 0.1462300f, 0.0539550f, 0.0000000f, 0.1374900f, 0.0506738f, 0.0000000f, | |||||
| 0.1291467f, 0.0475497f, 0.0000000f, 0.1212000f, 0.0445800f, 0.0000000f, | |||||
| 0.1136397f, 0.0417587f, 0.0000000f, 0.1064650f, 0.0390850f, 0.0000000f, | |||||
| 0.0996904f, 0.0365638f, 0.0000000f, 0.0933306f, 0.0342005f, 0.0000000f, | |||||
| 0.0874000f, 0.0320000f, 0.0000000f, 0.0819010f, 0.0299626f, 0.0000000f, | |||||
| 0.0768043f, 0.0280766f, 0.0000000f, 0.0720771f, 0.0263294f, 0.0000000f, | |||||
| 0.0676866f, 0.0247081f, 0.0000000f, 0.0636000f, 0.0232000f, 0.0000000f, | |||||
| 0.0598069f, 0.0218008f, 0.0000000f, 0.0562822f, 0.0205011f, 0.0000000f, | |||||
| 0.0529710f, 0.0192811f, 0.0000000f, 0.0498186f, 0.0181207f, 0.0000000f, | |||||
| /* 680 — 719 nm */ | |||||
| 0.0467700f, 0.0170000f, 0.0000000f, 0.0437841f, 0.0159038f, 0.0000000f, | |||||
| 0.0408754f, 0.0148372f, 0.0000000f, 0.0380726f, 0.0138107f, 0.0000000f, | |||||
| 0.0354046f, 0.0128348f, 0.0000000f, 0.0329000f, 0.0119200f, 0.0000000f, | |||||
| 0.0305642f, 0.0110683f, 0.0000000f, 0.0283806f, 0.0102734f, 0.0000000f, | |||||
| 0.0263448f, 0.0095333f, 0.0000000f, 0.0244528f, 0.0088462f, 0.0000000f, | |||||
| 0.0227000f, 0.0082100f, 0.0000000f, 0.0210843f, 0.0076238f, 0.0000000f, | |||||
| 0.0195999f, 0.0070854f, 0.0000000f, 0.0182373f, 0.0065915f, 0.0000000f, | |||||
| 0.0169872f, 0.0061385f, 0.0000000f, 0.0158400f, 0.0057230f, 0.0000000f, | |||||
| 0.0147906f, 0.0053431f, 0.0000000f, 0.0138313f, 0.0049958f, 0.0000000f, | |||||
| 0.0129487f, 0.0046764f, 0.0000000f, 0.0121292f, 0.0043801f, 0.0000000f, | |||||
| 0.0113592f, 0.0041020f, 0.0000000f, 0.0106294f, 0.0038385f, 0.0000000f, | |||||
| 0.0099388f, 0.0035891f, 0.0000000f, 0.0092884f, 0.0033542f, 0.0000000f, | |||||
| 0.0086789f, 0.0031341f, 0.0000000f, 0.0081109f, 0.0029290f, 0.0000000f, | |||||
| 0.0075824f, 0.0027381f, 0.0000000f, 0.0070887f, 0.0025599f, 0.0000000f, | |||||
| 0.0066273f, 0.0023932f, 0.0000000f, 0.0061954f, 0.0022373f, 0.0000000f, | |||||
| 0.0057903f, 0.0020910f, 0.0000000f, 0.0054098f, 0.0019536f, 0.0000000f, | |||||
| 0.0050526f, 0.0018246f, 0.0000000f, 0.0047175f, 0.0017036f, 0.0000000f, | |||||
| 0.0044035f, 0.0015902f, 0.0000000f, 0.0041095f, 0.0014840f, 0.0000000f, | |||||
| 0.0038339f, 0.0013845f, 0.0000000f, 0.0035757f, 0.0012913f, 0.0000000f, | |||||
| 0.0033343f, 0.0012041f, 0.0000000f, 0.0031091f, 0.0011227f, 0.0000000f, | |||||
| /* 720 — 759 nm */ | |||||
| 0.0028993f, 0.0010470f, 0.0000000f, 0.0027043f, 0.0009766f, 0.0000000f, | |||||
| 0.0025230f, 0.0009111f, 0.0000000f, 0.0023542f, 0.0008501f, 0.0000000f, | |||||
| 0.0021966f, 0.0007932f, 0.0000000f, 0.0020492f, 0.0007400f, 0.0000000f, | |||||
| 0.0019110f, 0.0006901f, 0.0000000f, 0.0017814f, 0.0006433f, 0.0000000f, | |||||
| 0.0016601f, 0.0005995f, 0.0000000f, 0.0015465f, 0.0005585f, 0.0000000f, | |||||
| 0.0014400f, 0.0005200f, 0.0000000f, 0.0013400f, 0.0004839f, 0.0000000f, | |||||
| 0.0012463f, 0.0004501f, 0.0000000f, 0.0011585f, 0.0004183f, 0.0000000f, | |||||
| 0.0010764f, 0.0003887f, 0.0000000f, 0.0009999f, 0.0003611f, 0.0000000f, | |||||
| 0.0009287f, 0.0003354f, 0.0000000f, 0.0008624f, 0.0003114f, 0.0000000f, | |||||
| 0.0008008f, 0.0002892f, 0.0000000f, 0.0007434f, 0.0002685f, 0.0000000f, | |||||
| 0.0006901f, 0.0002492f, 0.0000000f, 0.0006405f, 0.0002313f, 0.0000000f, | |||||
| 0.0005945f, 0.0002147f, 0.0000000f, 0.0005519f, 0.0001993f, 0.0000000f, | |||||
| 0.0005124f, 0.0001850f, 0.0000000f, 0.0004760f, 0.0001719f, 0.0000000f, | |||||
| 0.0004425f, 0.0001598f, 0.0000000f, 0.0004115f, 0.0001486f, 0.0000000f, | |||||
| 0.0003830f, 0.0001383f, 0.0000000f, 0.0003566f, 0.0001288f, 0.0000000f, | |||||
| 0.0003323f, 0.0001200f, 0.0000000f, 0.0003098f, 0.0001119f, 0.0000000f, | |||||
| 0.0002889f, 0.0001043f, 0.0000000f, 0.0002695f, 9.734e-05f, 0.0000000f, | |||||
| 0.0002516f, 9.085e-05f, 0.0000000f, 0.0002348f, 8.480e-05f, 0.0000000f, | |||||
| 0.0002192f, 7.915e-05f, 0.0000000f, 0.0002045f, 7.386e-05f, 0.0000000f, | |||||
| 0.0001908f, 6.892e-05f, 0.0000000f, 0.0001781f, 6.430e-05f, 0.0000000f, | |||||
| /* 760 — 799 nm */ | |||||
| 0.0001662f, 6.000e-05f, 0.0000000f, 0.0001550f, 5.598e-05f, 0.0000000f, | |||||
| 0.0001446f, 5.223e-05f, 0.0000000f, 0.0001349f, 4.872e-05f, 0.0000000f, | |||||
| 0.0001259f, 4.545e-05f, 0.0000000f, 0.0001174f, 4.240e-05f, 0.0000000f, | |||||
| 0.0001096f, 3.956e-05f, 0.0000000f, 0.0001022f, 3.692e-05f, 0.0000000f, | |||||
| 9.539e-05f, 3.445e-05f, 0.0000000f, 8.902e-05f, 3.215e-05f, 0.0000000f, | |||||
| 8.308e-05f, 3.000e-05f, 0.0000000f, 7.751e-05f, 2.799e-05f, 0.0000000f, | |||||
| 7.231e-05f, 2.611e-05f, 0.0000000f, 6.746e-05f, 2.436e-05f, 0.0000000f, | |||||
| 6.293e-05f, 2.272e-05f, 0.0000000f, 5.871e-05f, 2.120e-05f, 0.0000000f, | |||||
| 5.477e-05f, 1.978e-05f, 0.0000000f, 5.110e-05f, 1.845e-05f, 0.0000000f, | |||||
| 4.768e-05f, 1.722e-05f, 0.0000000f, 4.449e-05f, 1.606e-05f, 0.0000000f, | |||||
| 4.151e-05f, 1.499e-05f, 0.0000000f, 3.873e-05f, 1.399e-05f, 0.0000000f, | |||||
| 3.614e-05f, 1.305e-05f, 0.0000000f, 3.372e-05f, 1.218e-05f, 0.0000000f, | |||||
| 3.146e-05f, 1.136e-05f, 0.0000000f, 2.935e-05f, 1.060e-05f, 0.0000000f, | |||||
| 2.738e-05f, 9.886e-06f, 0.0000000f, 2.552e-05f, 9.217e-06f, 0.0000000f, | |||||
| 2.379e-05f, 8.592e-06f, 0.0000000f, 2.218e-05f, 8.009e-06f, 0.0000000f, | |||||
| 2.067e-05f, 7.466e-06f, 0.0000000f, 1.927e-05f, 6.960e-06f, 0.0000000f, | |||||
| 1.797e-05f, 6.488e-06f, 0.0000000f, 1.675e-05f, 6.049e-06f, 0.0000000f, | |||||
| 1.562e-05f, 5.639e-06f, 0.0000000f, 1.456e-05f, 5.258e-06f, 0.0000000f, | |||||
| 1.357e-05f, 4.902e-06f, 0.0000000f, 1.265e-05f, 4.570e-06f, 0.0000000f, | |||||
| 1.180e-05f, 4.260e-06f, 0.0000000f, 1.100e-05f, 3.972e-06f, 0.0000000f, | |||||
| /* 800 — 830 nm */ | |||||
| 1.025e-05f, 3.703e-06f, 0.0000000f, 9.560e-06f, 3.452e-06f, 0.0000000f, | |||||
| 8.912e-06f, 3.218e-06f, 0.0000000f, 8.308e-06f, 3.000e-06f, 0.0000000f, | |||||
| 7.746e-06f, 2.797e-06f, 0.0000000f, 7.221e-06f, 2.608e-06f, 0.0000000f, | |||||
| 6.732e-06f, 2.431e-06f, 0.0000000f, 6.276e-06f, 2.267e-06f, 0.0000000f, | |||||
| 5.851e-06f, 2.113e-06f, 0.0000000f, 5.455e-06f, 1.970e-06f, 0.0000000f, | |||||
| 5.086e-06f, 1.837e-06f, 0.0000000f, 4.741e-06f, 1.712e-06f, 0.0000000f, | |||||
| 4.420e-06f, 1.596e-06f, 0.0000000f, 4.121e-06f, 1.488e-06f, 0.0000000f, | |||||
| 3.842e-06f, 1.387e-06f, 0.0000000f, 3.582e-06f, 1.293e-06f, 0.0000000f, | |||||
| 3.339e-06f, 1.206e-06f, 0.0000000f, 3.113e-06f, 1.124e-06f, 0.0000000f, | |||||
| 2.902e-06f, 1.048e-06f, 0.0000000f, 2.706e-06f, 9.771e-07f, 0.0000000f, | |||||
| 2.523e-06f, 9.109e-07f, 0.0000000f, 2.352e-06f, 8.493e-07f, 0.0000000f, | |||||
| 2.192e-06f, 7.917e-07f, 0.0000000f, 2.044e-06f, 7.381e-07f, 0.0000000f, | |||||
| 1.905e-06f, 6.881e-07f, 0.0000000f, 1.777e-06f, 6.415e-07f, 0.0000000f, | |||||
| 1.656e-06f, 5.981e-07f, 0.0000000f, 1.544e-06f, 5.576e-07f, 0.0000000f, | |||||
| 1.439e-06f, 5.198e-07f, 0.0000000f, 1.342e-06f, 4.846e-07f, 0.0000000f, | |||||
| 1.251e-06f, 4.518e-07f, 0.0000000f, | |||||
| }; | |||||
| /* CIE 1964 Colorimetric Observer, aka. 10º Observer | |||||
| * for wavelengths 360 to 830. */ | |||||
| #if 0 | |||||
| static float cie_1964_xyz[] = | |||||
| { | |||||
| /* 360 — 399 nm */ | |||||
| 1.222e-07f, 1.340e-08f, 5.350e-07f, 1.851e-07f, 2.029e-08f, 8.107e-07f, | |||||
| 2.788e-07f, 3.056e-08f, 1.221e-06f, 4.175e-07f, 4.574e-08f, 1.829e-06f, | |||||
| 6.213e-07f, 6.805e-08f, 2.722e-06f, 9.193e-07f, 1.007e-07f, 4.028e-06f, | |||||
| 1.352e-06f, 1.480e-07f, 5.926e-06f, 1.977e-06f, 2.163e-07f, 8.665e-06f, | |||||
| 2.873e-06f, 3.142e-07f, 1.260e-05f, 4.150e-06f, 4.537e-07f, 1.820e-05f, | |||||
| 5.959e-06f, 6.511e-07f, 2.614e-05f, 8.506e-06f, 9.288e-07f, 3.733e-05f, | |||||
| 1.207e-05f, 1.318e-06f, 5.299e-05f, 1.702e-05f, 1.857e-06f, 7.476e-05f, | |||||
| 2.387e-05f, 2.602e-06f, 0.0001049f, 3.327e-05f, 3.625e-06f, 0.0001462f, | |||||
| 4.609e-05f, 5.019e-06f, 0.0002027f, 6.347e-05f, 6.907e-06f, 0.0002792f, | |||||
| 8.689e-05f, 9.449e-06f, 0.0003825f, 0.0001182f, 1.285e-05f, 0.0005207f, | |||||
| 0.0001600f, 1.736e-05f, 0.0007048f, 0.0002151f, 2.333e-05f, 0.0009482f, | |||||
| 0.0002875f, 3.115e-05f, 0.0012682f, 0.0003820f, 4.135e-05f, 0.0016861f, | |||||
| 0.0005046f, 5.456e-05f, 0.0022285f, 0.0006624f, 7.156e-05f, 0.0029278f, | |||||
| 0.0008645f, 0.0000933f, 0.0038237f, 0.0011215f, 0.0001209f, 0.0049642f, | |||||
| 0.0014462f, 0.0001556f, 0.0064067f, 0.0018536f, 0.0001992f, 0.0082193f, | |||||
| 0.0023616f, 0.0002534f, 0.0104822f, 0.0029906f, 0.0003202f, 0.0132890f, | |||||
| 0.0037645f, 0.0004024f, 0.0167470f, 0.0047102f, 0.0005023f, 0.0209800f, | |||||
| 0.0058581f, 0.0006232f, 0.0261270f, 0.0072423f, 0.0007685f, 0.0323440f, | |||||
| 0.0088996f, 0.0009417f, 0.0398020f, 0.0108709f, 0.0011478f, 0.0486910f, | |||||
| 0.0131989f, 0.0013903f, 0.0592100f, 0.0159292f, 0.0016740f, 0.0715760f, | |||||
| /* 400 — 439 nm */ | |||||
| 0.0191097f, 0.0020044f, 0.0860109f, 0.0227880f, 0.0023860f, 0.1027400f, | |||||
| 0.0270110f, 0.0028220f, 0.1220000f, 0.0318290f, 0.0033190f, 0.1440200f, | |||||
| 0.0372780f, 0.0038800f, 0.1689900f, 0.0434000f, 0.0045090f, 0.1971200f, | |||||
| 0.0502230f, 0.0052090f, 0.2285700f, 0.0577640f, 0.0059850f, 0.2634700f, | |||||
| 0.0660380f, 0.0068330f, 0.3019000f, 0.0750330f, 0.0077570f, 0.3438700f, | |||||
| 0.0847360f, 0.0087560f, 0.3893660f, 0.0950410f, 0.0098160f, 0.4379700f, | |||||
| 0.1058360f, 0.0109180f, 0.4892200f, 0.1170660f, 0.0120580f, 0.5429000f, | |||||
| 0.1286820f, 0.0132370f, 0.5988100f, 0.1406380f, 0.0144560f, 0.6567600f, | |||||
| 0.1528930f, 0.0157170f, 0.7165800f, 0.1654160f, 0.0170250f, 0.7781200f, | |||||
| 0.1781910f, 0.0183990f, 0.8413100f, 0.1912140f, 0.0198480f, 0.9061100f, | |||||
| 0.2044920f, 0.0213910f, 0.9725420f, 0.2176500f, 0.0229920f, 1.0389000f, | |||||
| 0.2302670f, 0.0245980f, 1.1031000f, 0.2423110f, 0.0262130f, 1.1651000f, | |||||
| 0.2537930f, 0.0278410f, 1.2249000f, 0.2647370f, 0.0294970f, 1.2825000f, | |||||
| 0.2751950f, 0.0311950f, 1.3382000f, 0.2853010f, 0.0329270f, 1.3926000f, | |||||
| 0.2951430f, 0.0347380f, 1.4461000f, 0.3048690f, 0.0366540f, 1.4994000f, | |||||
| 0.3146790f, 0.0386760f, 1.5534800f, 0.3243550f, 0.0407920f, 1.6072000f, | |||||
| 0.3335700f, 0.0429460f, 1.6589000f, 0.3422430f, 0.0451140f, 1.7082000f, | |||||
| 0.3503120f, 0.0473330f, 1.7548000f, 0.3577190f, 0.0496020f, 1.7985000f, | |||||
| 0.3644820f, 0.0519340f, 1.8392000f, 0.3704930f, 0.0543370f, 1.8766000f, | |||||
| 0.3757270f, 0.0568220f, 1.9105000f, 0.3801580f, 0.0593990f, 1.9408000f, | |||||
| /* 440 — 479 nm */ | |||||
| 0.3837340f, 0.0620770f, 1.9672800f, 0.3863270f, 0.0647370f, 1.9891000f, | |||||
| 0.3878580f, 0.0672850f, 2.0057000f, 0.3883960f, 0.0697640f, 2.0174000f, | |||||
| 0.3879780f, 0.0722180f, 2.0244000f, 0.3867260f, 0.0747040f, 2.0273000f, | |||||
| 0.3846960f, 0.0772720f, 2.0264000f, 0.3820060f, 0.0799790f, 2.0223000f, | |||||
| 0.3787090f, 0.0828740f, 2.0153000f, 0.3749150f, 0.0860000f, 2.0060000f, | |||||
| 0.3707020f, 0.0894560f, 1.9948000f, 0.3660890f, 0.0929470f, 1.9814000f, | |||||
| 0.3610450f, 0.0962750f, 1.9653000f, 0.3555180f, 0.0995350f, 1.9464000f, | |||||
| 0.3494860f, 0.1028290f, 1.9248000f, 0.3429570f, 0.1062560f, 1.9007000f, | |||||
| 0.3358930f, 0.1099010f, 1.8741000f, 0.3282840f, 0.1138350f, 1.8451000f, | |||||
| 0.3201500f, 0.1181670f, 1.8139000f, 0.3114750f, 0.1229320f, 1.7806000f, | |||||
| 0.3022730f, 0.1282010f, 1.7453700f, 0.2928580f, 0.1334570f, 1.7091000f, | |||||
| 0.2835020f, 0.1383230f, 1.6723000f, 0.2740440f, 0.1430420f, 1.6347000f, | |||||
| 0.2642630f, 0.1477870f, 1.5956000f, 0.2540850f, 0.1527610f, 1.5549000f, | |||||
| 0.2433920f, 0.1581020f, 1.5122000f, 0.2321870f, 0.1639410f, 1.4673000f, | |||||
| 0.2204880f, 0.1703620f, 1.4199000f, 0.2081980f, 0.1774250f, 1.3700000f, | |||||
| 0.1956180f, 0.1851900f, 1.3175600f, 0.1830340f, 0.1930250f, 1.2624000f, | |||||
| 0.1702220f, 0.2003130f, 1.2050000f, 0.1573480f, 0.2071560f, 1.1466000f, | |||||
| 0.1446500f, 0.2136440f, 1.0880000f, 0.1323490f, 0.2199400f, 1.0302000f, | |||||
| 0.1205840f, 0.2261700f, 0.9738300f, 0.1094560f, 0.2324670f, 0.9194300f, | |||||
| 0.0990420f, 0.2390250f, 0.8674600f, 0.0893880f, 0.2459970f, 0.8182800f, | |||||
| /* 480 — 519 nm */ | |||||
| 0.0805070f, 0.2535890f, 0.7721250f, 0.0720340f, 0.2618760f, 0.7282900f, | |||||
| 0.0637100f, 0.2706430f, 0.6860400f, 0.0556940f, 0.2796450f, 0.6455300f, | |||||
| 0.0481170f, 0.2886940f, 0.6068500f, 0.0410720f, 0.2976650f, 0.5700600f, | |||||
| 0.0346420f, 0.3064690f, 0.5352200f, 0.0288960f, 0.3150350f, 0.5023400f, | |||||
| 0.0238760f, 0.3233350f, 0.4714000f, 0.0196280f, 0.3313660f, 0.4423900f, | |||||
| 0.0161720f, 0.3391330f, 0.4152540f, 0.0133000f, 0.3478600f, 0.3900240f, | |||||
| 0.0107590f, 0.3583260f, 0.3663990f, 0.0085420f, 0.3700010f, 0.3440150f, | |||||
| 0.0066610f, 0.3824640f, 0.3226890f, 0.0051320f, 0.3953790f, 0.3023560f, | |||||
| 0.0039820f, 0.4084820f, 0.2830360f, 0.0032390f, 0.4215880f, 0.2648160f, | |||||
| 0.0029340f, 0.4346190f, 0.2478480f, 0.0031140f, 0.4476010f, 0.2323180f, | |||||
| 0.0038160f, 0.4607770f, 0.2185020f, 0.0050950f, 0.4743400f, 0.2058510f, | |||||
| 0.0069360f, 0.4882000f, 0.1935960f, 0.0092990f, 0.5023400f, 0.1817360f, | |||||
| 0.0121470f, 0.5167400f, 0.1702810f, 0.0154440f, 0.5313600f, 0.1592490f, | |||||
| 0.0191560f, 0.5461900f, 0.1486730f, 0.0232500f, 0.5611800f, 0.1386090f, | |||||
| 0.0276900f, 0.5762900f, 0.1290960f, 0.0324440f, 0.5915000f, 0.1202150f, | |||||
| 0.0374650f, 0.6067410f, 0.1120440f, 0.0429560f, 0.6221500f, 0.1047100f, | |||||
| 0.0491140f, 0.6378300f, 0.0981960f, 0.0559200f, 0.6537100f, 0.0923610f, | |||||
| 0.0633490f, 0.6696800f, 0.0870880f, 0.0713580f, 0.6856600f, 0.0822480f, | |||||
| 0.0799010f, 0.7015500f, 0.0777440f, 0.0889090f, 0.7172300f, 0.0734560f, | |||||
| 0.0982930f, 0.7325700f, 0.0692680f, 0.1079490f, 0.7474600f, 0.0650600f, | |||||
| /* 520 — 559 nm */ | |||||
| 0.1177490f, 0.7617570f, 0.0607090f, 0.1278390f, 0.7753400f, 0.0564570f, | |||||
| 0.1384500f, 0.7882200f, 0.0526090f, 0.1495160f, 0.8004600f, 0.0491220f, | |||||
| 0.1610410f, 0.8121400f, 0.0459540f, 0.1729530f, 0.8233300f, 0.0430500f, | |||||
| 0.1852090f, 0.8341200f, 0.0403680f, 0.1977550f, 0.8446000f, 0.0378390f, | |||||
| 0.2105380f, 0.8548700f, 0.0353840f, 0.2234600f, 0.8650400f, 0.0329490f, | |||||
| 0.2364910f, 0.8752110f, 0.0304510f, 0.2496330f, 0.8853700f, 0.0280290f, | |||||
| 0.2629720f, 0.8953700f, 0.0258620f, 0.2765150f, 0.9051500f, 0.0239200f, | |||||
| 0.2902690f, 0.9146500f, 0.0221740f, 0.3042130f, 0.9238100f, 0.0205840f, | |||||
| 0.3183610f, 0.9325500f, 0.0191270f, 0.3327050f, 0.9408100f, 0.0177400f, | |||||
| 0.3472320f, 0.9485200f, 0.0164030f, 0.3619260f, 0.9556000f, 0.0150640f, | |||||
| 0.3767720f, 0.9619880f, 0.0136760f, 0.3916830f, 0.9675400f, 0.0123080f, | |||||
| 0.4065940f, 0.9722300f, 0.0110560f, 0.4215390f, 0.9761700f, 0.0099150f, | |||||
| 0.4365170f, 0.9794600f, 0.0088720f, 0.4515840f, 0.9822000f, 0.0079180f, | |||||
| 0.4667820f, 0.9845200f, 0.0070300f, 0.4821470f, 0.9865200f, 0.0062230f, | |||||
| 0.4977380f, 0.9883200f, 0.0054530f, 0.5136060f, 0.9900200f, 0.0047140f, | |||||
| 0.5298260f, 0.9917610f, 0.0039880f, 0.5464400f, 0.9935300f, 0.0032890f, | |||||
| 0.5634260f, 0.9952300f, 0.0026460f, 0.5807260f, 0.9967700f, 0.0020630f, | |||||
| 0.5982900f, 0.9980900f, 0.0015330f, 0.6160530f, 0.9991100f, 0.0010910f, | |||||
| 0.6339480f, 0.9997700f, 0.0007110f, 0.6519010f, 1.0000000f, 0.0004070f, | |||||
| 0.6698240f, 0.9997100f, 0.0001840f, 0.6876320f, 0.9988500f, 0.0000470f, | |||||
| /* 560 — 599 nm */ | |||||
| 0.7052240f, 0.9973400f, 0.0000000f, 0.7227730f, 0.9952600f, 0.0000000f, | |||||
| 0.7404830f, 0.9927400f, 0.0000000f, 0.7582730f, 0.9897500f, 0.0000000f, | |||||
| 0.7760830f, 0.9863000f, 0.0000000f, 0.7938320f, 0.9823800f, 0.0000000f, | |||||
| 0.8114360f, 0.9779800f, 0.0000000f, 0.8288220f, 0.9731100f, 0.0000000f, | |||||
| 0.8458790f, 0.9677400f, 0.0000000f, 0.8625250f, 0.9618900f, 0.0000000f, | |||||
| 0.8786550f, 0.9555520f, 0.0000000f, 0.8942080f, 0.9486010f, 0.0000000f, | |||||
| 0.9092060f, 0.9409810f, 0.0000000f, 0.9236720f, 0.9327980f, 0.0000000f, | |||||
| 0.9376380f, 0.9241580f, 0.0000000f, 0.9511620f, 0.9151750f, 0.0000000f, | |||||
| 0.9642830f, 0.9059540f, 0.0000000f, 0.9770680f, 0.8966080f, 0.0000000f, | |||||
| 0.9895900f, 0.8872490f, 0.0000000f, 1.0019100f, 0.8779860f, 0.0000000f, | |||||
| 1.0141600f, 0.8689340f, 0.0000000f, 1.0265000f, 0.8601640f, 0.0000000f, | |||||
| 1.0388000f, 0.8515190f, 0.0000000f, 1.0510000f, 0.8429630f, 0.0000000f, | |||||
| 1.0629000f, 0.8343930f, 0.0000000f, 1.0743000f, 0.8256230f, 0.0000000f, | |||||
| 1.0852000f, 0.8167640f, 0.0000000f, 1.0952000f, 0.8075440f, 0.0000000f, | |||||
| 1.1042000f, 0.7979470f, 0.0000000f, 1.1120000f, 0.7878930f, 0.0000000f, | |||||
| 1.1185200f, 0.7774050f, 0.0000000f, 1.1238000f, 0.7664900f, 0.0000000f, | |||||
| 1.1280000f, 0.7553090f, 0.0000000f, 1.1311000f, 0.7438450f, 0.0000000f, | |||||
| 1.1332000f, 0.7321900f, 0.0000000f, 1.1343000f, 0.7203530f, 0.0000000f, | |||||
| 1.1343000f, 0.7082810f, 0.0000000f, 1.1333000f, 0.6960550f, 0.0000000f, | |||||
| 1.1312000f, 0.6836210f, 0.0000000f, 1.1281000f, 0.6710480f, 0.0000000f, | |||||
| /* 600 — 639 nm */ | |||||
| 1.1239900f, 0.6583410f, 0.0000000f, 1.1189000f, 0.6455450f, 0.0000000f, | |||||
| 1.1129000f, 0.6327180f, 0.0000000f, 1.1059000f, 0.6198150f, 0.0000000f, | |||||
| 1.0980000f, 0.6068870f, 0.0000000f, 1.0891000f, 0.5938780f, 0.0000000f, | |||||
| 1.0792000f, 0.5807810f, 0.0000000f, 1.0684000f, 0.5676530f, 0.0000000f, | |||||
| 1.0567000f, 0.5544900f, 0.0000000f, 1.0440000f, 0.5412280f, 0.0000000f, | |||||
| 1.0304800f, 0.5279630f, 0.0000000f, 1.0160000f, 0.5146340f, 0.0000000f, | |||||
| 1.0008000f, 0.5013630f, 0.0000000f, 0.9847900f, 0.4881240f, 0.0000000f, | |||||
| 0.9680800f, 0.4749350f, 0.0000000f, 0.9507400f, 0.4618340f, 0.0000000f, | |||||
| 0.9328000f, 0.4488230f, 0.0000000f, 0.9143400f, 0.4359170f, 0.0000000f, | |||||
| 0.8953900f, 0.4231530f, 0.0000000f, 0.8760300f, 0.4105260f, 0.0000000f, | |||||
| 0.8562970f, 0.3980570f, 0.0000000f, 0.8363500f, 0.3858350f, 0.0000000f, | |||||
| 0.8162900f, 0.3739510f, 0.0000000f, 0.7960500f, 0.3623110f, 0.0000000f, | |||||
| 0.7756100f, 0.3508630f, 0.0000000f, 0.7549300f, 0.3395540f, 0.0000000f, | |||||
| 0.7339900f, 0.3283090f, 0.0000000f, 0.7127800f, 0.3171180f, 0.0000000f, | |||||
| 0.6912900f, 0.3059360f, 0.0000000f, 0.6695200f, 0.2947370f, 0.0000000f, | |||||
| 0.6474670f, 0.2834930f, 0.0000000f, 0.6251100f, 0.2722220f, 0.0000000f, | |||||
| 0.6025200f, 0.2609900f, 0.0000000f, 0.5798900f, 0.2498770f, 0.0000000f, | |||||
| 0.5573700f, 0.2389460f, 0.0000000f, 0.5351100f, 0.2282540f, 0.0000000f, | |||||
| 0.5132400f, 0.2178530f, 0.0000000f, 0.4918600f, 0.2077800f, 0.0000000f, | |||||
| 0.4710800f, 0.1980720f, 0.0000000f, 0.4509600f, 0.1887480f, 0.0000000f, | |||||
| /* 640 — 679 nm */ | |||||
| 0.4315670f, 0.1798280f, 0.0000000f, 0.4128700f, 0.1712850f, 0.0000000f, | |||||
| 0.3947500f, 0.1630590f, 0.0000000f, 0.3772100f, 0.1551510f, 0.0000000f, | |||||
| 0.3601900f, 0.1475350f, 0.0000000f, 0.3436900f, 0.1402110f, 0.0000000f, | |||||
| 0.3276900f, 0.1331700f, 0.0000000f, 0.3121700f, 0.1264000f, 0.0000000f, | |||||
| 0.2971100f, 0.1198920f, 0.0000000f, 0.2825000f, 0.1136400f, 0.0000000f, | |||||
| 0.2683290f, 0.1076330f, 0.0000000f, 0.2545900f, 0.1018700f, 0.0000000f, | |||||
| 0.2413000f, 0.0963470f, 0.0000000f, 0.2284800f, 0.0910630f, 0.0000000f, | |||||
| 0.2161400f, 0.0860100f, 0.0000000f, 0.2043000f, 0.0811870f, 0.0000000f, | |||||
| 0.1929500f, 0.0765830f, 0.0000000f, 0.1821100f, 0.0721980f, 0.0000000f, | |||||
| 0.1717700f, 0.0680240f, 0.0000000f, 0.1619200f, 0.0640520f, 0.0000000f, | |||||
| 0.1525680f, 0.0602810f, 0.0000000f, 0.1436700f, 0.0566970f, 0.0000000f, | |||||
| 0.1352000f, 0.0532920f, 0.0000000f, 0.1271300f, 0.0500590f, 0.0000000f, | |||||
| 0.1194800f, 0.0469980f, 0.0000000f, 0.1122100f, 0.0440960f, 0.0000000f, | |||||
| 0.1053100f, 0.0413450f, 0.0000000f, 0.0987860f, 0.0387507f, 0.0000000f, | |||||
| 0.0926100f, 0.0362978f, 0.0000000f, 0.0867730f, 0.0339832f, 0.0000000f, | |||||
| 0.0812606f, 0.0318004f, 0.0000000f, 0.0760480f, 0.0297395f, 0.0000000f, | |||||
| 0.0711140f, 0.0277918f, 0.0000000f, 0.0664540f, 0.0259551f, 0.0000000f, | |||||
| 0.0620620f, 0.0242263f, 0.0000000f, 0.0579300f, 0.0226017f, 0.0000000f, | |||||
| 0.0540500f, 0.0210779f, 0.0000000f, 0.0504120f, 0.0196505f, 0.0000000f, | |||||
| 0.0470060f, 0.0183153f, 0.0000000f, 0.0438230f, 0.0170686f, 0.0000000f, | |||||
| /* 680 — 719 nm */ | |||||
| 0.0408508f, 0.0159051f, 0.0000000f, 0.0380720f, 0.0148183f, 0.0000000f, | |||||
| 0.0354680f, 0.0138008f, 0.0000000f, 0.0330310f, 0.0128495f, 0.0000000f, | |||||
| 0.0307530f, 0.0119607f, 0.0000000f, 0.0286230f, 0.0111303f, 0.0000000f, | |||||
| 0.0266350f, 0.0103555f, 0.0000000f, 0.0247810f, 0.0096332f, 0.0000000f, | |||||
| 0.0230520f, 0.0089599f, 0.0000000f, 0.0214410f, 0.0083324f, 0.0000000f, | |||||
| 0.0199413f, 0.0077488f, 0.0000000f, 0.0185440f, 0.0072046f, 0.0000000f, | |||||
| 0.0172410f, 0.0066975f, 0.0000000f, 0.0160270f, 0.0062251f, 0.0000000f, | |||||
| 0.0148960f, 0.0057850f, 0.0000000f, 0.0138420f, 0.0053751f, 0.0000000f, | |||||
| 0.0128620f, 0.0049941f, 0.0000000f, 0.0119490f, 0.0046392f, 0.0000000f, | |||||
| 0.0111000f, 0.0043093f, 0.0000000f, 0.0103110f, 0.0040028f, 0.0000000f, | |||||
| 0.0095769f, 0.0037177f, 0.0000000f, 0.0088940f, 0.0034526f, 0.0000000f, | |||||
| 0.0082581f, 0.0032058f, 0.0000000f, 0.0076664f, 0.0029762f, 0.0000000f, | |||||
| 0.0071163f, 0.0027628f, 0.0000000f, 0.0066052f, 0.0025646f, 0.0000000f, | |||||
| 0.0061306f, 0.0023805f, 0.0000000f, 0.0056903f, 0.0022097f, 0.0000000f, | |||||
| 0.0052819f, 0.0020513f, 0.0000000f, 0.0049033f, 0.0019045f, 0.0000000f, | |||||
| 0.0045526f, 0.0017685f, 0.0000000f, 0.0042275f, 0.0016424f, 0.0000000f, | |||||
| 0.0039258f, 0.0015254f, 0.0000000f, 0.0036457f, 0.0014167f, 0.0000000f, | |||||
| 0.0033859f, 0.0013160f, 0.0000000f, 0.0031447f, 0.0012224f, 0.0000000f, | |||||
| 0.0029208f, 0.0011356f, 0.0000000f, 0.0027130f, 0.0010549f, 0.0000000f, | |||||
| 0.0025202f, 0.0009801f, 0.0000000f, 0.0023411f, 0.0009107f, 0.0000000f, | |||||
| /* 720 — 759 nm */ | |||||
| 0.0021750f, 0.0008462f, 0.0000000f, 0.0020206f, 0.0007863f, 0.0000000f, | |||||
| 0.0018773f, 0.0007307f, 0.0000000f, 0.0017441f, 0.0006790f, 0.0000000f, | |||||
| 0.0016205f, 0.0006310f, 0.0000000f, 0.0015057f, 0.0005864f, 0.0000000f, | |||||
| 0.0013992f, 0.0005451f, 0.0000000f, 0.0013004f, 0.0005067f, 0.0000000f, | |||||
| 0.0012087f, 0.0004711f, 0.0000000f, 0.0011236f, 0.0004381f, 0.0000000f, | |||||
| 0.0010448f, 0.0004074f, 0.0000000f, 0.0009716f, 0.0003790f, 0.0000000f, | |||||
| 0.0009036f, 0.0003525f, 0.0000000f, 0.0008405f, 0.0003280f, 0.0000000f, | |||||
| 0.0007819f, 0.0003052f, 0.0000000f, 0.0007275f, 0.0002840f, 0.0000000f, | |||||
| 0.0006769f, 0.0002644f, 0.0000000f, 0.0006300f, 0.0002461f, 0.0000000f, | |||||
| 0.0005864f, 0.0002291f, 0.0000000f, 0.0005459f, 0.0002134f, 0.0000000f, | |||||
| 0.0005083f, 0.0001987f, 0.0000000f, 0.0004733f, 0.0001851f, 0.0000000f, | |||||
| 0.0004408f, 0.0001725f, 0.0000000f, 0.0004106f, 0.0001607f, 0.0000000f, | |||||
| 0.0003825f, 0.0001497f, 0.0000000f, 0.0003564f, 0.0001396f, 0.0000000f, | |||||
| 0.0003321f, 0.0001301f, 0.0000000f, 0.0003096f, 0.0001213f, 0.0000000f, | |||||
| 0.0002886f, 0.0001131f, 0.0000000f, 0.0002691f, 0.0001055f, 0.0000000f, | |||||
| 0.0002510f, 9.843e-05f, 0.0000000f, 0.0002341f, 9.185e-05f, 0.0000000f, | |||||
| 0.0002185f, 8.574e-05f, 0.0000000f, 2.0391e-4f, 8.005e-05f, 0.0000000f, | |||||
| 1.9040e-4f, 7.475e-05f, 0.0000000f, 1.7770e-4f, 6.982e-05f, 0.0000000f, | |||||
| 0.0001660f, 6.522e-05f, 0.0000000f, 0.0001550f, 6.094e-05f, 0.0000000f, | |||||
| 0.0001448f, 5.694e-05f, 0.0000000f, 0.0001353f, 5.322e-05f, 0.0000000f, | |||||
| /* 760 — 799 nm */ | |||||
| 0.0001264f, 4.974e-05f, 0.0000000f, 0.0001181f, 4.649e-05f, 0.0000000f, | |||||
| 0.0001104f, 4.346e-05f, 0.0000000f, 0.0001032f, 4.064e-05f, 0.0000000f, | |||||
| 9.643e-05f, 3.800e-05f, 0.0000000f, 9.015e-05f, 3.554e-05f, 0.0000000f, | |||||
| 8.429e-05f, 3.324e-05f, 0.0000000f, 7.883e-05f, 3.110e-05f, 0.0000000f, | |||||
| 7.373e-05f, 2.910e-05f, 0.0000000f, 6.897e-05f, 2.723e-05f, 0.0000000f, | |||||
| 6.453e-05f, 2.549e-05f, 0.0000000f, 6.038e-05f, 2.386e-05f, 0.0000000f, | |||||
| 0.0000565f, 2.233e-05f, 0.0000000f, 5.288e-05f, 2.091e-05f, 0.0000000f, | |||||
| 4.950e-05f, 1.958e-05f, 0.0000000f, 4.634e-05f, 1.834e-05f, 0.0000000f, | |||||
| 4.339e-05f, 1.718e-05f, 0.0000000f, 4.063e-05f, 1.609e-05f, 0.0000000f, | |||||
| 3.806e-05f, 1.508e-05f, 0.0000000f, 3.566e-05f, 1.413e-05f, 0.0000000f, | |||||
| 3.341e-05f, 1.325e-05f, 0.0000000f, 3.132e-05f, 1.242e-05f, 0.0000000f, | |||||
| 2.936e-05f, 1.165e-05f, 0.0000000f, 2.752e-05f, 1.093e-05f, 0.0000000f, | |||||
| 2.581e-05f, 1.025e-05f, 0.0000000f, 2.421e-05f, 9.620e-06f, 0.0000000f, | |||||
| 2.271e-05f, 9.028e-06f, 0.0000000f, 2.131e-05f, 8.474e-06f, 0.0000000f, | |||||
| 1.999e-05f, 7.955e-06f, 0.0000000f, 1.876e-05f, 7.469e-06f, 0.0000000f, | |||||
| 1.761e-05f, 7.013e-06f, 0.0000000f, 1.653e-05f, 6.586e-06f, 0.0000000f, | |||||
| 1.552e-05f, 6.186e-06f, 0.0000000f, 1.457e-05f, 5.811e-06f, 0.0000000f, | |||||
| 1.369e-05f, 5.459e-06f, 0.0000000f, 1.286e-05f, 5.130e-06f, 0.0000000f, | |||||
| 1.208e-05f, 4.821e-06f, 0.0000000f, 1.135e-05f, 4.531e-06f, 0.0000000f, | |||||
| 1.066e-05f, 4.259e-06f, 0.0000000f, 1.002e-05f, 4.004e-06f, 0.0000000f, | |||||
| /* 800 — 830 nm */ | |||||
| 9.414e-06f, 3.765e-06f, 0.0000000f, 8.848e-06f, 3.540e-06f, 0.0000000f, | |||||
| 8.317e-06f, 3.329e-06f, 0.0000000f, 7.819e-06f, 3.131e-06f, 0.0000000f, | |||||
| 7.352e-06f, 2.945e-06f, 0.0000000f, 6.913e-06f, 2.771e-06f, 0.0000000f, | |||||
| 6.502e-06f, 2.607e-06f, 0.0000000f, 6.115e-06f, 2.453e-06f, 0.0000000f, | |||||
| 5.753e-06f, 2.309e-06f, 0.0000000f, 5.413e-06f, 2.173e-06f, 0.0000000f, | |||||
| 5.093e-06f, 2.046e-06f, 0.0000000f, 4.794e-06f, 1.927e-06f, 0.0000000f, | |||||
| 4.513e-06f, 1.814e-06f, 0.0000000f, 4.248e-06f, 1.709e-06f, 0.0000000f, | |||||
| 4.000e-06f, 1.610e-06f, 0.0000000f, 3.767e-06f, 1.517e-06f, 0.0000000f, | |||||
| 3.548e-06f, 1.429e-06f, 0.0000000f, 3.342e-06f, 1.347e-06f, 0.0000000f, | |||||
| 3.149e-06f, 1.269e-06f, 0.0000000f, 2.967e-06f, 1.197e-06f, 0.0000000f, | |||||
| 2.795e-06f, 1.128e-06f, 0.0000000f, 2.635e-06f, 1.064e-06f, 0.0000000f, | |||||
| 2.483e-06f, 1.003e-06f, 0.0000000f, 2.341e-06f, 9.462e-07f, 0.0000000f, | |||||
| 2.208e-06f, 8.926e-07f, 0.0000000f, 2.082e-06f, 8.422e-07f, 0.0000000f, | |||||
| 1.964e-06f, 7.946e-07f, 0.0000000f, 1.852e-06f, 7.498e-07f, 0.0000000f, | |||||
| 1.747e-06f, 7.074e-07f, 0.0000000f, 1.647e-06f, 6.675e-07f, 0.0000000f, | |||||
| 1.553e-06f, 6.297e-07f, 0.0000000f, | |||||
| }; | |||||
| #endif | |||||
| vec3 Color::WavelengthToCIExyY(float nm) | |||||
| { | |||||
| nm -= 360.f; | |||||
| int i = (int)nm; | |||||
| if (i < 0 || i > 830 - 360) | |||||
| return vec3::zero; | |||||
| float t = nm - i; | |||||
| float x = lol::lerp(cie_1931_xyz[i * 3 + 0], cie_1931_xyz[i * 3 + 3], t); | |||||
| float y = lol::lerp(cie_1931_xyz[i * 3 + 1], cie_1931_xyz[i * 3 + 4], t); | |||||
| float z = lol::lerp(cie_1931_xyz[i * 3 + 2], cie_1931_xyz[i * 3 + 5], t); | |||||
| float normalize = 1.f / (x + y + z); | |||||
| return vec3(x * normalize, y * normalize, 100.0f); | |||||
| } | |||||
| } /* namespace lol */ | |||||
| @@ -1,140 +0,0 @@ | |||||
| // | |||||
| // Lol Engine | |||||
| // | |||||
| // Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||||
| // | |||||
| // Lol Engine is free software. It comes without any warranty, to | |||||
| // the extent permitted by applicable law. You can redistribute it | |||||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||||
| // See http://www.wtfpl.net/ for more details. | |||||
| // | |||||
| #include <lol/engine-internal.h> | |||||
| namespace lol | |||||
| { | |||||
| /* | |||||
| * Hardcoded constants for colours | |||||
| */ | |||||
| vec4 const Color::black = vec4(0, 0, 0, 1); | |||||
| vec4 const Color::red = vec4(1, 0, 0, 1); | |||||
| vec4 const Color::green = vec4(0, 1, 0, 1); | |||||
| vec4 const Color::yellow = vec4(1, 1, 0, 1); | |||||
| vec4 const Color::blue = vec4(0, 0, 1, 1); | |||||
| vec4 const Color::magenta = vec4(1, 0, 1, 1); | |||||
| vec4 const Color::cyan = vec4(0, 1, 1, 1); | |||||
| vec4 const Color::white = vec4(1, 1, 1, 1); | |||||
| vec4 const Color::dark_gray = vec4(.25f, .25f, .25f, 1); | |||||
| vec4 const Color::gray = vec4(.5f, .5f, .5f, 1); | |||||
| vec4 const Color::light_gray = vec4(.75f, .75f, .75f, 1); | |||||
| /* | |||||
| * Conversion from colours to hexadecimal | |||||
| */ | |||||
| std::string Color::HexString4Bpp(vec3 c) | |||||
| { | |||||
| uvec3 c2 = (uvec3)(clamp(c, 0.f, 1.f) * 255.999f); | |||||
| return format("%01x%01x%01x", c2.r, c2.g, c2.b); | |||||
| } | |||||
| std::string Color::HexString4Bpp(vec4 c) | |||||
| { | |||||
| uvec4 c2 = (uvec4)(clamp(c, 0.f, 1.f) * 15.999f); | |||||
| return format("%01x%1x%01x%01x", c2.r, c2.g, c2.b, c2.a); | |||||
| } | |||||
| std::string Color::HexString8Bpp(vec3 c) | |||||
| { | |||||
| uvec3 c2 = (uvec3)(clamp(c, 0.f, 1.f) * 255.999f); | |||||
| return format("%02x%02x%02x", c2.r, c2.g, c2.b); | |||||
| } | |||||
| std::string Color::HexString8Bpp(vec4 c) | |||||
| { | |||||
| uvec4 c2 = (uvec4)(clamp(c, 0.f, 1.f) * 15.999f); | |||||
| return format("%02x%2x%02x%02x", c2.r, c2.g, c2.b, c2.a); | |||||
| } | |||||
| /* | |||||
| * Convert uint color to vec4. | |||||
| */ | |||||
| vec4 Color::FromRGBA32(uint32_t c) | |||||
| { | |||||
| ivec4 v(c >> 24, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff); | |||||
| return vec4(v) * (1.f / 255.f); | |||||
| } | |||||
| vec4 Color::FromRGB32(uint32_t c) | |||||
| { | |||||
| return Color::FromRGBA32((c << 8) | 0x000000ffu); | |||||
| } | |||||
| vec4 Color::FromRGBA16(uint16_t c) | |||||
| { | |||||
| return Color::FromRGBA32 | |||||
| ( 0x11000000u * (c >> 12) | |||||
| | 0x00110000u * ((c >> 8) & 0xf) | |||||
| | 0x00001100u * ((c >> 4) & 0xf) | |||||
| | 0x00000011u * (c & 0xf)); | |||||
| } | |||||
| vec4 Color::FromRGB16(uint16_t c) | |||||
| { | |||||
| return Color::FromRGBA16((c << 4) | 0xfu); | |||||
| } | |||||
| /* | |||||
| * Convert uint color to vec4. | |||||
| */ | |||||
| uint32_t Color::ToRGBA32(vec4 c) | |||||
| { | |||||
| ivec4 v(c * 0xff); | |||||
| return (uint32_t)((v.r << 24) | (v.g << 16) | (v.b << 8) | v.a); | |||||
| } | |||||
| uint32_t Color::ToRGB32(vec4 c) | |||||
| { | |||||
| ivec4 v(c * 0xff); | |||||
| return (uint32_t)((v.r << 16) | (v.g << 8) | v.b); | |||||
| } | |||||
| uint16_t Color::ToRGBA16(vec4 c) | |||||
| { | |||||
| ivec4 v(c * 0xf); | |||||
| return (uint16_t)((v.r << 12) | (v.g << 8) | (v.b << 4) | v.a); | |||||
| } | |||||
| uint16_t Color::ToRGB16(vec4 c) | |||||
| { | |||||
| ivec4 v(c * 0xf); | |||||
| return (uint16_t)((v.r << 8) | (v.g << 4) | v.b); | |||||
| } | |||||
| /* | |||||
| * Conversion from colours to hexadecimal | |||||
| */ | |||||
| vec4 Color::C8BppHexString(std::string const &s) | |||||
| { | |||||
| std::string c = s[0] == '#' ? &s[1] : s; | |||||
| uint32_t tmp = std::strtol(c.c_str(), nullptr, 16); | |||||
| if (c.length() == 3) | |||||
| { | |||||
| tmp = 0x11000000u * (tmp >> 8) | |||||
| | 0x00110000u * ((tmp >> 4) & 0xf) | |||||
| | 0x00001100u * (tmp & 0xf) | |||||
| | 0x000000ffu; | |||||
| } | |||||
| else if (c.length() == 4) | |||||
| { | |||||
| tmp = 0x11000000u * (tmp >> 12) | |||||
| | 0x00110000u * ((tmp >> 8) & 0xf) | |||||
| | 0x00001100u * ((tmp >> 4) & 0xf) | |||||
| | 0x00000011u * (tmp & 0xf); | |||||
| } | |||||
| else if (c.length() == 6) | |||||
| { | |||||
| tmp = 0xffu | 0x100u * tmp; | |||||
| } | |||||
| vec4 color(0.f); | |||||
| ivec4 v(tmp >> 24, (tmp >> 16) & 0xff, (tmp >> 8) & 0xff, tmp & 0xff); | |||||
| return vec4(v) * (1.f / 255.f); | |||||
| } | |||||
| } /* namespace lol */ | |||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2004—2017 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2004—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -26,7 +26,7 @@ image image::YUVToRGB() const | |||||
| vec4 *pixels = ret.lock<PixelFormat::RGBA_F32>(); | vec4 *pixels = ret.lock<PixelFormat::RGBA_F32>(); | ||||
| for (int n = 0; n < count; ++n) | for (int n = 0; n < count; ++n) | ||||
| pixels[n] = Color::YUVToRGB(pixels[n]); | |||||
| pixels[n] = color::yuv_to_rgb(pixels[n]); | |||||
| ret.unlock(pixels); | ret.unlock(pixels); | ||||
| return ret; | return ret; | ||||
| @@ -39,7 +39,7 @@ image image::RGBToYUV() const | |||||
| vec4 *pixels = ret.lock<PixelFormat::RGBA_F32>(); | vec4 *pixels = ret.lock<PixelFormat::RGBA_F32>(); | ||||
| for (int n = 0; n < count; ++n) | for (int n = 0; n < count; ++n) | ||||
| pixels[n] = Color::RGBToYUV(pixels[n]); | |||||
| pixels[n] = color::rgb_to_yuv(pixels[n]); | |||||
| ret.unlock(pixels); | ret.unlock(pixels); | ||||
| return ret; | return ret; | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2004—2017 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2004—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -160,7 +160,7 @@ static image ResizeBresenham(image &src, ivec2 size) | |||||
| { | { | ||||
| if (remy == 0) | if (remy == 0) | ||||
| { | { | ||||
| vec4 color(0.f); | |||||
| vec4 col(0.f); | |||||
| int remx = 0; | int remx = 0; | ||||
| for (int x = 0, x0 = 0; x < size.x; x++) | for (int x = 0, x0 = 0; x < size.x; x++) | ||||
| @@ -171,13 +171,13 @@ static image ResizeBresenham(image &src, ivec2 size) | |||||
| { | { | ||||
| if (remx == 0) | if (remx == 0) | ||||
| { | { | ||||
| color = srcp[y0 * oldsize.x + x0]; | |||||
| col = srcp[y0 * oldsize.x + x0]; | |||||
| x0++; | x0++; | ||||
| remx = size.x; | remx = size.x; | ||||
| } | } | ||||
| int nx = lol::min(remx, oldsize.x - totx); | int nx = lol::min(remx, oldsize.x - totx); | ||||
| acolor += (float)nx * color; | |||||
| acolor += (float)nx * col; | |||||
| totx += nx; | totx += nx; | ||||
| remx -= nx; | remx -= nx; | ||||
| } | } | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -52,9 +52,9 @@ vec3 Light::GetPosition() | |||||
| return m_position; | return m_position; | ||||
| } | } | ||||
| void Light::SetColor(vec4 const &color) | |||||
| void Light::SetColor(vec4 const &col) | |||||
| { | { | ||||
| m_color = color; | |||||
| m_color = col; | |||||
| } | } | ||||
| vec4 Light::GetColor() | vec4 Light::GetColor() | ||||
| @@ -150,8 +150,6 @@ | |||||
| <ClCompile Include="image\codec\sdl-image.cpp" /> | <ClCompile Include="image\codec\sdl-image.cpp" /> | ||||
| <ClCompile Include="image\codec\zed-image.cpp" /> | <ClCompile Include="image\codec\zed-image.cpp" /> | ||||
| <ClCompile Include="image\codec\zed-palette-image.cpp" /> | <ClCompile Include="image\codec\zed-palette-image.cpp" /> | ||||
| <ClCompile Include="image\color\cie1931.cpp" /> | |||||
| <ClCompile Include="image\color\color.cpp" /> | |||||
| <ClCompile Include="image\filter\colors.cpp" /> | <ClCompile Include="image\filter\colors.cpp" /> | ||||
| <ClCompile Include="image\filter\convolution.cpp" /> | <ClCompile Include="image\filter\convolution.cpp" /> | ||||
| <ClCompile Include="image\filter\dilate.cpp" /> | <ClCompile Include="image\filter\dilate.cpp" /> | ||||
| @@ -128,12 +128,6 @@ | |||||
| <ClCompile Include="image\codec\zed-palette-image.cpp"> | <ClCompile Include="image\codec\zed-palette-image.cpp"> | ||||
| <Filter>image\codec</Filter> | <Filter>image\codec</Filter> | ||||
| </ClCompile> | </ClCompile> | ||||
| <ClCompile Include="image\color\cie1931.cpp"> | |||||
| <Filter>image\color</Filter> | |||||
| </ClCompile> | |||||
| <ClCompile Include="image\color\color.cpp"> | |||||
| <Filter>image\color</Filter> | |||||
| </ClCompile> | |||||
| <ClCompile Include="image\filter\colors.cpp"> | <ClCompile Include="image\filter\colors.cpp"> | ||||
| <Filter>image\filter</Filter> | <Filter>image\filter</Filter> | ||||
| </ClCompile> | </ClCompile> | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // © 2013—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | // © 2013—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | ||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| @@ -34,7 +34,7 @@ void DrawInner(TREE *tree, array<TBB, vec4> &boxes, | |||||
| array<TE *, int, vec4> &elements, | array<TE *, int, vec4> &elements, | ||||
| array<int, TBB> &leaves, int children, vec4 color) | array<int, TBB> &leaves, int children, vec4 color) | ||||
| { | { | ||||
| boxes.push(tree->GetAABB(), Color::white); | |||||
| boxes.push(tree->GetAABB(), color::white); | |||||
| leaves.push(0, boxes.last().m1); | leaves.push(0, boxes.last().m1); | ||||
| while (leaves.count() > 0) | while (leaves.count() > 0) | ||||
| { | { | ||||
| @@ -51,7 +51,7 @@ void DrawInner(TREE *tree, array<TBB, vec4> &boxes, | |||||
| } | } | ||||
| } | } | ||||
| if (!done) | if (!done) | ||||
| elements.push(tree->GetElements()[tree->GetTree()[leaves[0].m1].m_elements[j]].m_element, 1, Color::red); | |||||
| elements.push(tree->GetElements()[tree->GetTree()[leaves[0].m1].m_elements[j]].m_element, 1, color::red); | |||||
| } | } | ||||
| for (int i = 0; i < children; i++) | for (int i = 0; i < children; i++) | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // © 2013—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | // © 2013—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | ||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| @@ -36,8 +36,8 @@ void Draw(PortalDoor<TE>& port, vec4 color) | |||||
| // Draw normal | // Draw normal | ||||
| vec3 p = port.m_center + port.m_up * port.m_size.y * .5f; | vec3 p = port.m_center + port.m_up * port.m_size.y * .5f; | ||||
| Debug::DrawLine(p, p + port.m_normal, Color::red); | |||||
| Debug::DrawLine(p, p + port.m_up, Color::green); | |||||
| Debug::DrawLine(p, p + port.m_normal, color::red); | |||||
| Debug::DrawLine(p, p + port.m_up, color::green); | |||||
| // Draw door | // Draw door | ||||
| for (int l = 0; l < 4; l++) | for (int l = 0; l < 4; l++) | ||||
| Debug::DrawLine(points[l], points[(l + 1) % 4], color); | Debug::DrawLine(points[l], points[(l + 1) % 4], color); | ||||
| @@ -309,16 +309,16 @@ public: | |||||
| vec4 tmp = vec4::zero; | vec4 tmp = vec4::zero; | ||||
| for (auto port : room->m_doors) | for (auto port : room->m_doors) | ||||
| { | { | ||||
| Debug::Draw(*port, Color::cyan); | |||||
| Debug::Draw(*port, color::cyan); | |||||
| tmp += vec4(port->m_center, 1.f); | tmp += vec4(port->m_center, 1.f); | ||||
| } | } | ||||
| tmp /= tmp.w; | tmp /= tmp.w; | ||||
| Debug::DrawBox(tmp.xyz - vec3(1.f), tmp.xyz + vec3(1.f), Color::yellow); | |||||
| Debug::DrawBox(tmp.xyz - vec3(1.f), tmp.xyz + vec3(1.f), color::yellow); | |||||
| } | } | ||||
| for (auto port : ignore_doors) | for (auto port : ignore_doors) | ||||
| { | { | ||||
| Debug::Draw(*port, Color::magenta); | |||||
| Debug::DrawViewProj(port->m_view, port->m_proj, Color::magenta); | |||||
| Debug::Draw(*port, color::magenta); | |||||
| Debug::DrawViewProj(port->m_view, port->m_proj, color::magenta); | |||||
| } | } | ||||
| #endif //LOL_BUILD_DEBUG | #endif //LOL_BUILD_DEBUG | ||||
| } | } | ||||
| @@ -1,358 +0,0 @@ | |||||
| // | |||||
| // Lol Engine | |||||
| // | |||||
| // Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||||
| // | |||||
| // Lol Engine is free software. It comes without any warranty, to | |||||
| // the extent permitted by applicable law. You can redistribute it | |||||
| // and/or modify it under the terms of the Do What the Fuck You Want | |||||
| // to Public License, Version 2, as published by the WTFPL Task Force. | |||||
| // See http://www.wtfpl.net/ for more details. | |||||
| // | |||||
| #pragma once | |||||
| // | |||||
| // The Color class | |||||
| // --------------- | |||||
| // Provides various color conversion routines. | |||||
| // | |||||
| #include <lol/math/vector.h> | |||||
| namespace lol | |||||
| { | |||||
| class Color : public vec4 | |||||
| { | |||||
| public: | |||||
| /* | |||||
| * Convert linear RGB to sRGB | |||||
| */ | |||||
| static vec3 LinearRGBTosRGB(vec3 src) | |||||
| { | |||||
| vec3 ret = 12.92f * src; | |||||
| if (src.r > 0.0031308f) | |||||
| ret.r = 1.055f * pow(src.r, 1.0f / 2.4f) - 0.055f; | |||||
| if (src.g > 0.0031308f) | |||||
| ret.g = 1.055f * pow(src.g, 1.0f / 2.4f) - 0.055f; | |||||
| if (src.b > 0.0031308f) | |||||
| ret.b = 1.055f * pow(src.b, 1.0f / 2.4f) - 0.055f; | |||||
| return ret; | |||||
| } | |||||
| static vec4 LinearRGBTosRGB(vec4 src) | |||||
| { | |||||
| return vec4(LinearRGBTosRGB(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert sRGB to linear RGB | |||||
| */ | |||||
| static vec3 sRGBToLinearRGB(vec3 src) | |||||
| { | |||||
| vec3 ret = 1.0f / 12.92f * src; | |||||
| if (src.r > 0.04045f) | |||||
| ret.r = pow(src.r + 0.055f, 2.4f) / pow(1.055f, 2.4f); | |||||
| if (src.g > 0.04045f) | |||||
| ret.g = pow(src.g + 0.055f, 2.4f) / pow(1.055f, 2.4f); | |||||
| if (src.b > 0.04045f) | |||||
| ret.b = pow(src.b + 0.055f, 2.4f) / pow(1.055f, 2.4f); | |||||
| return ret; | |||||
| } | |||||
| static vec4 sRGBToLinearRGB(vec4 src) | |||||
| { | |||||
| return vec4(sRGBToLinearRGB(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert linear RGB to YUV | |||||
| */ | |||||
| static vec3 RGBToYUV(vec3 src) | |||||
| { | |||||
| mat3 m(vec3(0.299f, -0.14713f, 0.615f), | |||||
| vec3(0.587f, -0.28886f, -0.51499f), | |||||
| vec3(0.114f, 0.436f, -0.10001f)); | |||||
| vec3 tmp = m * src; | |||||
| tmp.r = (tmp.r * 220.f + 16.f) / 255.f; | |||||
| tmp.g += 0.5f; | |||||
| tmp.b += 0.5f; | |||||
| return clamp(tmp, 0.f, 1.f); | |||||
| } | |||||
| static vec4 RGBToYUV(vec4 src) | |||||
| { | |||||
| return vec4(RGBToYUV(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert YUV to linear RGB | |||||
| */ | |||||
| static vec3 YUVToRGB(vec3 src) | |||||
| { | |||||
| src.r = (src.r * 255.f - 16.f) / 220.f; | |||||
| src.g -= 0.5f; | |||||
| src.b -= 0.5f; | |||||
| mat3 m(vec3(1.f, 1.f, 1.f), | |||||
| vec3(0.f, -0.39465f, 2.03211f), | |||||
| vec3(1.13983f, -0.58060f, 0.f)); | |||||
| return clamp(m * src, 0.f, 1.f); | |||||
| } | |||||
| static vec4 YUVToRGB(vec4 src) | |||||
| { | |||||
| return vec4(YUVToRGB(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert linear HSV to linear RGB | |||||
| */ | |||||
| static vec3 HSVToRGB(vec3 src) | |||||
| { | |||||
| vec3 tmp = vec3(-1.f + abs(6.f * src.x - 3.f), | |||||
| 2.f - abs(6.f * src.x - 2.f), | |||||
| 2.f - abs(6.f * src.x - 4.f)); | |||||
| return src.z * mix(vec3(1.f), clamp(tmp, 0.f, 1.f), src.y); | |||||
| } | |||||
| static vec4 HSVToRGB(vec4 src) | |||||
| { | |||||
| return vec4(HSVToRGB(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert RGB to HSV | |||||
| */ | |||||
| static vec3 RGBToHSV(vec3 src) | |||||
| { | |||||
| float K = 0.f; | |||||
| if (src.g < src.b) | |||||
| src = src.rbg, K = -1.f; | |||||
| if (src.r < src.g) | |||||
| src = src.grb, K = -2.f / 6.f - K; | |||||
| float chroma = src.r - min(src.g, src.b); | |||||
| /* XXX: we use min() here because numerical stability is not | |||||
| * guaranteed with -ffast-math, I’ve seen it fail on i386. */ | |||||
| return vec3(min(abs(K + (src.g - src.b) / (6.f * chroma)), 1.f), | |||||
| chroma / (src.r + 1e-20f), | |||||
| src.r); | |||||
| } | |||||
| static vec4 RGBToHSV(vec4 src) | |||||
| { | |||||
| return vec4(RGBToHSV(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert RGB to HSL | |||||
| */ | |||||
| static vec3 RGBToHSL(vec3 src) | |||||
| { | |||||
| float K = 0.f; | |||||
| if (src.g < src.b) | |||||
| src = src.rbg, K = -1.f; | |||||
| if (src.r < src.g) | |||||
| src = src.grb, K = -2.f / 6.f - K; | |||||
| float chroma = src.r - min(src.g, src.b); | |||||
| float luma = src.r + min(src.g, src.b); | |||||
| /* XXX: we use min() here because numerical stability is not | |||||
| * guaranteed with -ffast-math, I’ve seen it fail on i386. */ | |||||
| float h = min(abs(K + (src.g - src.b) / (6.f * chroma)), 1.f); | |||||
| float s = clamp(chroma / (min(luma, 2.f - luma)), 0.f, 1.f); | |||||
| return vec3(h, s, 0.5f * luma); | |||||
| } | |||||
| static vec4 RGBToHSL(vec4 src) | |||||
| { | |||||
| return vec4(RGBToHSL(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert linear HSV to linear HSL | |||||
| */ | |||||
| static vec3 HSVToHSL(vec3 src) | |||||
| { | |||||
| float tmp = (2 - src.y) * src.z; | |||||
| return vec3(src.x, | |||||
| src.y * src.z / (min(tmp, 2.f - tmp) + 1e-20f), | |||||
| 0.5f * tmp); | |||||
| } | |||||
| static vec4 HSVToHSL(vec4 src) | |||||
| { | |||||
| return vec4(HSVToHSL(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert linear HSL to linear HSV | |||||
| */ | |||||
| static vec3 HSLToHSV(vec3 src) | |||||
| { | |||||
| float tmp = src.y * (0.5f - abs(0.5f - src.z)); | |||||
| return vec3(src.x, 2.f * tmp / (src.z + tmp + 1e-20f), src.z + tmp); | |||||
| } | |||||
| static vec4 HSLToHSV(vec4 src) | |||||
| { | |||||
| return vec4(HSLToHSV(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert linear RGB [0 1] to CIE XYZ [0 100] | |||||
| */ | |||||
| static vec3 LinearRGBToCIEXYZ(vec3 src) | |||||
| { | |||||
| mat3 m(vec3(41.24f, 21.26f, 1.93f), | |||||
| vec3(35.76f, 71.52f, 11.92f), | |||||
| vec3(18.05f, 7.22f, 95.05f)); | |||||
| return m * src; | |||||
| } | |||||
| static vec4 LinearRGBToCIEXYZ(vec4 src) | |||||
| { | |||||
| return vec4(LinearRGBToCIEXYZ(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert CIE XYZ [0 100] to linear RGB [0 1] | |||||
| */ | |||||
| static vec3 CIEXYZToLinearRGB(vec3 src) | |||||
| { | |||||
| mat3 m(vec3( 0.032406f, -0.009689f, 0.000557f), | |||||
| vec3(-0.015372f, 0.018758f, -0.002040f), | |||||
| vec3(-0.004986f, 0.000415f, 0.010570f)); | |||||
| return m * src; | |||||
| } | |||||
| static vec4 CIEXYZToLinearRGB(vec4 src) | |||||
| { | |||||
| return vec4(CIEXYZToLinearRGB(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert CIE XYZ to CIE xyY | |||||
| */ | |||||
| static vec3 CIEXYZToCIExyY(vec3 src) | |||||
| { | |||||
| float tmp = 1.0f / (src.x + src.y + src.z); | |||||
| return vec3(src.x * tmp, src.y * tmp, src.y); | |||||
| } | |||||
| static vec4 CIEXYZToCIExyY(vec4 src) | |||||
| { | |||||
| return vec4(CIEXYZToCIExyY(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert CIE xyY to CIE XYZ | |||||
| */ | |||||
| static vec3 CIExyYToCIEXYZ(vec3 src) | |||||
| { | |||||
| return src.z * vec3(src.x / src.y, | |||||
| 1.0f, | |||||
| (1.0f - src.x - src.y) / src.y); | |||||
| } | |||||
| static vec4 CIExyYToCIEXYZ(vec4 src) | |||||
| { | |||||
| return vec4(CIEXYZToCIExyY(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Convert CIE XYZ to CIE L*a*b* | |||||
| * Note: XYZ values are normalised using a D65 illuminant if | |||||
| * no white value is provided. | |||||
| */ | |||||
| static vec3 CIEXYZToCIELab(vec3 src, vec3 white_value) | |||||
| { | |||||
| float const a = (6.0f * 6.0f * 6.0f) / (29 * 29 * 29); | |||||
| float const b = (29.0f * 29.0f) / (3 * 6 * 6); | |||||
| float const c = 4.0f / 29; | |||||
| float const d = 1.0f / 3; | |||||
| src /= white_value; | |||||
| vec3 f = b * src + vec3(c); | |||||
| if (src.x > a) | |||||
| f.x = pow(src.x, d); | |||||
| if (src.y > a) | |||||
| f.y = pow(src.y, d); | |||||
| if (src.z > a) | |||||
| f.z = pow(src.z, d); | |||||
| return vec3(116.f * f.y - 16.f, | |||||
| 500.f * (f.x - f.y), | |||||
| 200.f * (f.y - f.z)); | |||||
| } | |||||
| static vec3 CIEXYZToCIELab(vec3 src) | |||||
| { | |||||
| return CIEXYZToCIELab(src, vec3(95.047f, 100.f, 108.883f)); | |||||
| } | |||||
| static vec4 CIEXYZToCIELab(vec4 src, vec4 white_value) | |||||
| { | |||||
| return vec4(CIEXYZToCIELab(src.rgb, white_value.rgb), src.a); | |||||
| } | |||||
| static vec4 CIEXYZToCIELab(vec4 src) | |||||
| { | |||||
| return vec4(CIEXYZToCIELab(src.rgb), src.a); | |||||
| } | |||||
| /* | |||||
| * Return distance using the CIEDE2000 metric, | |||||
| * input should be in CIE L*a*b*. | |||||
| */ | |||||
| static float DistanceCIEDE2000(vec3 lab1, vec3 lab2); | |||||
| /* | |||||
| * Convert a wavelength into an xyY fully saturated colour. | |||||
| */ | |||||
| static vec3 WavelengthToCIExyY(float nm); | |||||
| /* | |||||
| * Convert uint color to vec4. | |||||
| */ | |||||
| static vec4 FromRGBA32(uint32_t c); | |||||
| static vec4 FromRGB32(uint32_t c); | |||||
| static vec4 FromRGBA16(uint16_t c); | |||||
| static vec4 FromRGB16(uint16_t c); | |||||
| /* | |||||
| * Convert uint color to vec4. | |||||
| */ | |||||
| static uint32_t ToRGBA32(vec4 c); | |||||
| static uint32_t ToRGB32(vec4 c); | |||||
| static uint16_t ToRGBA16(vec4 c); | |||||
| static uint16_t ToRGB16(vec4 c); | |||||
| /* | |||||
| * Convert colors to hex strings. | |||||
| */ | |||||
| static std::string HexString4Bpp(vec3 c); | |||||
| static std::string HexString4Bpp(vec4 c); | |||||
| static std::string HexString8Bpp(vec3 c); | |||||
| static std::string HexString8Bpp(vec4 c); | |||||
| /* | |||||
| * Convert hex strings to colors. | |||||
| */ | |||||
| static vec4 C8BppHexString(std::string const &c); | |||||
| /* | |||||
| * Some predefined colours | |||||
| */ | |||||
| static const vec4 black, red, green, yellow, blue, magenta, | |||||
| cyan, white, dark_gray, gray, light_gray; | |||||
| }; | |||||
| } /* namespace lol */ | |||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // © 2016—2017 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | // © 2016—2017 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | ||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| @@ -15,12 +15,13 @@ | |||||
| // | // | ||||
| // The Resource class | // The Resource class | ||||
| // --------------- | |||||
| // —————————————————— | |||||
| // | // | ||||
| #include <lol/math/arraynd.h> | #include <lol/math/arraynd.h> | ||||
| #include <lol/math/vector.h> | #include <lol/math/vector.h> | ||||
| #include <lol/math/geometry.h> | #include <lol/math/geometry.h> | ||||
| #include <lol/image/image.h> | |||||
| #include <lol/image/pixel.h> | #include <lol/image/pixel.h> | ||||
| namespace lol | namespace lol | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // © 2014—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | // © 2014—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | ||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| @@ -408,14 +408,14 @@ void Scene::AddTile(TileSet *tileset, int id, mat4 model) | |||||
| m_tile_api.m_tiles.push(t); | m_tile_api.m_tiles.push(t); | ||||
| } | } | ||||
| void Scene::AddLine(vec3 a, vec3 b, vec4 color) | |||||
| void Scene::AddLine(vec3 a, vec3 b, vec4 col) | |||||
| { | { | ||||
| m_line_api.m_lines.push(a, b, color, -1.f, 0xFFFFFFFF, false, false); | |||||
| m_line_api.m_lines.push(a, b, col, -1.f, 0xFFFFFFFF, false, false); | |||||
| } | } | ||||
| void Scene::AddLine(vec3 a, vec3 b, vec4 color, float duration, int mask) | |||||
| void Scene::AddLine(vec3 a, vec3 b, vec4 col, float duration, int mask) | |||||
| { | { | ||||
| m_line_api.m_lines.push(a, b, color, duration, mask, false, false); | |||||
| m_line_api.m_lines.push(a, b, col, duration, mask, false, false); | |||||
| } | } | ||||
| void Scene::AddLight(Light *l) | void Scene::AddLight(Light *l) | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine | // Lol Engine | ||||
| // | // | ||||
| // Copyright © 2010—2019 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // © 2014—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | // © 2014—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | ||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| @@ -19,7 +19,7 @@ | |||||
| // | // | ||||
| #include <memory> | #include <memory> | ||||
| #include <cstdint> | |||||
| #include <stdint.h> | |||||
| #include "tileset.h" | #include "tileset.h" | ||||
| #include "light.h" | #include "light.h" | ||||
| @@ -27,6 +27,7 @@ | |||||
| #include "mesh/mesh.h" | #include "mesh/mesh.h" | ||||
| #include <lol/gpu/renderer.h> | #include <lol/gpu/renderer.h> | ||||
| #include <lol/gpu/framebuffer.h> | |||||
| #include <lol/base/thread.h> | #include <lol/base/thread.h> | ||||
| #define LOL_MAX_LIGHT_COUNT 8 | #define LOL_MAX_LIGHT_COUNT 8 | ||||
| @@ -1,7 +1,7 @@ | |||||
| // | // | ||||
| // Lol Engine — Unit tests | // Lol Engine — Unit tests | ||||
| // | // | ||||
| // Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||||
| // Copyright © 2010—2020 Sam Hocevar <sam@hocevar.net> | |||||
| // | // | ||||
| // Lol Engine is free software. It comes without any warranty, to | // Lol Engine is free software. It comes without any warranty, to | ||||
| // the extent permitted by applicable law. You can redistribute it | // the extent permitted by applicable law. You can redistribute it | ||||
| @@ -71,8 +71,8 @@ lolunit_declare_fixture(color_test) | |||||
| vec3 b(ciede2k[n + 3], ciede2k[n + 4], ciede2k[n + 5]); | vec3 b(ciede2k[n + 3], ciede2k[n + 4], ciede2k[n + 5]); | ||||
| float d1 = ciede2k[n + 6]; | float d1 = ciede2k[n + 6]; | ||||
| float d2 = Color::DistanceCIEDE2000(a, b); | |||||
| float d3 = Color::DistanceCIEDE2000(b, a); | |||||
| float d2 = color::distance_ciede2k(a, b); | |||||
| float d3 = color::distance_ciede2k(b, a); | |||||
| /* Check that our function works, and check that | /* Check that our function works, and check that | ||||
| * it is symmetrical. */ | * it is symmetrical. */ | ||||
| @@ -90,8 +90,8 @@ lolunit_declare_fixture(color_test) | |||||
| for (int b = 0; b < 20; b++) | for (int b = 0; b < 20; b++) | ||||
| { | { | ||||
| vec3 v1 = vec3(r / 20.f, g / 20.f, b / 20.f); | vec3 v1 = vec3(r / 20.f, g / 20.f, b / 20.f); | ||||
| vec3 v2 = Color::RGBToHSV(v1); | |||||
| vec3 v3 = Color::HSVToRGB(v2); | |||||
| vec3 v2 = color::rgb_to_hsv(v1); | |||||
| vec3 v3 = color::hsv_to_rgb(v2); | |||||
| std::string rgb = format("[%f %f %f]", v1.r, v1.g, v1.b); | std::string rgb = format("[%f %f %f]", v1.r, v1.g, v1.b); | ||||
| lolunit_set_context(&rgb[0]); | lolunit_set_context(&rgb[0]); | ||||
| @@ -112,8 +112,8 @@ lolunit_declare_fixture(color_test) | |||||
| for (int b = 0; b < 20; b++) | for (int b = 0; b < 20; b++) | ||||
| { | { | ||||
| vec3 v1 = vec3(r / 20.f, g / 20.f, b / 20.f); | vec3 v1 = vec3(r / 20.f, g / 20.f, b / 20.f); | ||||
| vec3 v2 = Color::RGBToHSL(v1); | |||||
| vec3 v3 = Color::HSVToHSL(Color::RGBToHSV(v1)); | |||||
| vec3 v2 = color::rgb_to_hsl(v1); | |||||
| vec3 v3 = color::hsv_to_hsl(color::rgb_to_hsv(v1)); | |||||
| std::string rgb = format("[%f %f %f]", v1.r, v1.g, v1.b); | std::string rgb = format("[%f %f %f]", v1.r, v1.g, v1.b); | ||||
| lolunit_set_context(&rgb[0]); | lolunit_set_context(&rgb[0]); | ||||