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.

Fragment shading malfunction during transformation

Fragment shading malfunction during transformation

Anonymous
Not applicable
691 Views
3 Replies
Message 1 of 4

Fragment shading malfunction during transformation

Anonymous
Not applicable

Hi,

 

I'm experimenting with a simple C++ plugin which draws a shaded cube using a locator node with a geometry override. The shading is done by loading a fragment XML from file.

If "Consolidate World" is enabled, and I start transforming the locator node (e.g. by translating it), the shader stops working.

 

After loading it looks like this (see the fragment XML below):

 

checker_ok.png

 

After starting to translate the node:

 

checker_trans.png

 

The strange thing is that if I replace the mayaChecker in the fragment XML to mayaBulge, this doesn't happen.

 

 

Some more details:

 

On the plugin side there is a locator node with a geometry override which builds a cube in populateGeometry, and in updateRenderItems it loads a fragment XML from file, gets an MShaderInstance from Maya and assigns it to the cube render item.

 

The code for the latter:

   

const char* frag_name = fragment_manager->addFragmentGraphFromFile("my_fragment.xml").asChar();
my_shader = shader_manager->getFragmentShader(frag_name, "outSurfaceFinal", true));
my_render_item->setShader(my_shader)

 

 

The fragment:

 

<fragment_graph  name="TestFragment" ref="TestFragment" class="FragmentGraph" version="1.0">
    <fragments>
        <fragment_ref name="blinn_1" ref="mayaBlinnSurface" />

        <fragment_ref name="checker_1mayaTextureOutputTooutColor1" ref="mayaTextureOutputTooutColor" />
        <fragment_ref name="checker_1" ref="mayaChecker" />

    </fragments>
    <connections>
        <connect from="checker_1mayaTextureOutputTooutColor1.outColor" to="blinn_1.color" name="color" />
        <connect from="checker_1.mayaTextureOutput" to="checker_1mayaTextureOutputTooutColor1.input" name="input" />
    </connections>
    <properties>
        <float4x4  name="ViewProj" ref="blinn_1.ViewProj" semantic="viewprojection" />

        <float3  name="Pw" ref="blinn_1.Pw" semantic="Pw" flags="varyingInputParam" />
        <float3  name="Nw" ref="blinn_1.Nw" semantic="Nw" flags="varyingInputParam" />
        <float3  name="Vw" ref="blinn_1.Vw" semantic="Vw" flags="varyingInputParam" />

        <float3  name="Lw" ref="blinn_1.Lw" />
        <float3  name="HLw" ref="blinn_1.HLw" />
        <float3  name="diffuseI" ref="blinn_1.diffuseI" />
        <float3  name="specularI" ref="blinn_1.specularI" />
        <float3  name="ambientIn" ref="blinn_1.ambientIn" />
    </properties>
    <values/>
    <outputs>
        <struct name="mayaSurfaceShaderOutput" ref="blinn_1.mayaSurfaceShaderOutput" />
    </outputs>
</fragment_graph>

 

Please advise why is this happening and what can I do about it?

0 Likes
692 Views
3 Replies
Replies (3)
Message 2 of 4

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Sorry for the delay. I think it is similar to a known issue which Pm value is unstable while moving the object. It appears that there isn't a workaround right now. 

 

Yours,

Li

0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi,

 

That's unfortunate, but thanks for the answer!

 

For future readers of this thread, the full code to reproduce this problem is here: https://github.com/zogi/maya-fragment-rendering-problem

 

Cheers,

Zoltan

0 Likes
Message 4 of 4

andrei.alex
Alumni
Alumni

The problem occurs when the viewport uses OpenGL, it seems to work fine in DX11 mode. Unless your project(s) require OpenGL, maybe switching to DX11 could be a temporary workaround.

 

A.

0 Likes