inline Colour RGBAConverter<Colour>::fromRGBA(RGBA const& col, double gamma) { double inverseGamma = 1/gamma; return Colour(gammaCorrect(double(col.r)/255, inverseGamma), gammaCorrect(double(col.g)/255, inverseGamma), gammaCorrect(double(col.b)/255, inverseGamma)); }
inline RGBA RGBAConverter<Colour>::toRGBA (Colour const& data, double gamma) { RGBA col; Colour clampedData(data); clampedData.clamp(); col.r = int(gammaCorrect(clampedData[0], gamma)*255); col.g = int(gammaCorrect(clampedData[1], gamma)*255); col.b = int(gammaCorrect(clampedData[2], gamma)*255); return col; }
void HotNeedleLightControlClass::draw(uint16_t needlePosition) { // Calculate display values for each pixel for (uint16_t p = 0; p < NEOPIXEL_COUNT; p++) { float backgroundRatio = (float)(fadeFrames - ledCounters[p]) / fadeFrames; float foregroundRatio = 1.0 - backgroundRatio; for (uint8_t c = 0; c < COLOR_BYTES; c++) { if (useHighlight) { // Foreground color is background color * highlight multiplier // Make sure we don't wrap past 255 int bg = backgroundColors[p][c] * highlightMultiplier; if (bg > 255) { bg = 255; } ledCurrentColors[p][c] = gammaCorrect((foregroundRatio * bg) + (backgroundRatio * backgroundColors[p][c])); } else { ledCurrentColors[p][c] = gammaCorrect((foregroundRatio * hotNeedleColor[c]) + (backgroundRatio * backgroundColors[p][c])); } } strip->setPixelColor(p, ledCurrentColors[p][RED], ledCurrentColors[p][GREEN], ledCurrentColors[p][BLUE]); } if(useMaximum){ updateMaximum(needlePosition); drawMaximum(); } if(useMinimum){ updateMinimum(needlePosition); drawMinimum(); } strip->show(); }
/** Update the color/alpha look-up table. Note: glColorTableSGI can have a maximum width of 1024 RGBA entries on IR2 graphics! @param dist slice distance relative to 3D texture sample point distance (1.0 for original distance, 0.0 for all opaque). */ void vvStingray::updateLUT(float dist) { vvDebugMsg::msg(1, "Generating texture LUT. Slice distance = ", dist); //cerr << "updateLUT called" << endl; float corr[4]; // gamma/alpha corrected RGBA values [0..1] int lutEntries; // number of entries in the RGBA lookup table int i,c; lutEntries = 256; assert(lutEntries <= 4096); // rgbaTF and rgbaLUT are limited to this size // Copy LUT entries while gamma and opacity correcting: for (i=0; i<lutEntries; ++i) { // Gamma correction: if (gammaCorrection) { corr[0] = gammaCorrect(rgbaTF[i * 4], VV_RED); corr[1] = gammaCorrect(rgbaTF[i * 4 + 1], VV_GREEN); corr[2] = gammaCorrect(rgbaTF[i * 4 + 2], VV_BLUE); } else { corr[0] = rgbaTF[i * 4]; corr[1] = rgbaTF[i * 4 + 1]; corr[2] = rgbaTF[i * 4 + 2]; } corr[3] = rgbaTF[i * 4 + 3]; // Convert float to uchar and copy to rgbaLUT array: for (c=0; c<4; ++c) { rgbaLUT[i * 4 + c] = (uchar)(corr[c] * 255.0f); } } // Copy LUT to graphics card: _stingRay->setLUT(rgbaLUT); }
void displayCathedral(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glColor3f(1.0, 1.0, 1.0); /* clear the screen to black */ glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); float A = (-.2 + .2/512.f)/2.f; ray r = ray(triple(0.f, -10.f, 0.f), spaceVector(.1, A, A), 0.f, FLT_MAX); spaceVector deltaZ = spaceVector(0.f, 0.f, .2/512.0); spaceVector deltaY = spaceVector(0.f, .2/512.0, 0.f); ray temp; ray normRay; seenPair pair; float * color = new float[3]; for (int j = 0; j < 512; j++) { temp = r; gJ = j; for (int i = 0; i < 512; i++) { gI = i; normRay = temp.normalized(); tShootRay(normRay, color); gammaCorrect(color, .454545); glColor3fv((GLfloat *) color); glVertex2i(i, j); temp = temp.changeDirection(deltaZ); } r = r.changeDirection(deltaY); } delete[] color; glEnd(); glFlush(); return; }