Announcement

Collapse
No announcement yet.

Using the same material with all of objects but each of them with different colours

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Finally, I have understood the problem. The two objects created with the Editor get their colour from the C++ code in PostInitializeComponents method. It seems that when I start the game, the two spheres run PostInitializeComponents method and then change their colours.

    Thanks a lot for your time and support.

    Leave a comment:


  • replied
    Yes, I have two different material instance.

    Leave a comment:


  • replied
    W/o downloading the git (I'm about to call it a night).. did you make sure to have a different material instance on each of the balls? The yellow ball should have your yellow color instance, the white ball should have a white color instance. It sounds like you just made a single instance, and your modifying that single instance. For two colors, you need to make 2 separate instances.

    Also, if they are changing colors when you start the game, are you doing anything to the material inside of a level or actor blueprint?

    Leave a comment:


  • replied
    I have created this git repository if you want to check all the project: https://github.com/ViaCognita/Estrellas. You can also download Estrellas.sdf 7zipped here: https://onedrive.live.com/redir?resi...hint=file%2c7z

    I don't know why, but the repository is about 1Gb. Maybe because I'm using starter content.
    Last edited by ViaCognita; 10-18-2015, 10:41 AM.

    Leave a comment:


  • replied
    In the first screenshot, I show how to 1) Create a UV Scaling parameter and 2) Using a Switch Param to add a color to the texture. This is my main project, and I only needed a normal texture, or a red one. In the second picture, I made up a section that will allow you to specify any color you want.

    Once one of these are in your main material, right click the material, and create a material instance. Name this instance MainMatName_Color_Inst. Create as many instances as you need colors for. Change each individual instance to whatever color, and add that instance to the mesh's material slot.

    PS: In the comment node, I say to connect the blue pin to an alpha mask.. it's actually the alpha channel that needs connected to an alpha mask (if you have one).. it's the bottom pin.


    Click image for larger version

Name:	RedDoorMat01.PNG
Views:	1
Size:	194.8 KB
ID:	1091396

    Click image for larger version

Name:	PaintAnyColor.PNG
Views:	1
Size:	94.3 KB
ID:	1091397
    Last edited by SaviorNT; 10-17-2015, 11:00 AM.

    Leave a comment:


  • replied
    I have created another material instance, with a blue colour. I get this:

    Before start the game:
    Click image for larger version

Name:	InitStar.png
Views:	1
Size:	70.8 KB
ID:	1091385

    Running the game:
    Click image for larger version

Name:	Running.png
Views:	1
Size:	122.3 KB
ID:	1091386

    The two yellow balls have a yellow material instance, and in the game I create balls with white-blue material. As you can see, all the Actors in game change their material instance.

    Leave a comment:


  • replied
    Originally posted by Jenny Gore View Post
    What is problem using one material instance per color?
    I don't know. I'm new in Unreal Development.

    Leave a comment:


  • replied
    Originally posted by Anadin View Post
    Even using an instance isn't going to cut it, you need to convert them to Dynamic Material Instances. then each one can have unique colour.
    They are UMaterialInstanceDynamic and they have the same colour.

    Leave a comment:


  • replied
    Even using an instance isn't going to cut it, you need to convert them to Dynamic Material Instances. then each one can have unique colour.

    Leave a comment:


  • replied
    Originally posted by ViaCognita View Post
    I want to use the same material in all of the objects but each of them with different colours. Now, if I change its base colour in one of them, all of them will have the same colour.
    What is problem using one material instance per color?

    Leave a comment:


  • replied
    If they are all material instances, you can set their scalar/vector parameters in blueprint with the "set scalar/vector parameter" nodes and change their values to whatever you want when they spawn.

    Leave a comment:


  • replied
    Add a param to the main material with the color, and then create a material instance. You'll need to duplicate the material instance for each color you want, but it will be much more optimized than using a separate material with only the colors changed. I also do this for UV scaling for various meshes. I'll post some screenshots if you need once I get off of work tonight.
    Last edited by SaviorNT; 10-16-2015, 04:03 PM.

    Leave a comment:


  • replied
    Originally posted by Jenny Gore View Post
    What is problem with your current solution? What you want to achieve?
    I want to use the same material in all of the objects but each of them with different colours. Now, if I change its base colour in one of them, all of them will have the same colour.

    Leave a comment:


  • replied
    I think the PerInstanceRandom material node would work

    Leave a comment:


  • replied
    What is problem with your current solution? What you want to achieve?

    Leave a comment:

Working...
X