bool VolumeRaycaster::bindVolumes(tgt::Shader* shader, const std::vector<VolumeStruct> &volumes, const tgt::Camera* camera, const tgt::vec4& lightPosition) { if (!VolumeRenderer::bindVolumes(shader, volumes, camera, lightPosition)) return false; shader->setIgnoreUniformLocationError(true); //TODO: This uses the first volume to set the step size. Could be changed so that step // size is calculated for each volume, but shaders need to be adapted as well to have volume // parameters available in ray setup and compositing. joerg if (volumes.size() > 0) { if (!volumes[0].volume_ || !volumes[0].volume_->getRepresentation<VolumeGL>() || !volumes[0].volume_->getRepresentation<VolumeGL>()->getTexture()) { LWARNING("No volume texture"); } else { shader->setUniform("samplingStepSize_", getSamplingStepSize(volumes[0].volume_)); LGL_ERROR; } } shader->setIgnoreUniformLocationError(false); return true; }
void SingleVolumeRaycaster::process() { // bind transfer function tgt::TextureUnit transferUnit; transferUnit.activate(); LGL_ERROR; ClassificationModes::bindTexture(classificationMode_.get(), transferFunc_.get(), getSamplingStepSize(volumeInport_.getData())); portGroup_.activateTargets(); portGroup_.clearTargets(); LGL_ERROR; // bind entry params tgt::TextureUnit entryUnit, entryDepthUnit, exitUnit, exitDepthUnit; entryPort_.bindTextures(entryUnit, entryDepthUnit); LGL_ERROR; // bind exit params exitPort_.bindTextures(exitUnit, exitDepthUnit); LGL_ERROR; // vector containing the volumes to bind; is passed to bindVolumes() std::vector<VolumeStruct> volumeTextures; // add main volume TextureUnit volUnit; volumeTextures.push_back(VolumeStruct( volumeInport_.getData(), &volUnit, "volume_","volumeStruct_", volumeInport_.getTextureClampModeProperty().getValue(), tgt::vec4(volumeInport_.getTextureBorderIntensityProperty().get()), volumeInport_.getTextureFilterModeProperty().getValue()) ); // initialize shader tgt::Shader* raycastPrg = shaderProp_.getShader(); raycastPrg->activate(); // set common uniforms used by all shaders tgt::Camera cam = camera_.get(); setGlobalShaderParameters(raycastPrg, &cam); // bind the volumes and pass the necessary information to the shader bindVolumes(raycastPrg, volumeTextures, &cam, lightPosition_.get()); // pass the remaining uniforms to the shader raycastPrg->setUniform("entryPoints_", entryUnit.getUnitNumber()); raycastPrg->setUniform("entryPointsDepth_", entryDepthUnit.getUnitNumber()); entryPort_.setTextureParameters(raycastPrg, "entryParameters_"); raycastPrg->setUniform("exitPoints_", exitUnit.getUnitNumber()); raycastPrg->setUniform("exitPointsDepth_", exitDepthUnit.getUnitNumber()); exitPort_.setTextureParameters(raycastPrg, "exitParameters_"); if (compositingMode_.isSelected("iso") || compositingMode1_.isSelected("iso") || compositingMode2_.isSelected("iso") ) raycastPrg->setUniform("isoValue_", isoValue_.get()); if (ClassificationModes::usesTransferFunction(classificationMode_.get())) transferFunc_.get()->setUniform(raycastPrg, "transferFunc_", "transferFuncTex_", transferUnit.getUnitNumber()); if (compositingMode_.isSelected("mida")) raycastPrg->setUniform("gammaValue_", gammaValue_.get()); if (compositingMode1_.isSelected("mida")) raycastPrg->setUniform("gammaValue1_", gammaValue1_.get()); if (compositingMode2_.isSelected("mida")) raycastPrg->setUniform("gammaValue2_", gammaValue2_.get()); LGL_ERROR; { PROFILING_BLOCK("raycasting"); renderQuad(); } raycastPrg->deactivate(); portGroup_.deactivateTargets(); TextureUnit::setZeroUnit(); LGL_ERROR; }