Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Polybrush material painting bug, errors & weird workaround

Discussion in 'World Building' started by Sly-Mk3, Nov 27, 2018.

  1. Sly-Mk3

    Sly-Mk3

    Joined:
    Nov 27, 2018
    Posts:
    3
    Hello dear Unity community!

    This should be the correct place to post this (hopefully).

    I've used the latest Polybrush on Unity 2018.3.0b11 just recently (after removing LWRP due to compatibility issues) and struggled with a bug where it was telling me the material on the mesh I wanted to paint texture layers on is not using a supported shader, despite being from the Polybrush group of shaders (in this case Polybrush / Standard Texture Blend Bump). Therefore, instead of seeing a list of layers to select and paint my mesh with as in this video (which I followed step by step),
    I simply had the warning message with blank space below or just blank space. The message can be seen here:

    To clarify:
    To be able to paint meshes with a polybrush material, I had to do the following hacky workaround (a result of desperate experimentation):
    1. Create material, drag material on mesh, convert material to "Polybrush / Main Texture With Decals"
    2. Fill slots in material, set tiling.
    3. Testing whether painting now works with decals (it should, perhaps this step can even be omitted), selectable texture tiles should be visible instead of the aforementioned warning in the Polybrush tool.
    4. Switch material shader to "Polybrush / Standard Texture Blend Bump" - suddenly it works just fine and normal maps can be added to the list.*
    *There's a possibility they appear darker than they should, though this could also be an issue of my materials, so this needs further checking.

    Now through using the Polybrush / Main Texture With Decals shader, I was able to get a (fairly limited) layers list, which is a great start, but obviously this is not how it is supposed to be as I'm constantly getting warnings and errors in my console as seen below. They spam my console whenever my brush hovers above my mesh or I'm painting.

    If anyone could verify whether they get this bug too or if they got a better solution to getting around this, that would be great as I'm dependent on the Polybrush tool. So far it is usable, but very limited.

    ---
    tl;dr

    Possible workflow to reproduce the bug:

    Create project (Unity 2018.3.0b11) with LWRP, install Polybrush, remove LWRP, make material with a Polybrush shader, attempt texture painting. If it fails, use my workaround list from above, then it'll magically work.

    ---

    It's a pretty cool tool and I hope it'll be developed further.

    Thanks in advance!

    Sly.
     
    Last edited: Nov 27, 2018
    Sonorpearl likes this.
  2. Sonorpearl

    Sonorpearl

    Joined:
    Sep 8, 2017
    Posts:
    13
    Hey @Sly-Mk3,

    it seems like I have the same bug. I recently had to take out LWRP, because the current version does not support it and I also get those errors.

    NullReferenceException:
    int mask = meshAttributes[selectedAttributeIndex].mask;

    With friendly Regards
    Jan aka. Sonorpearl
     
    Sly-Mk3 likes this.
  3. Sly-Mk3

    Sly-Mk3

    Joined:
    Nov 27, 2018
    Posts:
    3
    Hello @Sonorpearl,

    it's good to see I'm not alone with this. Means it's probably not an issue on my end only.


    Another report:
    Texture painting on a prefab containing two meshes: Texture painting is not saved after restart.

    The painted layers reset and result in the filled default layer being visible on your mesh when the object in question is a prefab. This happens when you save, close and reopen your project/Unity.
    The details from my original post are still up to date and as follows:
    • Latest Polybrush
    • Unity 2018.3.0b11
    • Project without LWRP (just 3D)
    • Using the "Polybrush / Main Texture With Decal" shader (previously mentioned "Polybrush / Standard Texture Blend Bump" shader is still somewhat possible but editing it afterwards turns out to be troublesome, Decal is currently the most stable one).
    Note that in my case said prefabs consisted of exactly two meshes, never more or less. Components in use were the usual: Transform, mesh renderer, collider and so on.


    How to recreate this bug:
    • Create empty game object.
    • Drag some random meshes into your scene (e.g. cube, can be same meshes or different ones).
    • Parent both meshes to your empty game object.
    • Make a prefab out of it.
    • Paint object with textures with the Decal shader, save scene, quit and restart.
    In case texture painting somehow saved on this one, see *. In that case drag the same prefab from your project into your scene and redo the process. The one you added now will likely fail to save any changes done to it, so will any other prefabs of that kind you've dragged into your scene.

    *Sometimes it works on some prefabs, though this behaviour certainly does not seem to be fully consistent. The exception to the rule I observed the most seems to be when you create a prefab out of meshes/objects in your scene, keeping them unchanged. There's a very slim chance the painted changes will then remain on your prefab.

    Selecting the parent instead of the child object you intend to use texture painting on and then painting it will have a likeliness of losing all changes upon restart as well.


    Wonky workaround:
    1. Remove material from prefab/mesh(es).
    2. Unpack prefab in scene.
    3. Drag material back on meshes.
    4. Do not select the game object they're inside of, but the meshes itself in the hierarchy.
    5. Repaint.
    Now the changes should save. Alternatively it can be fixed by replacing the prefab with objects you've just dragged into the scene and copying transform values over.

    Simple objects/meshes added to your scene seem to work just fine.

    ---

    tl;dr

    Polybrush won't save texture paint changes on prefabs consisting of two meshes unless you unpack it and select the specific mesh in hierarchy before texture painting it. Picking the parent game object might fail too.

    ---

    It would be great if others could look into that and verify my observations as well.

    Thanks in advance!

    Sly.
     
    corjn and Sonorpearl like this.
  4. Sonorpearl

    Sonorpearl

    Joined:
    Sep 8, 2017
    Posts:
    13
    Hey @gabrielw_unity, maybe you could help here. :)
    These 2 Bugs are really annoying otherwise, PolyBrush is so nice.
     
    Sly-Mk3 likes this.
  5. Sly-Mk3

    Sly-Mk3

    Joined:
    Nov 27, 2018
    Posts:
    3
    There seems to be another bug @Sonorpearl which (most likely) has to do with packing the game.

    Packing your game reverts changes:
    As soon as you turn it into an *.exe, the painted meshes revert back to the default layer of your Polybrush material. This goes for both, the packed game as well as in your editor/project the next time you launch it. However, since no meshes were sculpted in that scene, it's hard to tell whether these changes would've vanished as well. The grass models painted on islands did remain though, so this seems to be reliable thus far.

    To showcase what exactly happens, here's a screenshot from an early scene from within the project (before packing):

    And here's how it looks like after packing the game (screenshot from the project, but it doesn't look any different in the packed game either):

    Note the change of materials on both islands. The grass texture is gone and so is the stone structure below. There's just a dirt material left on the left one and a dirt grass material on the right.

    I know this isn't a final tool yet, but it would be great if this could get a fix sometime soon, even if it were just workarounds to avoid losing your edits/changes, reading them would be greatly welcome.

    The only idea I had of trying to keep the painted edits was searching for the data Polybrush generates somewhere in my project folders, but I couldn't find anything.
    Does anyone know if there is any texture mask or something like that Polybrush generates which I could turn into a material? Just something to make these changes into a "solid" material independent of Polybrush so that you could drag it on anything with the same layers/masking present.
    I couldn't find anything like that but that'd be incredibly useful, especially as a feature.


    The only other culprit I could think of would be a lightmap bake, but I'm sure I have done one before with it keeping my changes. I'll retry it and report back as soon as that is done.
     
  6. Sonorpearl

    Sonorpearl

    Joined:
    Sep 8, 2017
    Posts:
    13
    Any updates on the problems or the preview version of PolyBrush? Seems like Unity 2018.3 is nearing launch.
    Most of us would probably use a nightly build at this point.