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.

MAya2015 VP2 surface shader override xml files

MAya2015 VP2 surface shader override xml files

haggi_master
Advocate Advocate
2,363 Views
16 Replies
Message 1 of 17

MAya2015 VP2 surface shader override xml files

haggi_master
Advocate
Advocate

Hi,

I'm creating a surface shader override and try to implement the surface shader for VP2 with xml files... and it's driving me nuts!

I attached three files: afSurface.xml, afSurfaceDiffuse.xml and afSurfaceCombiner.xml. If I connect my nodes this way in afSurface's connections section:

    <connections>
        <connect from="afSurfaceDiffuse.outColor" to="afSurfaceCombiner.diffuseColor" />
        <connect from="afSurfaceCombiner.mayaSurfaceShaderOutput" to="mayaSurfaceShaderOutput.mayaSurfaceShaderOutput" />
    </connections>

I get the expected result in my viewport2. Now I'd like to use lighting information. If I'm not completely mistaken, I need the help of the maya16LightAccum to use lights. So I connect it this way:

    <connections>
        <connect from="afSurfaceDiffuse.outColor" to="maya16LightAccum.scaledDiffuse" />
        <connect from="maya16LightAccum.scaledDiffuse" to="afSurfaceCombiner.diffuseColor" />
        <connect from="afSurfaceCombiner.mayaSurfaceShaderOutput" to="mayaSurfaceShaderOutput.mayaSurfaceShaderOutput" />
</connections>

But now I get a compile error which looks like this:

// Error: The compile returned an error. // 
// Error:  // 
// cgfxShaderNode::cgErrorCallBack

What is not really helpful. Even obvious syntax errors are reported this way. So if anyone could have a look at my code and tell me why it refuses to compile, I'd really appreciate it. And it would be extremely useful to have a possibility to get more detailed compile informations.

 

 

0 Likes
2,364 Views
16 Replies
Replies (16)
Message 2 of 17

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I don't think you have connected properly in the fragment graph, I think all three inputs should be connected and a light selector is required. The good news is XGen using this fragment too, you could check how it works with XGen(Maya2018/plug-ins/xgen/presets/shaders/xgenFacingCameraPhongSurface.xml).

 

I don't have 2015 installed on my computer right now, if the xml file wasn't there, you could download a 2018 trial and get this xml file. Hope it helps.

 

Yours,

Li

0 Likes
Message 3 of 17

haggi_master
Advocate
Advocate

In the afSurface.xml you can see the light selector at the end.

<string name="selector" ref="maya16LightAccum.selector" />

And I connected the scaledSpecular, so all three inputs are connected. But I get exactly the same result. Is there maybe any way to get a bit more infos about the compile error? Or to compile the xml files myself and see what's happening? I would accept a Maya2018 solution as well if no Maya2015 solution exists.

0 Likes
Message 4 of 17

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

If you looked at the file I mentioned, you'll find you don't have a selector value.

 

<string name="selector" value="mayaLightSelector16"  />

I didn't see you've connected scaledSpecular in afSurface.xml.  BTW: That file does exist in Maya 2015 too, so you could check it without downloading 2018 and xgenPhongSurface.xml uses same shader fragment.

 

Yours,

Li

0 Likes
Message 5 of 17

haggi_master
Advocate
Advocate

Sorry, I didn't make it clear that I just tested your suggestion with connecting all three inputs here. It is not in the xml files I attached. And I'm not really sure if we are talking about the same files. The attached afSurface.xml shader graph file has a selector string property. At least if I open it and check it. Maybe you are talking about another file? The current afSurface.xml looks like this:

<fragment_graph name="afSurface" ref="afSurface" class="FragmentGraph" version="1.0" feature_level="0">
    <fragments>
        <fragment_ref name="maya16LightAccum" ref="maya16LightAccum" />
        <fragment_ref name="mayaSurfaceShaderOutput" ref="mayaSurfaceShaderOutput" />
        <fragment_ref name="afSurfaceDiffuse" ref="afSurfaceDiffuse" />        
        <fragment_ref name="afSurfaceCombiner" ref="afSurfaceCombiner" />        
    </fragments>
    <connections>
        <connect from="afSurfaceDiffuse.outColor" to="maya16LightAccum.scaledDiffuse" />
        <connect from="afSurfaceDiffuse.outColor" to="maya16LightAccum.scaledSpecular" />
        <connect from="maya16LightAccum.scaledDiffuse" to="afSurfaceCombiner.diffuseColor" />
        <connect from="maya16LightAccum.scaledSpecular" to="afSurfaceCombiner.specInput" />
        <connect from="afSurfaceCombiner.mayaSurfaceShaderOutput" to="mayaSurfaceShaderOutput.mayaSurfaceShaderOutput" />
    </connections>
    <properties>
        <float3 name="diffuseColor" ref="afSurfaceDiffuse.diffuseColor" />
        <float3 name="Nw" ref="afSurfaceDiffuse.N" flags="varyingInputParam" />
        <float3 name="Vw" ref="afSurfaceDiffuse.V"/>
        <float3 name="Lw" ref="afSurfaceDiffuse.L"/>
        <float3 name="SLw" ref="afSurfaceDiffuse.SL"/>
        <string name="selector" ref="maya16LightAccum.selector" />
    </properties>
    <values>
    </values>
    <outputs>
        <struct name="mayaSurfaceShaderOutput" ref="mayaSurfaceShaderOutput.mayaSurfaceShaderOutput" />
    </outputs>
</fragment_graph>

 edit:

I think I see what you mean. In the "values" section there is a selector attribute as well. Sorry, I simply oversaw it. I'll test it right now.

0 Likes
Message 6 of 17

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

There is a value section below in that file and this is one of the values.

 

<string name="selector" value="mayaLightSelector16"  />

Please look at the xgen fragment graph file I mentioned earlier and do some tests based on it.

 

Yours,

Li

 

 

0 Likes
Message 7 of 17

haggi_master
Advocate
Advocate

I tried to add all necessary elements but I still do not have any success. As a last try I added my whole shader with python implementation and updated xml files.

I've done all my best to find the problem, but unfortunately there is not very much information about how the shader xml files have to be built and the worst are the crippled error messages from the shader compiler. In Maya2018 it is even worse, it simply shows the wrong result without any feedback at all.

The shader I attached only displays the dot product, it does not use any light information at the moment (I planned to implement all lighting info later as soon as it works).

0 Likes
Message 8 of 17

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Could you try to add

        <fragment_ref name="mayaLightSelector16" ref="mayaLightSelector16" />

in fragments section? It should be the missing piece in your graph.

 

It seems Maya can't find the selector fragment in the graph.

 

Yours,

Li

0 Likes
Message 9 of 17

haggi_master
Advocate
Advocate

Thanks for not giving up! I added the fragment but it does not change the result.

I still get the errormessage:

// cgfxShaderNode::cgErrorCallBack
// Error: The compile returned an error. // 
// Error:  // 

And the xgen xml files works without explicitly loading the fragment.

0 Likes
Message 10 of 17

cheng_xi_li
Autodesk Support
Autodesk Support

I tried following xml with Maya 2018 debug version and I didn't get any compile error(if there were a compile error, it would raise an assert error).

 

<fragment_graph name="afSurface" ref="afSurface" class="FragmentGraph" version="1.0" feature_level="0">
    <fragments>
        <fragment_ref name="maya16LightAccum" ref="maya16LightAccum" />
        <fragment_ref name="mayaLightSelector16" ref="mayaLightSelector16"/>
        <fragment_ref name="mayaSurfaceShaderOutput" ref="mayaSurfaceShaderOutput" />
        <fragment_ref name="afSurfaceDiffuse" ref="afSurfaceDiffuse" />        
        <fragment_ref name="afSurfaceCombiner" ref="afSurfaceCombiner" />        
    </fragments>
    <connections>
        <connect from="afSurfaceDiffuse.outColor" to="maya16LightAccum.scaledDiffuse" name = "scaledDiffuse" />
        <connect from="afSurfaceDiffuse.outColor" to="maya16LightAccum.scaledSpecular" name = "scaledSpecular" />
        <connect from="maya16LightAccum.scaledDiffuse" to="afSurfaceCombiner.diffuseColor" />
        <connect from="maya16LightAccum.scaledSpecular" to="afSurfaceCombiner.specInput" />
        <connect from="afSurfaceCombiner.mayaSurfaceShaderOutput" to="mayaSurfaceShaderOutput.mayaSurfaceShaderOutput" />
        <!--connect from="afSurfaceDiffuse.outColor" to="afSurfaceCombiner.diffuseColor" />
        <connect from="afSurfaceCombiner.mayaSurfaceShaderOutput" to="mayaSurfaceShaderOutput.mayaSurfaceShaderOutput" /-->
    </connections>
    <properties>
        <float3 name="diffuseColor" ref="afSurfaceDiffuse.diffuseColor" />
        <float3 name="Nw" semantic="Nw" ref="afSurfaceDiffuse.Nw" flags="varyingInputParam" />
        <float3 name="Vw" ref="afSurfaceDiffuse.Vw"/>
        <float3 name="Lw" ref="afSurfaceDiffuse.Lw"/>
        <float3 name="SLw" ref="afSurfaceDiffuse.SLw"/>
        <float3 name="diffuseI" ref="afSurfaceDiffuse.diffuseI" />
        <float3 name="specularI" ref="afSurfaceDiffuse.specularI" />
        <string name="selector" ref="maya16LightAccum.selector" />
    </properties>
    <values>
        <float3 name="diffuseColor" value="0.000000,0.000000,0.000000"  />
        <float3 name="Nw" value="0.000000,0.000000,0.000000"  />
        <float3 name="Vw" value="0.000000,0.000000,0.000000"  />
        <float3 name="Lw" value="0.000000,0.000000,0.000000"  />
        <float3 name="SLw" value="0.000000,0.000000,0.000000"  />
        <float3 name="diffuseI" value="0.000000,0.000000,0.000000"  />
        <float3 name="specularI" value="0.000000,0.000000,0.000000"  />
        <string name="selector" value="mayaLightSelector16"/>
    </values>
    <outputs>
        <struct name="mayaSurfaceShaderOutput" ref="mayaSurfaceShaderOutput.mayaSurfaceShaderOutput" />
    </outputs>
</fragment_graph>

It displays a white surface on my computer with OpenGL Legacy which looks like promising. 

 

P.S. I am going to be on vacation next week and I will be back in the week after.

 

Yours,

Li

0 Likes
Message 11 of 17

haggi_master
Advocate
Advocate

Yes, it looks promising, but it is wrong. With:

 

float3 result = diffuseColor;
                            float dotNL = saturate(dot(Nw, Vw));
                            result = diffuseColor * dotNL;
                            return (result);

You should get a diffuseColor multiplied by the facing ratio what means it should be darker at the edges of the geometry. I suppose what you see is a complete white geometry, that's the same what I see in Maya2015 and with the compiler error. And shader should use the diffuseColor from the attached shader what does not happen (at least in my case).

0 Likes
Message 12 of 17

cheng_xi_li
Autodesk Support
Autodesk Support

In that case, I might need to check with Maya 2015 after my vacation. But Maya 2015 is a quite old version, I'll need to find some libraries to debug with it, it might take some time.

 

I tried your original shader graph, it is also a full white shader on my computer(Maya 2018). If it wasn't compiled at all or something goes wrong, the result should be orange instead. But somehow the afColorDiffuse part is missing, I'll check that later too.

 

Yours,

Li

 

 

0 Likes
Message 13 of 17

haggi_master
Advocate
Advocate

There is no need to serach for Maya2015. We can continue with Maya2018. If we find a solution for the problem there, I'm quite sure I can translate it to the old version. I wish you some nice days.

 

0 Likes
Message 14 of 17

haggi_master
Advocate
Advocate

Hi,

any news about this problem?

0 Likes
Message 15 of 17

cheng_xi_li
Autodesk Support
Autodesk Support
Hi,

I am still researching on it. I tried to reach out our engineers earlier, I’ll get back to you if I’ve made any progress or got any replies from our engineers.

BTW:There is a class called MLightParameterInformation<> added after 2015(I believe it should be 2016.5) seems necessary for the job. I am not sure if it is the only way to make lighting shader work in Maya VP2 right now. If that’s the case, I am afraid upgrade to a newer version would be only option.

Yours,
Li
0 Likes
Message 16 of 17

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I think I've found the root cause.

 

The light attributes are missing in original shadernode/override. I might cause Maya failed to make light data bind to the fragment automatically.  There is a similar sample in the devkit called phongShader. So I replaced mayaPhongSurface with afSurface_phongShader there and it worked.

 

If you didn't create light attributes, it is still possible to use lights. You'll need to add all light data into the fragment and it seems working. Please check the afSurface.xml in the attachment, it demonstrates how to do it.

 

Yours,

Li

0 Likes
Message 17 of 17

haggi_master
Advocate
Advocate

Thanks a lot for the support and sorry for the long delay, I was (and still I am) quite busy and have not very much time to continue with the shader development. I'll test the code and give feedback as soon as possible.

0 Likes