Stride Forums Archive

Change model material diffuse map

3 posts, 1595 views, 2016-05-29 to 2016-05-30

Maldar 2016-05-29 #1

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?

Maldar 2016-05-30 #2

Ok, I got it.

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

xen2 (Virgile) 2016-05-30 #3 in reply to #2

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

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