suntabu

Hi,

I wanna change the texture of my spine animations, with this forum's advice I made it work by using MaterialPropertyBlock.

But some animations not working properly, some parts of its attachments are not replaced with the new texture.

I checked its slots and attachments, found that they are hidden/showed, I mean when I setting MaterialPropertyBlocks the MeshRenderer's materials did not list these attachments' materials. So I must check the spine's meshrenderer's materials every frame, it's very bad.

Is there any good solutions?
suntabu
  • Mensajes: 3

Harald

suntabu escribió:I wanna change the texture of my spine animations, with this forum's advice I made it work by using MaterialPropertyBlock.
Which advice have you been following?
suntabu escribió:I checked its slots and attachments, found that they are hidden/showed, I mean when I setting MaterialPropertyBlocks the MeshRenderer's materials did not list these attachments' materials.
I do not quite understand the above sentence. Could you please explain that in different words?
suntabu escribió:So I must check the spine's meshrenderer's materials every frame, it's very bad.
The overhead of checking a few texture reference IDs shoult be negligible, depending on what you are actually checking.
Avatar de Usuario
Harald

Harri
  • Mensajes: 1730

suntabu

Thanks for your reply.
Harald escribió:Which advice have you been following?
http://esotericsoftware.com/forum/How-to-swap-Materials-in-a-Spine-Animation-7115

Harald escribió:I do not quite understand the above sentence. Could you please explain that in different words?
It means after I set my spine animation's meshrenderer's sharedMaterials with MaterialPropertyBlocks, once the anmation playing, it's sharedMaterials were changed and renewed every frame, so the changes on materials were lost.
Harald escribió:The overhead of checking a few texture reference IDs shoult be negligible, depending on what you are actually checking.
So if I wanna my changes not dismiss, I must set again every frame with MaterialPropertyBlocks. It's not good, need some advices.
suntabu
  • Mensajes: 3

Harald

This advice is 2.5 years old. Nevertheless, the proper way to override materials is mentioned in Pharan's answer under variant b:
Pharan escribió:b) If you need whole material replacement, or multi-material handling, or for different shaders, I recommend CustomMaterialOverride:
You can do this e.g. via the following calls:
skeleton.CustomMaterialOverride.Add(fromMaterial, toMaterial);
// if you want to remove one override later:
skeleton.CustomMaterialOverride.Remove(fromMaterial);
// if you need to remove all overrides:
skeleton.CustomMaterialOverride.Clear();
Avatar de Usuario
Harald

Harri
  • Mensajes: 1730

suntabu

OK, actually I have done this with Override Materials.
But I just want to try MaterialPropertyBlock.
suntabu
  • Mensajes: 3

Harald

suntabu escribió:OK, actually I have done this with Override Materials.
But I just want to try MaterialPropertyBlock.
suntabu escribió:So if I wanna my changes not dismiss, I must set again every frame with MaterialPropertyBlocks. It's not good, need some advices.
If your attachments change to different atlases, you could try if you can get them all fit into a single atlas that will not change.

If this is not possible, then you will need to set the material property block every frame, and query the assigned materials as you described. Why do you think this is so bad that you want to avoid it at all cost?
Avatar de Usuario
Harald

Harri
  • Mensajes: 1730

eprime

Please, I need me too change texture, but in xna runtime
Cristian
Avatar de Usuario
eprime
  • Mensajes: 48

Harald

Does this reply here resolve this as well?
Avatar de Usuario
Harald

Harri
  • Mensajes: 1730

eprime

YES! :heart:
Avatar de Usuario
eprime
  • Mensajes: 48

Harald

Great, thanks for getting back to us. :)
Avatar de Usuario
Harald

Harri
  • Mensajes: 1730


Volver a Unity