Search Unity

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:
    32
    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:
    32
    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:
    32
    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.
     
  7. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi, sorry I missed this! We've had to (again, sorry) put Polybrush on a wee hold while PB4 is completed. Going a little slower than the Asset Store days, but trying to make sure we catch everything this time :)

    Polybrush 1.0 will indeed solve the LWRP/HDRP woes, yes!
     
  8. ThomasBKat

    ThomasBKat

    Joined:
    Jul 21, 2013
    Posts:
    3
    It's March, wondering how this is progressing? Looking forward to the fix :)
     
  9. francoteves8246

    francoteves8246

    Joined:
    Oct 27, 2018
    Posts:
    6
    Same problem here with Unity 2019.2
     
  10. jenapier

    jenapier

    Joined:
    Nov 11, 2017
    Posts:
    4
    Same problem @gabrielw_unity - none of the shaders work in polybrush. They turn my mesh black, and say "it doesnt look like any of the materials on this object support texture blending".
     
  11. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi jenapier! Could you file a bug report for this? Sounds like a specific issue, easier to track and fix that way. Thanks!
     
  12. gputhread

    gputhread

    Joined:
    Dec 7, 2018
    Posts:
    36
    I just deformed and painted a larger area of my open world map, all the edits i lost just after starting unity back. There was a blackout happening today, so i closed unity in fear of project damage and went for dinner. But I am sad n confused that it was all working fine till today evening but how a closing n opening of project leaded it to lose all edits from deforming to painting. I also deleted z_add_vertex stream which appeared on neighbouring water mesh which was making it invisible in playmode before going to dinner which solved it disappear problem. Whatever it happened I will use fbx exporting...as deforming is tough while painting is easy :), saving scene is not working :'). Also composite mesh given weird result i will not hit that button till beta ends. Unity 2017.4.27 LTS | Polybrush 0.9.15
     
  13. jenapier

    jenapier

    Joined:
    Nov 11, 2017
    Posts:
    4
    Hi @gabrielw_unity
    I have tried everything and have now tested on 4 different versions of Unity (latest is 2019.3.0a05) with completely new projects/installs etc. This has rendered polybrush unusuable and I am unable to use any of its functionality or blend shaders. Here is more details/screenshots:

    1) Firstly - my mesh is completely black and I get this error (regardless of which polybrush shader I use):


    2) I was told to switch the Mac renderer to OpenGL so I did so as per here and restart Unity:


    3) Now the blend shader STILL doesn't do texture blending (and I still get the error), but the vertex blend appears to doing something but very glitchy with a white fog over it. It's still completely unusable:



    4) I also get this error in the console:



    I am desperate for help on this so can you please advise a solution. Thank you.
     
  14. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi there, sorry I've been away - we are right now rebuilding the shaders to be much simpler and geared toward users creating their own, since we can't control all the ways they will be used. Are you using LWRP or HDRP, by chance? I can help you create a custom shader via Shader Forge, it's very simple and gives you full control! :)
     
  15. judymoon1028

    judymoon1028

    Joined:
    Aug 15, 2019
    Posts:
    4
    Did the bug get fixed yet?
     
  16. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Yup, version 1.x should work fine :)
     
    ZIMohammad likes this.
  17. blastproofgames

    blastproofgames

    Joined:
    Apr 3, 2014
    Posts:
    18
    I have an issue with a random shadow popping up in my scene whenever I use the Standard Texture Blend shader.
    https://imgur.com/a/6q8cKUs


    The shadow's size seems to be inversely proportional to the size of the shadow distance.
    Any insight?
     
  18. JOESIDinc

    JOESIDinc

    Joined:
    Mar 30, 2015
    Posts:
    7
    @gabrielw_unity I've tried multiple combinations of settings but can't get PolyBrush 1.01 shader to work on Android. I am using a Galaxy Samsung S8+ and building the app with Unity 2019.2 6f1. In the editor, it always appears correctly using the Standard PolyBrush shader but on build its jet black. I also tried the LWRP pipeline and then using the LWRP Polybrush shader but that one says that it's not supported. In the shader graph it's flagged as an error in the Master PBR shader. I'm using Texture blending. Any help would be greatly appreciated. Let me know if there is anything I can do to help.
     
    Last edited: Sep 24, 2019