Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Material property changes don't work with ObiCloth
#2
(01-11-2021, 11:25 PM)timconkling Wrote: (I'm not sure if this is a bug, or an unsupported feature, or if I'm doing something wrong!)
  • We have a character in our game who wears a gown. The gown uses an Obi SkinnedCloth component for its cloth simulation.
  • If the character takes damage, the gown becomes "bloodied".
  • To do the bloody-gown effect, we're animating a property on its Material instance; a shader uses the property to do some color blending.
This all works properly when we use Unity cloth:
But when we use Obi cloth, changes to the gown Material's properties don't do anything:

Hi Tim!

The reason for this is that Obi uses the list of shared materials in the renderer to render the cloth itself, since SkinnedMeshRenderer does not allow certain features needed for cloth rendering. Go to line 69 of ObiSkinnedClothRenderer.cs, and change:

Code:
skin.GetSharedMaterials(rendererMaterials);

to

Code:
skin.GetMaterials(rendererMaterials);

That should do it.

(01-11-2021, 11:25 PM)timconkling Wrote: (If we change the *master* Material's properties, we *can* get the bloody-gown effect to work with Obi - but of course, that means that all gowns share the "bloody" status.)

Do you mean the renderers sharedMaterial? This works the same way in Obi as in any other renderer: the sharedMaterial is a reference to a single material, shared by all renderers using it. As soon as you call renderer.material, an independent instance of the sharedMaterial is created and assigned to the renderer.

Using the individual material instances instead of the shared materials (by changing the line of code above) will do the trick.
Reply


Messages In This Thread
RE: Material property changes don't work with ObiCloth - by josemendez - 02-11-2021, 08:09 AM