How can choose the region of submaterials at runtime

sorry for bad English

I have shapes like cube or sphere that have 2 colors
I created a sample cube in blender and add it to lumberyard


now , at runtime i wish more of the shape be red , for example
but i don’t how do it.

Hi aimar. It might help to have a better idea of the final effect you are trying to achieve, but I can try and point you in the right direction. As you can see, there are two sub-materials in your .mtl file, which implies that the mesh itself has been broken up into two sub-meshes. This is done during asset processing time where the sub-meshes from the fbx are combined based on what material has been applied to the triangles in the dcc tool that was used to create the fbx. There is no built-in way at runtime to change which triangles are part of which sub-mesh, so you will need to make that change in the dcc tool you are using to create the cube if your intention is to use two separate materials.

However there are a couple of ways you can achieve a similar effect using a single material. One would be to use the Blendlayer Shader Generation Param, use blue for your base diffuse and red for your 2nd diffuse. Then choose a black-to-white gradient texture as your blend map. At that point, in the material editor you will be able to use the “BlendFactor” Shader Param to determine at which point in the gradient the material transitions from using the base settings to the 2nd layer settings. The “BlendFalloff” Shader Param will determine whether there is a hard transition between the two (like your image above) or a blend at the transition. https://docs.aws.amazon.com/lumberyard/latest/userguide/mat-maps-blend.html

You can then use script canvas, lua, or c++ to modify the BlendFactor shader param in order to change the point of the transition at runtime. https://docs.aws.amazon.com/lumberyard/latest/userguide/material-owner-set-param-number.html

Alternatively, if you want a fixed change or something that animates in a constant fashion, instead of a blendlayer you could use a diffuse texture that is split half and half between red and blue, then use the Texture Maps->Diffuse->Advanced->Tiling or Texture Maps->Diffuse->Advanced->Oscillator.

In either case, you will likely need to modify the uv coordinates for your cube, since a typical cube will show the same thing on all six sides, whereas it looks like you want one red face, one blue face, and four faces with both.