Changing material color or texture to a material #2437
Unanswered
morenostef
asked this question in
Newcomers
Replies: 1 comment 1 reply
-
|
Can you clarify where you got this example? The code should be |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi. I'm experimenting with materials in c#. I'd like to replace a material of an imported model with a new material runtime.If the material is already created among the assets,no problem loading it . The problems arise when i create a material runtime and i must change color or texture. I followed the manual suggestion below,but there is no "material.Parameters" and,obviously i get errors.
Are there solutions ?
/////////////////////////
// Create a material (eg with red diffuse color).
var materialDescription = new MaterialDescriptor
{
Attributes =
{
DiffuseModel = new MaterialDiffuseLambertModelFeature(),
Diffuse = new MaterialDiffuseMapFeature(new ComputeColor { Key = MaterialKeys.DiffuseValue })
}
};
var material = Material.New(GraphicsDevice, materialDescription);
material.Parameters[0].Set(MaterialKeys.DiffuseValue, Color.Red);
model.Materials.Add(0, material);
/////////////////////////////////////
Beta Was this translation helpful? Give feedback.
All reactions