Commit bbc96ed3 authored by Ken Martin's avatar Ken Martin

provide support for existing multitexture calls

The old MapDataArrayTGoMultiTexture relied on
being able to lock dowwn a specific texture unit
which cannot be guaranteed as external code
or render passes may bne uising that texture unit.

Instead we support the method having the name of a texture
along with the matching ethod in vtkProperty to name
a texture. Between these two users can assign texture
coordinate arrays to specific textures.

Deprecated the old index and unit based methods.
Removed a no longer needed vtkTexture.h include
which may bite some folks who are using vtkTexture
but not including the header (which they shoudl do)
parent 4cb59514
......@@ -27,6 +27,7 @@
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkTestUtilities.h>
#include <vtkTexture.h>
#include <vtkTubeFilter.h>
namespace
......
......@@ -31,6 +31,7 @@
#include "vtkSmartPointer.h"
#include "vtkStdString.h"
#include "vtkTestUtilities.h"
#include "vtkTexture.h"
#include "vtkTransform.h"
#include <vtksys/SystemTools.hxx>
......
......@@ -50,6 +50,7 @@
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSmartPointer.h"
#include "vtkTexture.h"
#include "vtkTimerLog.h"
#include "vtkTransformFilter.h"
#include "vtkXMLPolyDataWriter.h"
......@@ -341,11 +342,11 @@ void vtkGeoTerrain::AddActors(
sameTexture = (
!textureNode1 ||
actor->GetProperty()->GetNumberOfTextures() < 1 ||
actor->GetProperty()->GetTexture(vtkProperty::VTK_TEXTURE_UNIT_0) == textureNode1->GetTexture()
actor->GetProperty()->GetTexture("VTK_TEXTURE_UNIT_0") == textureNode1->GetTexture()
) && (
!textureNode2 ||
actor->GetProperty()->GetNumberOfTextures() < 2 ||
actor->GetProperty()->GetTexture(vtkProperty::VTK_TEXTURE_UNIT_1) == textureNode2->GetTexture()
actor->GetProperty()->GetTexture("VTK_TEXTURE_UNIT_1") == textureNode2->GetTexture()
);
}
else
......@@ -387,17 +388,17 @@ void vtkGeoTerrain::AddActors(
if (multiTexturing && textureUnits > 1)
{
// Multi texturing
mapper->MapDataArrayToMultiTextureAttribute(vtkProperty::VTK_TEXTURE_UNIT_0,
mapper->MapDataArrayToMultiTextureAttribute("VTK_TEXTURE_UNIT_0",
"LatLong", vtkDataObject::FIELD_ASSOCIATION_POINTS);
textureNode1->GetTexture()->SetBlendingMode(vtkTexture::VTK_TEXTURE_BLENDING_MODE_REPLACE);
actor->GetProperty()->SetTexture(vtkProperty::VTK_TEXTURE_UNIT_0, textureNode1->GetTexture());
actor->GetProperty()->SetTexture("VTK_TEXTURE_UNIT_0", textureNode1->GetTexture());
if (textureNode2)
{
mapper->MapDataArrayToMultiTextureAttribute(vtkProperty::VTK_TEXTURE_UNIT_1,
mapper->MapDataArrayToMultiTextureAttribute("VTK_TEXTURE_UNIT_1",
"LatLong", vtkDataObject::FIELD_ASSOCIATION_POINTS);
textureNode2->GetTexture()->SetBlendingMode(vtkTexture::VTK_TEXTURE_BLENDING_MODE_ADD);
actor->GetProperty()->SetTexture(vtkProperty::VTK_TEXTURE_UNIT_1, textureNode2->GetTexture());
actor->GetProperty()->SetTexture("VTK_TEXTURE_UNIT_1", textureNode2->GetTexture());
}
}
else
......@@ -438,11 +439,11 @@ void vtkGeoTerrain::AddActors(
sameTexture = (
!textureNode1 ||
actor->GetProperty()->GetNumberOfTextures() < 1 ||
actor->GetProperty()->GetTexture(vtkProperty::VTK_TEXTURE_UNIT_0) == textureNode1->GetTexture()
actor->GetProperty()->GetTexture("VTK_TEXTURE_UNIT_0") == textureNode1->GetTexture()
) && (
!textureNode2 ||
actor->GetProperty()->GetNumberOfTextures() < 2 ||
actor->GetProperty()->GetTexture(vtkProperty::VTK_TEXTURE_UNIT_1) == textureNode2->GetTexture()
actor->GetProperty()->GetTexture("VTK_TEXTURE_UNIT_1") == textureNode2->GetTexture()
);
}
else
......
......@@ -36,6 +36,7 @@
#include "vtkProperty.h"
#include "vtkRenderWindow.h"
#include "vtkRendererCollection.h"
#include "vtkTexture.h"
#include "vtkTransform.h"
#include "vtkTriangleFilter.h"
#include "vtkXMLPolyDataWriter.h"
......
......@@ -20,6 +20,7 @@
#include "vtkProperty.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkTexture.h"
#include "vtksys/SystemTools.hxx"
#include "vtkTransform.h"
......
......@@ -28,6 +28,7 @@
#include "vtkTexturedActor2D.h"
#include "vtkTextMapper.h"
#include "vtkTextProperty.h"
#include "vtkTexture.h"
#include "vtkTransform.h"
#include "vtkTransformPolyDataFilter.h"
#include "vtkViewport.h"
......
......@@ -89,7 +89,7 @@ int TestTStripsColorsTCoords(int argc, char *argv[])
polyData->Delete();
vtkActor *actor = vtkActor::New();
actor->GetProperty()->SetTexture("texture",texture);
actor->GetProperty()->SetTexture("mytexture",texture);
texture->Delete();
actor->SetMapper(mapper);
mapper->Delete();
......
......@@ -88,7 +88,7 @@ int TestTStripsNormalsColorsTCoords(int argc, char *argv[])
polyData->Delete();
vtkActor *actor = vtkActor::New();
actor->GetProperty()->SetTexture("texture",texture);
actor->GetProperty()->SetTexture("mytexture",texture);
texture->Delete();
actor->SetMapper(mapper);
mapper->Delete();
......
......@@ -71,7 +71,7 @@ int TestTStripsNormalsTCoords(int argc, char *argv[])
polyData->Delete();
vtkActor *actor = vtkActor::New();
actor->GetProperty()->SetTexture("texture",texture);
actor->GetProperty()->SetTexture("mytexture",texture);
texture->Delete();
actor->SetMapper(mapper);
mapper->Delete();
......
......@@ -72,7 +72,7 @@ int TestTStripsTCoords(int argc, char *argv[])
polyData->Delete();
vtkActor *actor = vtkActor::New();
actor->GetProperty()->SetTexture("texture",texture);
actor->GetProperty()->SetTexture("mytexture",texture);
texture->Delete();
actor->SetMapper(mapper);
mapper->Delete();
......
......@@ -183,13 +183,25 @@ void vtkPolyDataMapper::MapDataArrayToVertexAttribute(
vtkErrorMacro("Not implemented at this level...");
}
//----------------------------------------------------------------------------
#ifndef VTK_LEGACY_REMOVE
void vtkPolyDataMapper::MapDataArrayToMultiTextureAttribute(
int vtkNotUsed(unit),
const char* vtkNotUsed(dataArrayName),
int vtkNotUsed(fieldAssociation),
int vtkNotUsed(componentno)
)
{
VTK_LEGACY_BODY(vtkPolyDataMapper::MapDataArrayToMultiTextureAttribute, "VTK 8.2");
}
#endif
//----------------------------------------------------------------------------
void vtkPolyDataMapper::MapDataArrayToMultiTextureAttribute(
const char* vtkNotUsed(tname),
const char* vtkNotUsed(dataArrayName),
int vtkNotUsed(fieldAssociation),
int vtkNotUsed(componentno)
)
{
vtkErrorMacro("Not implemented at this level...");
}
......
......@@ -27,7 +27,7 @@
#include "vtkRenderingCoreModule.h" // For export macro
#include "vtkMapper.h"
#include "vtkTexture.h" // used to include texture unit enum.
//#include "vtkTexture.h" // used to include texture unit enum.
class vtkPolyData;
class vtkRenderer;
......@@ -111,15 +111,24 @@ public:
* (vtkDataObject::FIELD_ASSOCIATION_CELLS).
* componentno indicates which component from the data array must be passed as
* the attribute. If -1, then all components are passed.
* Currently only point data is supported.
*/
virtual void MapDataArrayToVertexAttribute(
const char* vertexAttributeName,
const char* dataArrayName, int fieldAssociation, int componentno = -1);
// Specify a data array to use as the texture coordinate
// for a named texture. See vtkProperty.h for how to
// name textures.
virtual void MapDataArrayToMultiTextureAttribute(
int unit,
const char *textureName,
const char* dataArrayName, int fieldAssociation, int componentno = -1);
// deprecated in favor of the const char * signature
VTK_LEGACY(virtual void MapDataArrayToMultiTextureAttribute(
int unit,
const char* dataArrayName, int fieldAssociation, int componentno = -1));
/**
* Remove a vertex attribute mapping.
*/
......
......@@ -25,21 +25,8 @@
#include <cstdlib>
#include <sstream>
#include <map>
#include <vtksys/SystemTools.hxx>
class vtkPropertyInternals
{
public:
// key==texture unit, value==texture
typedef std::map<int, vtkSmartPointer<vtkTexture> > MapOfTextures;
MapOfTextures Textures;
// key==texture name, value==texture-unit.
typedef std::map<std::string, int> MapOfTextureNames;
MapOfTextureNames TextureNames;
};
vtkCxxSetObjectMacro(vtkProperty, Information, vtkInformation);
//----------------------------------------------------------------------------
......@@ -98,7 +85,6 @@ vtkProperty::vtkProperty()
this->Shading = 0;
this->MaterialName = nullptr;
this->Internals = new vtkPropertyInternals;
this->Information = vtkInformation::New();
this->Information->Register(this);
......@@ -108,8 +94,8 @@ vtkProperty::vtkProperty()
//----------------------------------------------------------------------------
vtkProperty::~vtkProperty()
{
this->RemoveAllTextures();
this->SetMaterialName(nullptr);
delete this->Internals;
this->SetInformation(nullptr);
}
......@@ -147,11 +133,10 @@ void vtkProperty::DeepCopy(vtkProperty *p)
this->SetShading(p->GetShading());
this->RemoveAllTextures();
vtkPropertyInternals::MapOfTextures::iterator iter =
p->Internals->Textures.begin();
for (;iter != p->Internals->Textures.end(); ++iter)
auto iter = p->Textures.begin();
for (;iter != p->Textures.end(); ++iter)
{
this->Internals->Textures[iter->first] = iter->second;
this->Textures[iter->first] = iter->second;
}
// TODO: need to pass shader variables.
}
......@@ -252,149 +237,86 @@ void vtkProperty::GetColor(double &r, double &g, double &b)
//----------------------------------------------------------------------------
void vtkProperty::SetTexture(const char* name, vtkTexture* tex)
{
vtkPropertyInternals::MapOfTextureNames::iterator iter =
this->Internals->TextureNames.find(std::string(name));
if (iter != this->Internals->TextureNames.end())
{
vtkWarningMacro("Texture with name " << name
<< " exists. It will be replaced.");
}
// Locate a free texture unit.
int texture_unit = -1;
for (int cc=0; ; cc++)
auto iter =
this->Textures.find(std::string(name));
if (iter != this->Textures.end())
{
if (this->Internals->Textures.find(cc) == this->Internals->Textures.end())
// same value?
if (iter->second == tex)
{
texture_unit = cc;
break;
return;
}
vtkWarningMacro("Texture with name " << name
<< " exists. It will be replaced.");
iter->second->UnRegister(this);
}
this->Internals->TextureNames[name] = texture_unit;
this->SetTexture(texture_unit, tex);
tex->Register(this);
this->Textures[name] = tex;
}
//----------------------------------------------------------------------------
vtkTexture* vtkProperty::GetTexture(const char* name)
{
vtkPropertyInternals::MapOfTextureNames::iterator iter =
this->Internals->TextureNames.find(std::string(name));
if (iter == this->Internals->TextureNames.end())
auto iter =
this->Textures.find(std::string(name));
if (iter == this->Textures.end())
{
return nullptr;
}
return this->GetTexture(iter->second);
return iter->second;
}
#ifndef VTK_LEGACY_REMOVE
//----------------------------------------------------------------------------
void vtkProperty::SetTexture(int unit, vtkTexture* tex)
void vtkProperty::SetTexture(int, vtkTexture*)
{
vtkPropertyInternals::MapOfTextures::iterator iter =
this->Internals->Textures.find(unit);
if (iter != this->Internals->Textures.end())
{
vtkWarningMacro("Replacing texture previously assigned to unit " << unit);
}
this->Internals->Textures[unit] = tex;
VTK_LEGACY_BODY(vtkProperty::SetTexture, "VTK 8.2");
}
//----------------------------------------------------------------------------
vtkTexture* vtkProperty::GetTexture(int unit)
vtkTexture* vtkProperty::GetTexture(int)
{
vtkPropertyInternals::MapOfTextures::iterator iter =
this->Internals->Textures.find(unit);
if (iter != this->Internals->Textures.end())
{
return iter->second;
}
vtkErrorMacro("No texture assigned to texture unit " << unit << " exists.");
VTK_LEGACY_BODY(vtkProperty::GetTexture, "VTK 8.2");
return nullptr;
}
//----------------------------------------------------------------------------
int vtkProperty::GetNumberOfTextures()
void vtkProperty::RemoveTexture(int)
{
return static_cast<int>(this->Internals->Textures.size());
VTK_LEGACY_BODY(vtkProperty::RemoveTexture, "VTK 8.2");
}
//----------------------------------------------------------------------------
void vtkProperty::RemoveTexture(const char* name)
{
vtkPropertyInternals::MapOfTextureNames::iterator iter =
this->Internals->TextureNames.find(std::string(name));
if (iter != this->Internals->TextureNames.end())
{
this->RemoveTexture(iter->second);
this->Internals->TextureNames.erase(iter);
}
}
#endif
//----------------------------------------------------------------------------
void vtkProperty::RemoveTexture(int unit)
{
vtkPropertyInternals::MapOfTextures::iterator iter =
this->Internals->Textures.find(unit);
if (iter != this->Internals->Textures.end())
{
this->Internals->Textures.erase(unit);
}
}
//----------------------------------------------------------------------------
void vtkProperty::RemoveAllTextures()
{
this->Internals->TextureNames.clear();
this->Internals->Textures.clear();
}
//----------------------------------------------------------------------------
vtkTexture* vtkProperty::GetTextureAtIndex(int index)
int vtkProperty::GetNumberOfTextures()
{
vtkPropertyInternals::MapOfTextures::iterator iter =
this->Internals->Textures.begin();
for (int id = 0; iter != this->Internals->Textures.end(); ++iter, ++id)
{
if (id == index)
{
return iter->second;
}
}
vtkErrorMacro("No texture at index " << index );
return nullptr;
return static_cast<int>(this->Textures.size());
}
//----------------------------------------------------------------------------
int vtkProperty::GetTextureUnitAtIndex(int index)
void vtkProperty::RemoveTexture(const char* name)
{
vtkPropertyInternals::MapOfTextures::iterator iter =
this->Internals->Textures.begin();
for (int id = 0; iter != this->Internals->Textures.end(); ++iter, ++id)
auto iter =
this->Textures.find(std::string(name));
if (iter != this->Textures.end())
{
if (id == index)
{
return iter->first;
}
iter->second->UnRegister(this);
this->Textures.erase(iter);
}
vtkErrorMacro("No texture at index " << index );
return -1;
}
//----------------------------------------------------------------------------
int vtkProperty::GetTextureUnit(const char* name)
void vtkProperty::RemoveAllTextures()
{
vtkPropertyInternals::MapOfTextureNames::iterator iter =
this->Internals->TextureNames.find(name);
if (iter != this->Internals->TextureNames.end())
while (this->Textures.size())
{
return iter->second;
auto iter = this->Textures.begin();
iter->second->UnRegister(this);
this->Textures.erase(iter);
}
vtkErrorMacro("No texture with name " << name);
return -1;
}
//----------------------------------------------------------------------------
......
......@@ -33,6 +33,7 @@
#include "vtkRenderingCoreModule.h" // For export macro
#include "vtkObject.h"
#include <map> // used for ivar
// shading models
#define VTK_FLAT 0
......@@ -427,7 +428,9 @@ public:
* Set/Get the texture object to control rendering texture maps. This will
* be a vtkTexture object. A property does not need to have an associated
* texture map and multiple properties can share one texture. Textures
* must be assigned unique names.
* must be assigned unique names. Note that for texture blending the
* textures will be rendering is alphabetical order and after any texture
* defined in the actor.
*/
void SetTexture(const char* name, vtkTexture* texture);
vtkTexture* GetTexture(const char* name);
......@@ -440,14 +443,13 @@ public:
* texture map and multiple properties can share one texture. Textures
* must be assigned unique names.
*/
void SetTexture(int unit, vtkTexture* texture);
vtkTexture* GetTexture(int unit);
void RemoveTexture(int unit);
VTK_LEGACY(void SetTexture(int unit, vtkTexture* texture));
VTK_LEGACY(vtkTexture* GetTexture(int unit));
VTK_LEGACY(void RemoveTexture(int unit));
//@}
/**
* Remove a texture from the collection. Note that the
* indices of all the subsequent textures, if any, will change.
* Remove a texture from the collection.
*/
void RemoveTexture(const char* name);
......@@ -461,6 +463,12 @@ public:
*/
int GetNumberOfTextures();
/**
* Returns all the textures in this property and their names
*/
std::map<std::string, vtkTexture *> &GetAllTextures() {
return this->Textures; }
/**
* Release any graphics resources that are being consumed by this
* property. The parameter window could be used to determine which graphic
......@@ -468,10 +476,9 @@ public:
*/
virtual void ReleaseGraphicsResources(vtkWindow *win);
/**
* Used to specify which texture unit a texture will use.
* Only relevant when multitexturing.
*/
#ifndef VTK_LEGACY_REMOVE
// deprecated. Textures should use names not units
enum VTKTextureUnit
{
VTK_TEXTURE_UNIT_0 = 0,
......@@ -483,6 +490,7 @@ public:
VTK_TEXTURE_UNIT_6,
VTK_TEXTURE_UNIT_7
};
#endif
//@{
/**
......@@ -533,12 +541,8 @@ protected:
char* MaterialName;
// FIXME:
// Don't use these methods. They will be removed. They are provided only
// for the time-being.
vtkTexture* GetTextureAtIndex(int index);
int GetTextureUnitAtIndex(int index);
int GetTextureUnit(const char* name);
typedef std::map<std::string, vtkTexture*> MapOfTextures;
MapOfTextures Textures;
// Arbitrary extra information associated with this Property.
vtkInformation* Information;
......
......@@ -21,6 +21,7 @@ vtk_add_test_cxx(vtkRenderingOpenGL2CxxTests tests
TestGlyph3DMapperPickability.cxx,NO_DATA
TestLightingMapLuminancePass.cxx
TestLightingMapNormalsPass.cxx
TestMultiTexturing.cxx
TestOffscreenRenderingResize.cxx
TestPointFillPass.cxx
TestPropPicker2Renderers.cxx,NO_DATA
......
......@@ -32,6 +32,7 @@
#include "vtkSkybox.h"
#include "vtkSmartPointer.h"
#include "vtkTestUtilities.h"
#include "vtkTexture.h"
#include "vtkLight.h"
......@@ -141,7 +142,7 @@ int TestCubeMap2(int argc, char *argv[])
vtkShader::Fragment,
"//VTK::Light::Impl", // replace
true, // before the standard replacements
" vec3 cubeColor = texture(texture_0, normalize(TexCoords)).xyz;\n"
" vec3 cubeColor = texture(actortexture, normalize(TexCoords)).xyz;\n"
"//VTK::Light::Impl\n"
" gl_FragData[0] = vec4(ambientColor + diffuse + specular + specularColor*cubeColor, opacity);\n"
, // we still want the default
......
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkFloatArray.h"
#include "vtkJPEGReader.h"
#include "vtkNew.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkPointData.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkTestUtilities.h"
#include "vtkTexture.h"
#include "vtkTexturedSphereSource.h"
#include "vtkTIFFReader.h"
//----------------------------------------------------------------------------
int TestMultiTexturing(int argc, char* argv[])
{
vtkNew<vtkRenderer> renderer;
renderer->SetBackground(0.5, 0.5, 0.5);
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->SetSize(300, 300);
renderWindow->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renderWindow);
vtkNew<vtkTexturedSphereSource> sphere;
sphere->SetThetaResolution(64);
sphere->SetPhiResolution(32);
sphere->Update();
vtkPolyData *pd = sphere->GetOutput();
vtkFloatArray *tcoord =
vtkFloatArray::SafeDownCast(pd->GetPointData()->GetTCoords());
vtkNew<vtkFloatArray> tcoord2;
tcoord2->SetNumberOfComponents(2);
tcoord2->SetNumberOfTuples(tcoord->GetNumberOfTuples());
for (int i = 0; i < tcoord->GetNumberOfTuples(); ++i)
{
float tmp[2];
tcoord->GetTypedTuple(i, tmp);
// mess with the tcoords to make sure
// this array is getting used
tcoord2->SetTuple2(i, tmp[0], tmp[1]*2.0);
}
tcoord2->SetName("tcoord2");
pd->GetPointData()->AddArray(tcoord2);
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputData(pd);
vtkNew<vtkActor> actor;
renderer->AddActor(actor);
actor->SetMapper(mapper);
std::string file1 = vtkTestUtilities::ExpandDataFileName(argc, argv,
"Data/GIS/raster.tif");
vtkNew<vtkTIFFReader> reader1;
reader1->SetFileName(file1.c_str());
vtkNew<vtkTexture> tex1;
tex1->InterpolateOn();
tex1->SetInputConnection(reader1->GetOutputPort());
actor->GetProperty()->SetTexture("earth_color", tex1);
std::string file2 = vtkTestUtilities::ExpandDataFileName(argc, argv,
"Data/clouds.jpeg");
vtkNew<vtkJPEGReader> reader2;
reader2->SetFileName(file2.c_str());
vtkNew<vtkTexture> tex2;
tex2->InterpolateOn();
tex2->SetBlendingMode(vtkTexture::VTK_TEXTURE_BLENDING_MODE_MODULATE);
tex2->SetBlendingMode(vtkTexture::VTK_TEXTURE_BLENDING_MODE_ADD);
tex2->SetInputConnection(reader2->GetOutputPort());
actor->GetProperty()->SetTexture("skyclouds", tex2);
mapper->MapDataArrayToMultiTextureAttribute(
"skyclouds", "tcoord2", vtkDataObject::FIELD_ASSOCIATION_POINTS);
renderWindow->SetMultiSamples(0);
renderer->ResetCamera();
renderer->GetActiveCamera()->Elevation(-45);
renderer->GetActiveCamera()->OrthogonalizeViewUp();
renderer->GetActiveCamera()->Zoom(1.5);
renderer->ResetCameraClippingRange();
renderWindow->Render();
int retVal = vtkRegressionTestImage( renderWindow );
if ( retVal == vtkRegressionTester::DO_INTERACTOR)
{
iren->Start();
}
return !retVal;
}
......@@ -24,6 +24,7 @@
#include "vtkRenderer.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkTexture.h"
#include "vtkTestUtilities.h"
#include "vtkLight.h"
......
......@@ -31,6 +31,7 @@
#include "vtkSkybox.h"
#include "vtkSmartPointer.h"
#include "vtkTestUtilities.h"
#include "vtkTexture.h"
#include "vtkLight.h"
......@@ -123,7 +124,7 @@ int TestSphereMap(int argc, char *argv[])
true, // before the standard replacements
"//VTK::Light::Impl\n"
" float phix = length(vec2(TexCoords.x, TexCoords.z));\n"
" vec3 skyColor = texture(texture_0, vec2(0.5*atan(TexCoords.z, TexCoords.x)/3.1415927 + 0.5, atan(TexCoords.y,phix)/3.1415927 + 0.5)).xyz;\n"
" vec3 skyColor = texture(actortexture, vec2(0.5*atan(TexCoords.z, TexCoords.x)/3.1415927 + 0.5, atan(TexCoords.y,phix)/3.1415927 + 0.5)).xyz;\n"
" gl_FragData[0] = vec4(ambientColor + diffuse + specular + specularColor*skyColor, opacity);\n"
, // we still want the default
false // only do it once
......
......@@ -838,7 +838,7 @@ void vtkCompositeMapperHelper2::AppendOneBufferObject(
"vertexMC", poly->GetPoints()->GetData(), VTK_FLOAT);
this->VBOs->AppendDataArray("normalMC", n, VTK_FLOAT);
this->VBOs->AppendDataArray("scalarColor", c, VTK_UNSIGNED_CHAR);
this->VBOs->AppendDataArray("tcoordMC", tcoords, VTK_FLOAT);
this->VBOs->AppendDataArray("tcoord", tcoords, VTK_FLOAT);
// now create the IBOs
vtkOpenGLIndexBufferObject::AppendPointIndexBuffer(
......
......@@ -41,6 +41,7 @@ class vtkOpenGLBufferObject;
class vtkOpenGLVertexBufferObject;
class vtkOpenGLVertexBufferObjectGroup;
class vtkPoints;
class vtkTexture;
class vtkTextureObject;
class vtkTransform;
......@@ -256,6 +257,15 @@ public:
int fieldAssociation,
int componentno = -1) override;
// This method will Map the specified data array for use as
// a texture coordinate for texture tname. The actual
// attribute will be named tname_coord so as to not
// conflict with the texture sampler definition which will
// be tname.
void MapDataArrayToMultiTextureAttribute(
const char *tname,
const char* dataArrayName, int fieldAssociation, int componentno = -1) override;
/**