Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Maya2015 VP2 How to create geometry shader in DrawOverride?

haggi_master
Advocate

Maya2015 VP2 How to create geometry shader in DrawOverride?

haggi_master
Advocate
Advocate

Hi,

I have my own alembic surface shape node to handle point data. At the moment I am able to read points from an alembic file and display the points with an DrawOverride. The next step would be to visualize the point sizes interactively. My idea was to create someting like a sprite and adjust scale in a geometry shader. Unfortunately I could not find an example for using geometry shaders in a MPxDrawOverride.

 

My question: Is it possible to use geometryShaders in a MPxDrawOverride? And if yes, how?

0 Likes
Reply
Accepted solutions (1)
665 Views
3 Replies
Replies (3)

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution
Hi,

I am afraid you can't do that with Maya 2015. I remembered that engineers had added geometry shading fragment support along with GPUInput semantic recently. There is a sample for geometry shader in Maya 2018 devkit. I've never tried if it could be used with MPxDrawOverride directly but it might be a good start if you are interested in it.

Yours,
Li
0 Likes

haggi_master
Advocate
Advocate

Hi,

 

I hope you don't mind that I ignored your hint that it is not possible with Maya2015 and I simply tried it. The code snippet below int the draw() method of my DrawOverride() method shows the principles.

 

The shader program contains a vertexShader, geometryShader and fragment shader. The basics work and the geometry shader produces the desired ouput. Now I have a little problem: I have no idea how I can add texture coords to my vertex array and use it in my gl shaders. In the vertex shader I tried to use:

 

in vec2 UV;

or

in float UV;

 

but both does not work. I know this is not really a supported way to use the DrawOverride, but maybe there is a hint how to add texture coords to a vertex buffer.

 

 

glUseProgram(s_program);
float mat[4][4];
double* d = ao.matrix.getValue(); glUniformMatrix4dv(s_objectLoc, 1, GL_FALSE, d); context.getMatrix(MHWRender::MDrawContext::kWorldViewMtx).get(mat); glUniformMatrix4fv(s_modelLoc, 1, GL_FALSE, &mat[0][0]); context.getMatrix(MHWRender::MDrawContext::kViewProjMtx).get(mat); glUniformMatrix4fv(s_viewProjLoc, 1, GL_FALSE, &mat[0][0]); glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); V3f* point = (V3f* )ao.points->get(); float *pscale = (float* )ao.pscale->get(); glVertexPointer( 3, GL_FLOAT, sizeof(V3f), &point[0].x ); glTexCoordPointer(1, GL_FLOAT, sizeof(float), pscale); glDrawArrays(GL_POINTS, 0, ao.points->size()); glDisableClientState( GL_TEXTURE_COORD_ARRAY ); glDisableClientState( GL_VERTEX_ARRAY ); glUseProgram(0);

 

0 Likes

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Oh yes, you've got my blind spot. If you want to implement custom drawing, it is possible, I was kind thinking in shader fragment only. 

 

For shader it should be

 

gl_MultiTexCoord0

 

I think.

 

Yours,

Li

 

0 Likes