Kar

Hello,

I'm using a plugin called Super Fast Soft Shadows for unity:
https://www.youtube.com/watch?v=sZxrQHIaBbE

I tried to use it with Spine, and it seems to work correctly.
The only problem is when I want to use the light sampler: It picks the light level in one point, and applies that lighting to the whole image.

This requires changing some material parameters, and creating a new instance of the material for the gameObject. But it seems that just instantiating a new material and assigning it to the mesh renderer is doing nothing.

Is there any way to create a material per instance so the material's parameter can be changed per instance?


Thanks a lot.
Kar
  • Сообщения: 11

Pharan

You need to assign that material to the Atlas asset.

The material array on the MeshRenderer is managed by the SkeletonRenderer so it knows which parts come from where in cases where you have more than one atlas or atlas page. More on that here: http://esotericsoftware.com/spine-unity#Materials
Аватара пользователя
Pharan
  • Сообщения: 5366

Kar

I see I can use the Render.SetPropertyBlock in order to change the parameters per instance, but it seems that in order to the shader to work properly. But I also need to enable or disable a keyword in the shader depending on some parameter, but there is no EnableKeyword(string keyword) for the material property block.

Is there any way to achieve this?
Kar
  • Сообщения: 11

Pharan

MaterialPropertyBlock is for changing the properties.

I think keywords are a compilation step thing (not something you can enable and disable at runtime), so you may just have to set your settings on the material you set on the atlas asset.
Аватара пользователя
Pharan
  • Сообщения: 5366

Kar

Hello,

I created a new shader without the multicompile options, so I don't need to enable/disable keywords, and it works!


Thanks a lot for the help!
Kar
  • Сообщения: 11


Вернуться в Unity