// Because file only specifies a number of control points, a full color table must be made from these control points by linearly interpolating void TransferFunction::LoadLookup(std::vector<glm::vec4> &colorTable) { glm::vec4 previousColor(0.0f); float previousIntensity = 0.0f; int next = 0; for (int i=0; i<256; i++) { float currentIntensity = (float)i / (float)255; while (next < numIntensities && currentIntensity > intensities[next]) { previousIntensity = intensities[next]; previousColor = colors[next]; next++; } if (next < numIntensities) colorTable[i] = LERPColor(previousColor, colors[next], previousIntensity, intensities[next], currentIntensity); else colorTable[i] = LERPColor(previousColor, glm::vec4(0.0f), previousIntensity, 1.0f, currentIntensity); } CopyToTex(colorTable); }
void TransferFunction::loadLookup() { glm::vec4 previousColor(0.0f); float previousIntensity = 0.0f; int next = 0; for (int i=0; i<TRANSFER_FN_TABLE_SIZE; i++) { float currentIntensity = (float)i / (float)255; while (next < m_numIntensities && currentIntensity > m_intensities[next]) { previousIntensity = m_intensities[next]; previousColor = m_colors[next]; next++; } if (next < m_numIntensities) m_colorTable[i] = LERPColor(previousColor, m_colors[next], previousIntensity, m_intensities[next], currentIntensity); else m_colorTable[i] = LERPColor(previousColor, glm::vec4(0.0f), previousIntensity, 1.0f, currentIntensity); } }