Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Shader uniform value set according to mesh attribute

Shader uniform value set according to mesh attribute

Anonymous
Not applicable
520 Views
1 Reply
Message 1 of 2

Shader uniform value set according to mesh attribute

Anonymous
Not applicable

Hi,

 

I am currently trying to figure out how it is possible with the Maya API to dynamically set the value of a uniform that is defined by a MPxHardwareShader. I am currently able to change the attribute that directs to invalidate the uniform so that it is effectively changed globally for a whole scene. However, I want to do this dependent on an attribute set per MFnMesh. A simple scenario would be to have an objectID defined as an attribute per mesh and a correspondent uniform of equal type defined in the shader, and while drawing the meshes to have the uniform value set to the correspondent objectID. My ultimate goal is to achieve this with a custom matrix that is set per mesh/object in a similar fashion as the World matrix supplied by Maya. I am using the dx11Shader with Viewport 2.0.

 

Thanks in advance for helping!

 

Amir

0 Likes
521 Views
1 Reply
Reply (1)
Message 2 of 2

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I've discussed with our engineers yesterday. There is a way could achieve your requirement but it might be the most efficient way. There are two steps required to enable you to use something worked like an uniform attribute from meshes.

 

You'll need to create a MPxVertexBufferGenerator. I think vertexBufferGenerator sample in the devkit is a very good sample for you.

 

It could create custom stream based on a given shape for custom shaders which add requirement for that custom stream with MVertexBufferDescriptor. I think you don't have to update dx11Shader, it should have already supported varying semantic.

 

Yours,

Li

0 Likes