From 6702151ac6a806d916403b2a60e3dc1e52b712aa Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Thu, 22 Aug 2013 02:13:01 -0700 Subject: [PATCH] Add cubic gamma correction on brightness --- MarkSlee.pde | 29 +++++++++++++++++++++++++++++ TestPatterns.pde | 24 ------------------------ _Internals.pde | 13 ++++++++++--- _Mappings.pde | 19 ++++++++++++------- 4 files changed, 51 insertions(+), 34 deletions(-) diff --git a/MarkSlee.pde b/MarkSlee.pde index 68d8de1..a67f719 100644 --- a/MarkSlee.pde +++ b/MarkSlee.pde @@ -705,3 +705,32 @@ class Traktor extends SCPattern { } } } + +class ColorFuckerEffect extends SCEffect { + + BasicParameter hueShift = new BasicParameter("HSHFT", 0); + BasicParameter sat = new BasicParameter("SAT", 1); + BasicParameter bright = new BasicParameter("BRT", 1); + + ColorFuckerEffect(GLucose glucose) { + super(glucose); + addParameter(hueShift); + addParameter(bright); + addParameter(sat); + } + + public void doApply(int[] colors) { + float bMod = bright.getValuef(); + float sMod = sat.getValuef(); + float hMod = hueShift.getValuef(); + if (bMod < 1 || sMod < 1 || hMod > 0) { + for (int i = 0; i < colors.length; ++i) { + colors[i] = color( + (hue(colors[i]) + hueShift.getValuef()*360.) % 360, + saturation(colors[i]) * sat.getValuef(), + brightness(colors[i]) * bright.getValuef() + ); + } + } + } +} diff --git a/TestPatterns.pde b/TestPatterns.pde index ab90d21..b2e49f1 100644 --- a/TestPatterns.pde +++ b/TestPatterns.pde @@ -259,30 +259,6 @@ class TestProjectionPattern extends TestPattern { } } -class ColorFuckerEffect extends SCEffect { - - BasicParameter hueShift = new BasicParameter("HSHFT", 0); - BasicParameter sat = new BasicParameter("SAT", 1); - BasicParameter bright = new BasicParameter("BRT", 1); - - ColorFuckerEffect(GLucose glucose) { - super(glucose); - addParameter(hueShift); - addParameter(bright); - addParameter(sat); - } - - public void doApply(int[] colors) { - for (int i = 0; i < colors.length; ++i) { - colors[i] = color( - (hue(colors[i]) + hueShift.getValuef()*360.) % 360, - saturation(colors[i]) * sat.getValuef(), - brightness(colors[i]) * bright.getValuef() - ); - } - } -} - class TestCubePattern extends TestPattern { private SawLFO index = new SawLFO(0, Cube.POINTS_PER_CUBE, Cube.POINTS_PER_CUBE*60); diff --git a/_Internals.pde b/_Internals.pde index 8b2e3da..a358f1b 100644 --- a/_Internals.pde +++ b/_Internals.pde @@ -204,9 +204,16 @@ void draw() { debugUI.draw(); } - // TODO(dan): if you want to, here would be a good place to - // put in gamma correction, modifying the colors that get - // sent to the pandaboards, without mucking up the UI here + // Gamma correction here. Apply a cubic to the brightness + // for better representation of dynamic range + for (int i = 0; i < colors.length; ++i) { + float b = brightness(colors[i]) / 100.f; + colors[i] = color( + hue(colors[i]), + saturation(colors[i]), + (b*b*b) * 100. + ); + } // TODO(mcslee): move into GLucose engine for (PandaDriver p : pandaBoards) { diff --git a/_Mappings.pde b/_Mappings.pde index 01aaa2a..3932f0b 100644 --- a/_Mappings.pde +++ b/_Mappings.pde @@ -124,17 +124,22 @@ public PandaMapping[] buildPandaList() { return new PandaMapping[] { new PandaMapping( "10.200.1.29", new ChannelMapping[] { - new ChannelMapping(), - new ChannelMapping(), - new ChannelMapping(), - new ChannelMapping(), - new ChannelMapping(), - new ChannelMapping(), - new ChannelMapping(), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), new ChannelMapping(ChannelMapping.MODE_BASS), new ChannelMapping(ChannelMapping.MODE_STRUTS_AND_FLOOR), new ChannelMapping(ChannelMapping.MODE_SPEAKER, LEFT_SPEAKER), new ChannelMapping(ChannelMapping.MODE_SPEAKER, RIGHT_SPEAKER), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), + new ChannelMapping(ChannelMapping.MODE_CUBES, new int[] { 1, 2, 3, 4 }), }), new PandaMapping( -- 2.34.1