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.

Vertex color display for custom shaders in VP2

Vertex color display for custom shaders in VP2

szabolcs.horvatth
Contributor Contributor
1,404 Views
8 Replies
Message 1 of 9

Vertex color display for custom shaders in VP2

szabolcs.horvatth
Contributor
Contributor

Hi,

 

Is it possible to display poly color per vertex data with custom shaders in VP2.0? Not even Arnold's aiStandardSurface seems to support it. If its possible than could you show an example how to do it?

 

Cheers,
Szabolcs

0 Likes
Accepted solutions (1)
1,405 Views
8 Replies
Replies (8)
Message 2 of 9

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Have you tried MShaderManager::k3dCPVSolidShader from Maya? It is one of stock shaders. There is a sample called geometryReplicator in the devkit using this shader, you could test it.

 

You could also create your own shader based on the stock shader from Maya. I've written a blog about it few years ago.

 

Yours,

Li

0 Likes
Message 3 of 9

Anonymous
Not applicable

Hi,

I tried to replicate the same effect in fragment XML-s. I created a simple scene with a sphere with vertex colors and with a lambert shader. I dumped the calculated fragment graphs and that Maya automatically connects new fragments to the graph to get the vertex colors (mayaCPVColorBlending, mayaCPVPassing, mayaCPVMasking).

When I tried to do the same with our custom created shader I added an extra paramter to it (<float4  name="colorIn" semantic="fcolor" flags="varyingInputParam" />), which - according to the documentation - is the parameter responsible for the vertex colors. But unfortunately the incoming color was pure black.

I also tried to create an another custom shader which has only one parameter, the colorIn, and it just passes it to the outColor out parameter. And I tried to connect this node to one of our custom shader's parameter (eg. diffuse), but the result was the same: pure black.

Is there something else I need to set? Eg. in the shader code or in the fragment XML-s?

I tried to check the mayaCPVColorBlending and the mayaLambertSurface shaders' XML files, but it seems that only the colorIn parameter is the main requirement to get the vertex colors in the fragments.

Can you help me?

 

Thanks,

Ferenc

0 Likes
Message 4 of 9

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Have you added geometry requirement in your shader? I think you'll need to add color first.

 

Yours,

Li

 

 

 

0 Likes
Message 5 of 9

Anonymous
Not applicable

Hi,

Actually I am using MPxShadingNodeOverride to make the shader work in VP2.0, as I see there is no addGeometryRequirement function to override in this class. Should I switch to MPxShaderOverride?

 

Thanks,

Ferenc

0 Likes
Message 6 of 9

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I think you could try that, you could control how fragment graph is created in MPxShaderOverride and having more controls over how the shader is working in Maya.

 

Yours,

Li

0 Likes
Message 7 of 9

Anonymous
Not applicable

Hi,

Isn't there any other way to make the vertex color work with MPxShadingNodeOverride?

 

Thanks,

Ferenc

0 Likes
Message 8 of 9

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

You could try colorSet semantic.

 

<float4 name=\"colorSet\" semantic=\"colorset\" flags=\"varyingInputParam\" />"

Yours,

Li 

0 Likes
Message 9 of 9

Anonymous
Not applicable
Accepted solution

Hi,

I finally managed to solve the problem!

I needed to convert the MPxShadingNodeOverride to a MPxSurfaceShadingNodeOverride. With this the shader got the perfect input paramter. So eventually the fcolor semantic was enough.

 

Thanks for you help,

Ferenc