Search Unity

[ProBuilder] The majority of changes cause materials added after the first not to show.

Discussion in 'World Building' started by Blaize_J, Feb 7, 2021.

  1. Blaize_J

    Blaize_J

    Joined:
    Oct 29, 2018
    Posts:
    3
    Currently on Unity (2019.4.19f1), tried versions between ProBuilder (4.4.0)(Verified) - (5.0.0-pre.10)

    The majority of changes to a ProBuilder object cause any materials either
    a. after the first one (don't know how to test)
    or
    b. after a transparent one (tested)
    to no longer show.

    1. Create a new shape using ProBuilder
    upload_2021-2-6_17-49-2.png

    2. Make a transparent texture with something on it, turn on Alpha is Transparency (I used the ProBuilder's GridBox_Default.png and got rid of the white)


    3. Turn the texture into a material, make sure Surface type is Transparent.
    upload_2021-2-6_17-56-42.png

    4. Add another material to the object
    upload_2021-2-6_18-0-33.png

    5. Where the issue appears. It will look like step 3's image. A number of things can trigger it, for example:
    Transforming in any way and undoing the transform.
    Selecting a vertex, edge or face, and moving it.


    Notes:
    Any amount of undoing, or assigning different materials before going back to the two desired does not fix the issue, instead forcing you to make a new ProBuilder object, in which you just can't do a lot of things to after you've assigned the materials desired, making this quite a bothersome bug if you're going for the result I am.

    Any other materials added after the transparent one don't show after the bug.

    This doesn't happen with default objects such as the cube for some reference.
     

    Attached Files:

    Last edited: Feb 7, 2021
  2. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    If I understand correctly, you're trying to render the cube twice with two difference materials? So there is a single submesh and two materials assigned to the MeshRenderer?

    If so, that's not supported by ProBuilder. It assumes that 1 submesh == 1 material, and will automatically manage the MeshRenderer material array to ensure that there aren't too many or too few materials.
     
  3. Blaize_J

    Blaize_J

    Joined:
    Oct 29, 2018
    Posts:
    3
    If default 3D objects support it, why shouldn't ProBuilder objects?
    Since it's not supported shouldn't the option for more materials be removed?
    Right now there's a buggy in-between at the moment where you "can" do it, and then it stops working once you try to do something with the object. I know I'd prefer it to be supported as it's strange to have to make a shader for something usually supported by default.

    Being able to put separate materials onto specific faces seems to be one of the cool features of ProBuilder, and the same issue doesn't apply there, and it will even show a second material being added like what I'm trying to do except they don't overlap.
    upload_2021-2-7_14-1-49.png
     

    Attached Files:

    Last edited: Feb 7, 2021
  4. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    To give a bit more context, ProBuilder manages the MeshRenderer material array so that you don't end up with excess materials (which is a performance cost) and too few (which means your mesh doesn't render how you expect).

    The ability to add additional materials to a single submesh is a more of an oddity rather than a feature, at least in my opinion. Hence not much thought was given to supporting that use case. It's a little difficult to handle from a technical point of view as well. If you have a single submesh and two materials, then assign a third material to a face, what happens? Does ProBuilder create 3 submeshes, 2 duplicates for the existing materials and a third for the new material? Or do you expect it to re-use the existing second material, overwriting the value? The other alternative is to remove the texturing entirely and just enable ProBuilder to define submesh regions, which seems like a step backwards for usability.

    Or, maybe the answer is that ProBuilder only appends to the materials array. That would still result in some strange behavior, but it would support the multiple materials for a single submesh use case.

    I guess my next question is what is the reason for rendering the mesh twice with two materials? I'm having trouble thinking of a case where a shader wouldn't be preferable, for example.