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.

C++ shader Viewport 2.0 texture display

C++ shader Viewport 2.0 texture display

Anonymous
Not applicable
3,959 Views
25 Replies
Message 1 of 26

C++ shader Viewport 2.0 texture display

Anonymous
Not applicable

Hello All, 

 

I'm in the process of writing a shader but can't get the texture to display for VP2 or rather the parameter to set it to. 

(as a side note everything else works as well as for VP1)

 

 

 

for the MShaderInstance im using the k3dBlinnShader

 

 

I havent found any list of parameters for the stock shaders. 

 

 

the pixel data is acquired and set into a MTextureAssignment

 

 

0 Likes
Accepted solutions (1)
3,960 Views
25 Replies
Replies (25)
Message 21 of 26

cheng_xi_li
Autodesk Support
Autodesk Support

Hi ferenc,

 

The texture assignment looks fine to me, do you have a working sample? 

 

Yours,

Li

0 Likes
Message 22 of 26

Anonymous
Not applicable

Hi,

I created a sample code, which gets a mesh for input, and draws it out to the viewport (in VP2.0 with SubSceneOverride).

It use the same method.

I attach a sample .hdr image and a sample scene.

 

Thanks,

Ferenc

0 Likes
Message 23 of 26

cheng_xi_li
Autodesk Support
Autodesk Support

Hi ferenc,

 

I've checked your code, I think you've missed the texture coord buffer for the render item. It is created with MGeometry::kTexture and required to provide uv coords for the shader.

 

If you want to create a replica of a geometry, MGeometryExtractor could be useful, and geometryReplicator sample in our devkit could be very helpful. It also shows that the buffers you might need for your renderitem.

 

Yours,

Li

Message 24 of 26

Anonymous
Not applicable

Hi Li,

Thanks for the tip, it worked. I missed the texture coord buffer. When I setted it, everything worked!

 

Thanks,

Ferenc

0 Likes
Message 25 of 26

QDPCO
Explorer
Explorer

Hi there !

 

I am trying to port my C++ plugin to Maya 2018.

 

I need to have shader overrides in the VP2.0 (including textures), and I need to draw related swatches in the attribute editor or the hypershade.

 

So the vp2BlinnShader sample in the devkit seems a good start. Unfortunately, the swatch does not work.

 

Concerning textures, the modified sample provided in this post works fine in Maya 2016 (and the swatch too). But it does not work in Maya 2018, neither for the swatch nor for the texture display.

 

Could anyone provide a valid sample code for Maya 2018 ?

 

Thank you for your time.

Message 26 of 26

QDPCO
Explorer
Explorer

Still investigating...

 

First I thought there was just a failure in the shading process, but I had not noticed that the geometry can not be translated.

 

MayaShaderOverrideProblem.jpg

 

This looks like the following topic :

https://forums.autodesk.com/t5/maya-programming/fragment-shading-malfunction-during-transformation/t...

 

So I tried the workaround : switching to DX11, and then the sample works well, except for the swatch.

 

Unfortunately, this is a problem since my project is developped in OpenGL and was working at last until Maya2014.

 

I am working with Maya2018 SP2. Can I expect this problem to be solved in a next version ?

 

Regards.

0 Likes