Skip to content
Snippets Groups Projects
Commit 8e554a2e authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri :speech_balloon: Committed by Kitware Robot
Browse files

Merge topic 'floor_plane_scale'


a2d3bb77 Skybox: Add a scale factor for floor texture

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Acked-by: default avatarbuildbot <buildbot@kitware.com>
Merge-request: !11047
parents b680e262 a2d3bb77
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,8 @@ vtkSkybox::vtkSkybox()
this->FloorRight[0] = 1.0;
this->FloorRight[1] = 0.0;
this->FloorRight[2] = 0.0;
this->FloorTexCoordScale[0] = 1.0;
this->FloorTexCoordScale[1] = 1.0;
}
//------------------------------------------------------------------------------
......
......@@ -57,6 +57,18 @@ public:
vtkGetVector3Macro(FloorRight, float);
///@}
///@{
/**
* Set/Get the [u,v] texture coordinate scaling for the floor projection.
* Defaults to [1, 1] i.e. no scaling, which means the floor texture coordinates are computed
* based on the view coordinates of the plane points.
*
* \sa SetProjectionToFloor()
*/
vtkGetVector2Macro(FloorTexCoordScale, float);
vtkSetVector2Macro(FloorTexCoordScale, float);
///@}
///@{
/**
* Define if the colors should be gamma corrected.
......@@ -75,6 +87,7 @@ protected:
int Projection;
float FloorPlane[4];
float FloorRight[3];
float FloorTexCoordScale[2];
bool GammaCorrect = false;
......
......@@ -92,6 +92,7 @@ void vtkOpenGLSkybox::UpdateUniforms(vtkObject*, unsigned long, void* calldata)
plane[3] = this->FloorPlane[3] / norm;
program->SetUniform4f("floorPlane", plane);
program->SetUniform3f("floorRight", this->FloorRight);
program->SetUniform2f("floorTCoordScale", this->FloorTexCoordScale);
float front[3];
vtkMath::Cross(plane, this->FloorRight, front);
program->SetUniform3f("floorFront", front);
......@@ -177,9 +178,10 @@ void vtkOpenGLSkybox::Render(vtkRenderer* ren, vtkMapper* mapper)
if (this->Projection == vtkSkybox::Floor)
{
vtkShaderProgram::Substitute(str, "//VTK::Projection::Dec",
"uniform vec4 floorPlane;\n" // floor plane eqn
"uniform vec3 floorRight;\n" // floor plane right
"uniform vec3 floorFront;\n" // floor plane front
"uniform vec4 floorPlane;\n" // floor plane eqn
"uniform vec3 floorRight;\n" // floor plane right
"uniform vec3 floorFront;\n" // floor plane front
"uniform vec2 floorTCoordScale;\n" // floor texture scale
"uniform mat4 MCDCMatrix;\n"
"uniform sampler2D actortexture;\n");
......@@ -193,7 +195,7 @@ void vtkOpenGLSkybox::Render(vtkRenderer* ren, vtkMapper* mapper)
" if (t >= 0.0) {\n"
" vec3 pos = dirv*t - p0l0;\n"
" vec4 color = texture(actortexture, "
"vec2(dot(floorRight,pos), dot(floorFront, pos)));\n"
"vec2(dot(floorRight,pos)/floorTCoordScale.x, dot(floorFront, pos)/floorTCoordScale.y));\n"
" //VTK::Gamma::Impl\n"
// The discards cause a discontinuity with mipmapping
// on the horizon of the floor. So we fade out the floor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment