PDA

View Full Version : refresh shading after deformation


dealer2couleurs
04-08-2009, 08:54 PM
Hi,

I have some issues with a plugin in C++ for Maya 2009, 32 bits.

I made a contact deformer plugin to deform an object based on an other geometry. Everything is fine for the computation of the deformation but sometimes, the shading of my objects disappear and he looks like it is flat. It's seem to be a bug because I can't find the action I made to have the error. Sometimes it happend when I change the current frame, and sometimes when I move my objects but that don't happend for all frames and I can't reproduise the error when I want.

I hope someone has already encounter this kind of weird effect and can help me...

Good week

Nicolas

http://img10.imageshack.us/img10/126/withouterror.png
http://img12.imageshack.us/img12/9006/shadingerrorl.png
http://img12.imageshack.us/gal.php?g=shadingerrorl.png

dealer2couleurs
04-09-2009, 07:32 PM
no idea ??

do you know others Maya programming forum ??

Keilun
04-09-2009, 09:35 PM
Can you elaborate on what your plug-in is doing to achieve the deformation? I'm guessing there's a bug in your deformation code that might be duplicating the mesh and leaving the original on top.

In the frame where it appears the original plane is there, can you select that mesh and see what the topology looks like and post the screenshot?

dealer2couleurs
04-09-2009, 11:51 PM
I use the twist deformer exemple to make my plugin. I change the deformation calcul which twist an object to move the vertex of the deformed object (the plane) according to an other geometry (the sphere). When I have the image number two on Maya (sometimes but not all times) and I select the object called plane1 which is deformed by my code, I obtain the first image. The topologie is deformed and there is no other geometry in the scene

I use an iter on my geometry to know the original position of my point and I set the new position with iter.setPosition(pt,MSpace::kWorld);

I'm sure my deformation is good, it's just a issue about the real time rendering of the object in Maya because the error don't appear in the Maya or Mental Ray render.

Keilun
04-14-2009, 06:55 PM
Not sure what else to say. In your screenshot #2, if you select the bottom mesh rather than the sphere can we see what it looks like? Don't box-select. Just single-click select that top plane. I'm curious to see what the wireframe shows and if it's showing on the deformed base as well.

Other than that, it could be a driver issue or perhaps a bug in 2009. It's hard to say.

dealer2couleurs
04-14-2009, 08:38 PM
As I said, the bottom mesh on the second image is the one from the first image. I fact the first image I have is the one with the error and when I clic on my plane to select it, the wireframe is deformed. If after that I select the sphere again, the shading of my plane stay with the good one.

As I said, I have only two object on my scene. and my renders with mental ray or maya software are good each time.

Keilun
04-14-2009, 09:16 PM
Ah. I misread your last post.

You mentioned you were editing the twist plugin. Do you mean the surfaceTwist app? In which case, I'm wondering are you using an actual deformer node to accomplish this? Or just straight running this on an existing mesh in the scene?

You really want to be using the node based approach. If you aren't already, you can use the offsetNode example as a base and just copy your modified code from twistSurf() to the offsetNode::deform() and make your deformation there.

I'm guessing there's some updating issue in the poly. Normals probably not updating which results in that weird shading issue.

dealer2couleurs
04-14-2009, 09:46 PM
I use the yTwistNode Deformer exemple not the surfaceTwist but I think it's the same.

And a particularity of my node is that it is connected with more than one geometry. To connect it in my scene, I select my plane, then the sphere and I use the command " deformer -type "nameOfMyPlugin"" to connect him with my objects. After that in my compute methode, I change the calculs depending the current plug index. The plug index 0 for the plane compute deformations and the plug index 1 don't do anything. It simply read the geometry with an iterator an set the position of each point with the old one. For the plug 0, I compute the deformation based on the point distance and I set the new vertex position with my iterator.

Keilun
04-14-2009, 10:05 PM
Are you able to post your code?

dealer2couleurs
04-14-2009, 10:34 PM
I can't sorry

dealer2couleurs
04-21-2009, 10:00 PM
I refresh my post because I really need a solution.

I have check my scene, the normals are computed in real time after the calcul of my deformation, there isn't an other object or the original one.

I explain again my probleme.

I have use the Ytwist deformer exemple,
found in Maya directory, to implement my own deformation systeme.
In the exemple, I have change the deformation calcul in the deform method for mine and I also overwrite the compute method to make some specific works.

the issue I have is that the shading in the Maya viewport dissapear some times. With little objects, everything is fine, but when I use more complexe objects, is seems not to refresh the shading. In fact, I see my deformations (like the black area in the bottom of the second image), when I check the normals, they are updated in real time, but the shading is flat. it's look like he considered the object as a unique polygon. The shading are computed in real time because I see specular reflect when I move around the object but the shading doesn't fit with the geometry.

After that, if I try to select my object, the real shading appear. And when I deselect it the shading stay. You can say it's not a big deal because when I render my scene everything is fine even if I don't have the shading in the viewport. But it's not usefull to work, that's happend a lot with the playblast and it's seems to happend every two frames.

I post a video of a playblast so you can see beter what I talk about
hope someone can help me...

http://www.youtube.com/watch?v=I3vE6QAcsCc

Keilun
04-22-2009, 08:43 PM
Here's something you can try:

You have two objects right now, sphere and plane.

Source mesh = sphere
Target mesh = plane

Currently your workflow involves attaching the deformer to both meshes and then just ignoring the source mesh in your compute, based on the index.

Rather than do that, try creating a separate input mesh attribute on your deformer. Call it .sourceMesh and make it an array attribute to correspond to the inputGeom inputs (which are your actual deformation targets). From there, remove the ignore by index code that you have and just read off the corresponding input source mesh.

It's hard to say if I'm right or not since I can't see your code, but I'm guessing the way you're going about the node setup is wrong. At the very least this removes a variable from the equation.

Going beyond that, you probably don't even need to override the compute method anymore. You can stick to the deform() function which is the recommended approach. With the source mesh properly separated from the deform target, you should be able to just read the source mesh off the data block inside the deform() method.

Give those a shot. Sorry I can't be of more help, but that's the best guess I've got so far.

dealer2couleurs
04-22-2009, 09:16 PM
thank you for the tips but I can't use it.

I need to overwrite the compute methode to call the deformation of the first object when the second object is moved. Moreover, I plug directly the objects into the deformer so I can plug more than one or two objects. For exemple I can plug three object on my deformer and if one of them is moved, only the first one is deformed.

I don't know if there is an other way to do that, that's the one I found.

Keilun
04-22-2009, 09:26 PM
You can still have multiple objects influencing the first object.

Currently your deformer has a single target, but multiple objects that can influence it. I'm mostly suggesting that you not pass in the influencing objects through the inputGeom. Rather, you create a separate sourceMesh attribute that will influence a given index on inputGeom.

If you want multiple meshes influencing a given target index on inputGeom, then you could make it a 2D array (multi-multi attribute):

.inputGeometry[inputGeomIndex]
.sourceMesh[inputGeomIndex][X]

As long as .sourceMesh is affecting the outputGeometry attribute, it will trigger the deformation when any of the source meshes move.

attributeAffects( aSourceMeshes, aInputGeom )

I could be wrong, but I'm mostly trying to suggest that you simplify the way you're setting up your node computation, as that's what I suspect is the issue.

dealer2couleurs
04-22-2009, 10:10 PM
I will try that, but I'm surprised...

Are you sure that moving the sourceMesh will call the deformation of the target object?
I don't remember very well but I have try that at the begining and as I remember, moving the object which is pluged as a source don't update the calcul on the target. that's why I have found an other way to do that... but maybe I have forgotten someting when I tried... (not the attributAffect)

Please confirm it's possible...
It's not because I don't trust you but I already test that and I don't remember why but I have choose an other way...

Keilun
04-22-2009, 10:16 PM
If you plug the worldMesh rather than outMesh of the mesh node, it should update. outMesh will be local space mesh data. worldMesh will hold the world space mesh data. Of course since a mesh can be instanced, worldMesh is itself an array attribute corresponding to the instance indices. For non-instanced meshes you can just always use the 0th index.

That might be the part you might have missed?

CGTalk Moderation
04-22-2009, 10:16 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.