How to use TDBuffer_AttribName() for indexed POP Attribute access in GLSL Material? (Example needed!)

Hello everyone,

I’m trying to access a POP Attribute using an arbitrary index within a GLSL Material (MAT).

The official documentation mentions these functions for indexed attribute access on the “Other POP Attributes” page: Experimental:Write a GLSL Material - Derivative

I understand the purpose of TDBuffer_AttribName(elementIndex) is to read a buffer using a specific index, but I’m unsure about the implementation.

Could someone please provide a simple, working example that shows:

How to read the attribute of a different point (e.g., point at elementIndex + 1) using the TDBuffer_P(...) function inside the Vertex or Fragment Shader.

Thank you very much!

Hello,

There are a couple examples about POP attributes access in the examples

GLSL Folder, GLSLPOPs.toe, TOP_MAT base

in the MAT shader gl_VertexID is a built-in variable for the current vertex being rendered

if your input POP only has point attributes, and no vertex or primitive attribute:
gl_VertexId = pointIndex

if your POP also has vertex of primitive attributes, each vertex references a pointIndex. Just realizing you can’t access it directly in the MAT right now so you would have to store it as a vertex attribute first, might be useful to add it (in GLSL POPs there is TDInputPointIndex(uint vertIndex) Experimental:Write GLSL POPs - Derivative, , you can also access it with the built-in attribute _PointI in Math POP etc)

Let me know if that helps! Happy to try to create a more specific example depending on what you’re trying to accomplish - also it might be easier to do more processing in GLSL POPs before the MAT (costs more GPU memory though)