From 4efa5a97f931d1d29757fac3198bb4991dd219de Mon Sep 17 00:00:00 2001 From: Ken Martin <ken.martin@kitware.com> Date: Fri, 27 Oct 2017 08:54:57 -0400 Subject: [PATCH] fixes for wide line clipping and mipmap filtering wide lines or other objects using the geometry shader were not being clipped. This fixes that. Mipmaped linear textures were using linearmipmapnearest when they should default to linearmipmaplinear. --- Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx | 44 +++++++++++++++---- Rendering/OpenGL2/vtkOpenGLTexture.cxx | 2 +- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx b/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx index b8166ea1875..2ec88b9baf6 100644 --- a/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx +++ b/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx @@ -1068,6 +1068,7 @@ void vtkOpenGLPolyDataMapper::ReplaceShaderClip( { std::string VSSource = shaders[vtkShader::Vertex]->GetSource(); std::string FSSource = shaders[vtkShader::Fragment]->GetSource(); + std::string GSSource = shaders[vtkShader::Geometry]->GetSource(); if (this->GetNumberOfClippingPlanes()) { @@ -1079,15 +1080,39 @@ void vtkOpenGLPolyDataMapper::ReplaceShaderClip( numClipPlanes = 6; } - vtkShaderProgram::Substitute(VSSource, "//VTK::Clip::Dec", - "uniform int numClipPlanes;\n" - "uniform vec4 clipPlanes[6];\n" - "varying float clipDistancesVSOutput[6];"); - vtkShaderProgram::Substitute(VSSource, "//VTK::Clip::Impl", - "for (int planeNum = 0; planeNum < numClipPlanes; planeNum++)\n" - " {\n" - " clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);\n" - " }\n"); + // geometry shader impl + if (GSSource.length()) + { + vtkShaderProgram::Substitute(VSSource, "//VTK::Clip::Dec", + "varying vec4 clipVertexMC;"); + vtkShaderProgram::Substitute(VSSource, "//VTK::Clip::Impl", + " clipVertexMC = vertexMC;\n"); + vtkShaderProgram::Substitute(GSSource, + "//VTK::Clip::Dec", + "uniform int numClipPlanes;\n" + "uniform vec4 clipPlanes[6];\n" + "in vec4 clipVertexMC[];\n" + "out float clipDistancesGSOutput[6];"); + vtkShaderProgram::Substitute(GSSource, + "//VTK::Clip::Impl", + "for (int planeNum = 0; planeNum < numClipPlanes; planeNum++)\n" + " {\n" + " clipDistancesGSOutput[planeNum] = dot(clipPlanes[planeNum], clipVertexMC[i]);\n" + " }\n"); + } + else // vertex shader impl + { + vtkShaderProgram::Substitute(VSSource, "//VTK::Clip::Dec", + "uniform int numClipPlanes;\n" + "uniform vec4 clipPlanes[6];\n" + "varying float clipDistancesVSOutput[6];"); + vtkShaderProgram::Substitute(VSSource, "//VTK::Clip::Impl", + "for (int planeNum = 0; planeNum < numClipPlanes; planeNum++)\n" + " {\n" + " clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);\n" + " }\n"); + } + vtkShaderProgram::Substitute(FSSource, "//VTK::Clip::Dec", "uniform int numClipPlanes;\n" "varying float clipDistancesVSOutput[6];"); @@ -1099,6 +1124,7 @@ void vtkOpenGLPolyDataMapper::ReplaceShaderClip( } shaders[vtkShader::Vertex]->SetSource(VSSource); shaders[vtkShader::Fragment]->SetSource(FSSource); + shaders[vtkShader::Geometry]->SetSource(GSSource); } void vtkOpenGLPolyDataMapper::ReplaceShaderNormal( diff --git a/Rendering/OpenGL2/vtkOpenGLTexture.cxx b/Rendering/OpenGL2/vtkOpenGLTexture.cxx index 10cd78543cc..1e553b72689 100644 --- a/Rendering/OpenGL2/vtkOpenGLTexture.cxx +++ b/Rendering/OpenGL2/vtkOpenGLTexture.cxx @@ -332,7 +332,7 @@ void vtkOpenGLTexture::Load(vtkRenderer *ren) if (this->Mipmap && levels > 1 && (!this->CubeMap || majorV >= 4)) { - this->TextureObject->SetMinificationFilter(vtkTextureObject::LinearMipmapNearest); + this->TextureObject->SetMinificationFilter(vtkTextureObject::LinearMipmapLinear); this->TextureObject->SetMaxLevel(levels - 1); this->TextureObject->SendParameters(); glGenerateMipmap(this->TextureObject->GetTarget()); -- GitLab