Multiple sets of texture coordinates with OpenGL2 backend

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple sets of texture coordinates with OpenGL2 backend

Simon Drouin
Is there any way to have multiple sets of texture coordinates on a vtkPolyData with the OpenGL2 backend?

In the legacy OpenGL backend, it used to be possible to have multiple sets of texture coordinates on a vtkPolyData by adding multiple arrays, each containing a set of texture coordinates, to the point data of the polydata, by doing something like this:

polyData->GetPointData()->AddArray( tcoordArray )

And then associating the array to one of the textures with:

polyDataMapper->MapDataArrayToMultiTextureAttribute( textureUnit, arrayName );

This behavior is not implemented in the OpenGL2 backend. The mapper considers only the array returned by polyData->GetPointData()->GetTCoord() as texture coordinates and uses it for all textures. Initially, I thought I could do the job by modifying the shader program used to render the polydata, but the mapper doesn't seem to pack the extra arrays from the point data into the VBO, so the data is not there for the shader.

Any solution?

Thanks in advance.

s.


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers

Reply | Threaded
Open this post in threaded view
|

Re: Multiple sets of texture coordinates with OpenGL2 backend

Ken Martin
Have you tried?

  /**
   * Select a data array from the point/cell data
   * and map it to a generic vertex attribute.
   * vertexAttributeName is the name of the vertex attribute.
   * dataArrayName is the name of the data array.
   * fieldAssociation indicates when the data array is a point data array or
   * cell data array (vtkDataObject::FIELD_ASSOCIATION_POINTS or
   * (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.
   */
  virtual void MapDataArrayToVertexAttribute(
    const char* vertexAttributeName,
    const char* dataArrayName, int fieldAssociation, int componentno = -1);


You will need to do something with that attribute in the shader code. I believe only point association is supported.  All textures will automatically get bound in order with names starting with texture_0 and going up.



On Tue, Dec 19, 2017 at 11:32 PM, Simon Drouin <[hidden email]> wrote:
Is there any way to have multiple sets of texture coordinates on a vtkPolyData with the OpenGL2 backend?

In the legacy OpenGL backend, it used to be possible to have multiple sets of texture coordinates on a vtkPolyData by adding multiple arrays, each containing a set of texture coordinates, to the point data of the polydata, by doing something like this:

polyData->GetPointData()->AddArray( tcoordArray )

And then associating the array to one of the textures with:

polyDataMapper->MapDataArrayToMultiTextureAttribute( textureUnit, arrayName );

This behavior is not implemented in the OpenGL2 backend. The mapper considers only the array returned by polyData->GetPointData()->GetTCoord() as texture coordinates and uses it for all textures. Initially, I thought I could do the job by modifying the shader program used to render the polydata, but the mapper doesn't seem to pack the extra arrays from the point data into the VBO, so the data is not there for the shader.

Any solution?

Thanks in advance.

s.


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers





--
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065

This communication, including all attachments, contains confidential and legally privileged information, and it is intended only for the use of the addressee.  Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken in reliance on it is prohibited and may be unlawful. If you received this communication in error please notify us immediately and destroy the original message.  Thank you.

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Search the list archives at: http://markmail.org/search/?q=vtk-developers

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtk-developers