In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

Various improvements/fixes in general raycaster infrastructure:

* Disabled LOD-based gradients since their effect is somewhat questionable, they slow down the rendering and lead to artifacts in some case.
* Removed LOD option from ProcessorDecoratorGradient
* Added OpenGL and GLSL versions up to 4.5 to cgt::GpuCapabilities
parent e53955a4
......@@ -46,7 +46,11 @@ vec3 computeGradientForwardDifferencesLod(in sampler3D tex, in TextureParameters
* \param texCoords Lookup position in texture coordinates
*/
vec3 computeGradientForwardDifferences(in sampler3D tex, in TextureParameters3D texParams, in vec3 texCoords) {
return computeGradientForwardDifferencesLod(tex, texParams, texCoords, 0.0);
float v = texture(tex, texCoords).r;
float dx = textureOffset(tex, texCoords, ivec3(1, 0, 0)).r;
float dy = textureOffset(tex, texCoords, ivec3(0, 1, 0)).r;
float dz = textureOffset(tex, texCoords, ivec3(0, 0, 1)).r;
return vec3(dx - v, dy - v, dz - v) * texParams._voxelSize;
}
/**
......@@ -73,7 +77,13 @@ vec3 computeGradientCentralDifferencesLod(in sampler3D tex, in TextureParameters
* \param texCoords Lookup position in texture coordinates
*/
vec3 computeGradientCentralDifferences(in sampler3D tex, in TextureParameters3D texParams, in vec3 texCoords) {
return computeGradientCentralDifferencesLod(tex, texParams, texCoords, 0.0);
float dx = textureOffset(tex, texCoords, ivec3(1, 0, 0)).r;
float dy = textureOffset(tex, texCoords, ivec3(0, 1, 0)).r;
float dz = textureOffset(tex, texCoords, ivec3(0, 0, 1)).r;
float mdx = textureOffset(tex, texCoords, ivec3(-1, 0, 0)).r;
float mdy = textureOffset(tex, texCoords, ivec3(0, -1, 0)).r;
float mdz = textureOffset(tex, texCoords, ivec3(0, 0, -1)).r;
return vec3(dx - mdx, dy - mdy, dz - mdz) * texParams._voxelSize * 0.5;
}
......
......@@ -38,10 +38,8 @@ namespace campvis {
ProcessorDecoratorGradient::ProcessorDecoratorGradient()
: AbstractProcessorDecorator()
, p_gradientMethod("GradientMethod", "Gradient Computation Method", gradientOptions, 4)
, p_lod("GradientLod", "LOD for Gradient Computation", 0.5f, 0.f, 5.f, .1f, 1)
{
p_gradientMethod.setValue(1);
p_gradientMethod.s_changed.connect(this, &ProcessorDecoratorGradient::onGradientMethodChanged);
}
ProcessorDecoratorGradient::~ProcessorDecoratorGradient() {
......@@ -50,19 +48,16 @@ namespace campvis {
void ProcessorDecoratorGradient::addProperties(AbstractProcessor* propCollection) {
propCollection->addProperty(p_gradientMethod, AbstractProcessor::INVALID_SHADER | AbstractProcessor::INVALID_RESULT);
propCollection->addProperty(p_lod);
}
std::string ProcessorDecoratorGradient::generateHeader() const {
std::string toReturn;
switch (p_gradientMethod.getOptionValue()) {
case ForwardDifferences:
toReturn.append("#define computeGradient(tex, texParams, texCoords) computeGradientForwardDifferencesLod(tex, texParams, texCoords, _gradientLod)\n");
toReturn.append("uniform float _gradientLod = 0.0;\n");
toReturn.append("#define computeGradient(tex, texParams, texCoords) computeGradientForwardDifferences(tex, texParams, texCoords)\n");
break;
case CentralDifferences:
toReturn.append("#define computeGradient(tex, texParams, texCoords) computeGradientCentralDifferencesLod(tex, texParams, texCoords, _gradientLod)\n");
toReturn.append("uniform float _gradientLod = 0.0;\n");
toReturn.append("#define computeGradient(tex, texParams, texCoords) computeGradientCentralDifferences(tex, texParams, texCoords)\n");
break;
case FilteredCentralDifferences:
toReturn.append("#define computeGradient(tex, texParams, texCoords) computeGradientFilteredCentralDifferences(tex, texParams, texCoords)\n");
......@@ -78,14 +73,4 @@ namespace campvis {
return toReturn;
}
void ProcessorDecoratorGradient::renderProlog(const DataContainer& dataContainer, cgt::Shader* shader) {
if (p_gradientMethod.getOptionValue() == ForwardDifferences || p_gradientMethod.getOptionValue() == CentralDifferences) {
shader->setUniform("_gradientLod", p_lod.getValue());
}
}
void ProcessorDecoratorGradient::onGradientMethodChanged(const AbstractProperty* prop) {
p_lod.setVisible(p_gradientMethod.getOptionValue() == ForwardDifferences || p_gradientMethod.getOptionValue() == CentralDifferences);
}
}
......@@ -59,16 +59,10 @@ namespace campvis {
protected:
/// \see AbstractProcessorDecorator::addProperties()
void addProperties(AbstractProcessor* propCollection);
/// \see AbstractProcessorDecorator::renderProlog()
virtual void renderProlog(const DataContainer& dataContainer, cgt::Shader* shader);
/// \see AbstractProcessorDecorator::generateHeader()
std::string generateHeader() const;
/// Callback method when p_gradientMethod has changed
void onGradientMethodChanged(const AbstractProperty* prop);
GenericOptionProperty<GradientMethod> p_gradientMethod; ///< Method for calculating the gradients
FloatProperty p_lod; ///< LOD to use for texture lookup during gradient computation
};
......
......@@ -95,17 +95,6 @@ namespace campvis {
if (img != nullptr && entryPoints != nullptr && exitPoints != nullptr && camera != nullptr) {
if (img->getDimensionality() == 3) {
// little hack to support LOD texture lookup for the gradients:
// if texture does not yet have mipmaps, create them.
const cgt::Texture* tex = img->getTexture();
if (tex->getFilter() != cgt::Texture::MIPMAP) {
const_cast<cgt::Texture*>(tex)->setFilter(cgt::Texture::MIPMAP);
glGenerateMipmap(GL_TEXTURE_3D);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
LGL_ERROR;
}
_shader->activate();
_shader->setIgnoreUniformLocationError(true);
......
......@@ -472,6 +472,9 @@ const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::CGT_GL_VERSION_3_3(
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::CGT_GL_VERSION_4_0(4,0,0);
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::CGT_GL_VERSION_4_1(4,1,0);
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::CGT_GL_VERSION_4_2(4,2,0);
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::CGT_GL_VERSION_4_3(4,3,0);
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::CGT_GL_VERSION_4_4(4,4,0);
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::CGT_GL_VERSION_4_5(4,5,0);
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::SHADER_VERSION_110(1,10); ///< GLSL version 1.10
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::SHADER_VERSION_120(1,20); ///< GLSL version 1.20
......@@ -482,6 +485,9 @@ const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::SHADER_VERSION_330(
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::SHADER_VERSION_400(4, 0); ///< GLSL version 4.00
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::SHADER_VERSION_410(4,10); ///< GLSL version 4.10
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::SHADER_VERSION_420(4,20); ///< GLSL version 4.20
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::SHADER_VERSION_430(4,30); ///< GLSL version 4.30
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::SHADER_VERSION_440(4,40); ///< GLSL version 4.40
const GpuCapabilities::GlVersion GpuCapabilities::GlVersion::SHADER_VERSION_450(4,50); ///< GLSL version 4.50
GpuCapabilities::GlVersion::GlVersion(int major, int minor, int release)
: major_(major), minor_(minor), release_(release)
......
......@@ -114,6 +114,9 @@ public:
static const GlVersion CGT_GL_VERSION_4_0;
static const GlVersion CGT_GL_VERSION_4_1;
static const GlVersion CGT_GL_VERSION_4_2;
static const GlVersion CGT_GL_VERSION_4_3;
static const GlVersion CGT_GL_VERSION_4_4;
static const GlVersion CGT_GL_VERSION_4_5;
static const GlVersion SHADER_VERSION_110; ///< GLSL version 1.10
static const GlVersion SHADER_VERSION_120; ///< GLSL version 1.20
......@@ -124,6 +127,9 @@ public:
static const GlVersion SHADER_VERSION_400; ///< GLSL version 4.00
static const GlVersion SHADER_VERSION_410; ///< GLSL version 4.10
static const GlVersion SHADER_VERSION_420; ///< GLSL version 4.20
static const GlVersion SHADER_VERSION_430; ///< GLSL version 4.30
static const GlVersion SHADER_VERSION_440; ///< GLSL version 4.40
static const GlVersion SHADER_VERSION_450; ///< GLSL version 4.50
};
......
......@@ -73,6 +73,7 @@ const float SAMPLING_BASE_INTERVAL_RCP = 200.0;
vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords) {
vec4 result = vec4(0.0);
vec3 direction = exitPoint - entryPoint;
float len = length(direction);
// Adjust direction a bit to prevent division by zero
direction.x = (abs(direction.x) < 0.0000001) ? 0.0000001 : direction.x;
......@@ -129,7 +130,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
}
// advance to the next evaluation point along the ray
tNear += _samplingStepSize;
tNear += _samplingStepSize / len;
}
......
......@@ -55,8 +55,6 @@ namespace campvis {
}
void AdvOptimizedRaycaster::init() {
RaycastingProcessor::init();
_vhm = new VoxelHierarchyMapper();
......@@ -84,10 +82,6 @@ namespace campvis {
ScopedTypedData<LightSourceData> light(data, p_lightId.getValue());
if (p_enableShading.getValue() == false || light != nullptr) {
// undo MIPMAP hack from RaycastingProcessor, as mipmapping results in artifacts during ray clipping...
if (image->getTexture()->getFilter() != cgt::Texture::LINEAR)
const_cast<cgt::Texture*>(image->getTexture())->setFilter(cgt::Texture::LINEAR);
_shader->activate();
cgt::TextureUnit xorUnit, bbvUnit;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment