Change model material diffuse map

Hello,
I’m trying to do just that from code and my attempt looks like this:
modelComponent.Materials[0].Parameters.Set((ParameterKey)ParameterKeys.FindByName("Material.DifuseMap"), myTexture);
How to do it right?

Ok, I got it.

modelComponent.Materials[0].Parameters.Set((ObjectParameterKey<Texture>)ParameterKeys.FindByName("Material.DiffuseMap"), myTexture);

You might want to use shader auto-generated keys so that they are compile-time checked:

modelComponent.Materials[0].Parameters.Set(MaterialKeys.DiffuseMap, myTexture);

2 Likes