Home Technical Talk

Does vertex painting a mesh make it unique?

jordank95
polycounter lvl 8
Offline / Send Message
jordank95 polycounter lvl 8

I have a bunch of the same mesh in my level, a giant rock basically. Ive duplicated this same rock around my level and each of the copies of this rock has the same material on it thats setup for vertex painting with a few different textures. If I vertex paint each one of these rocks separately, does that count as a draw call each?

Also, Is there a way to save a vertex painted copy of a mesh and use that instead of having to vertex paint the same mesh again over and over?

Replies

  • rexo12
    Offline / Send Message
    rexo12 interpolator

    Hard to answer as you haven't told us the engine you're using.

    In general, If you aren't explicitly instancing your objects then they consume a new draw call for each duplicate anyway. If you were instancing, then you wouldn't be able to define vertex colours per-instance (not easily, i'm sure you could do some transformations in shader). Just do some profiling on your scene?

    The answer to your second question is to paint your colours outside of the engine so that the 'source' asset you import has them.

  • jordank95
    Offline / Send Message
    jordank95 polycounter lvl 8

    @rexo12 using UE4.

    Ok that makes sense. So if Im just duplicating my rock and vertex painting it so it looks different, its the same as just duplicating it in general? The vertex painting per rock wont matter since its not an instance anyway, its just a duplicate. Am I understanding correctly?

  • rexo12
    Offline / Send Message
    rexo12 interpolator

    Yes that's correct. In particular I don't believe vertex colours have any impact on draw calls.

  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter

    Ue4 supports dynamic instancing as of recent versions so a duplicate mesh isn't necessarily a new draw call.

    Id have to run it through renderdoc to be sure but it is likely that vertex paint would break the dynamic instancing - unreal seems purposely designed to achieve maximum draw calls from minimal input so it'd be on theme

  • jordank95
    Offline / Send Message
    jordank95 polycounter lvl 8

    @poopipe hey can you explain how the dynamic instancing works? and what versions of UE4 is this in?

  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter

    I don't remember what version it came in but it's in 4.26/4.27 - you might need to enable the setting somewhere.


    it'll batch static mesh actors/components where they use the same mesh and lod level - it appeared to work when the meshes were inside blueprint actors but I wouldn't commit my reputation to that one.



    it's worth noting that if the number of draw calls is an issue you can often get around the problem by masking with textures and some sort of world space noise modifier instead. it works well for dirt/organic stuff

  • Shrike
    Offline / Send Message
    Shrike interpolator

    Very careful there, we had this issue recently in Unity (it might or might not or might be in some unreal settings be the same) and its sneaky but makes total sense if you figure it out.

    It depends on if you make your new mesh a saved asset that is in your project or just a model that exists in the scene file.

    Batching is not enough If you have the asset not saved as real project asset, each copy will have to be saved as new mesh with its vertex positions, colors, uv data etc into the scene by the engine. That means the scene will bloat up with the new vertex information. So in this case, copy pasting a exact same painted pipe 200 times with a same vertex color which was not saved to disc but just existed as virtual copy in your environment, was adding hundreds of MB to the environment file.

    (Because if its not saved, it can't draw from any saved mesh and has to save all mesh infos for every usage you make, no matter if its the same or not. In your scene is then a big list essentially with the info of each single vertex of each single vertex painted mesh, while for a saved mesh the scene just saves the X Y Z and scale etc info)

    Long story short, save your vertex painted meshes as prefab/to your project if you want to copy paste them unless its just a simple plane.

  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter

    Creating a new library asset for each of those will guarantee that nothing is shared in main memory or batched on the GPU - I definitely wouldn't do that without testing it first.

  • Shrike
    Offline / Send Message
    Shrike interpolator

    I mean when you copy this mesh. If you copy a piece of painted pipe 200 times you want it in library and then it can be batched with itself.

  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter


    You're probably right but I wouldn't do it without first proving they don't batch

  • Fabi_G
    Online / Send Message
    Fabi_G high dynamic range

    Used the same approach as Shrike in Unreal (4.26 iirc) - create few vertex painted variants (e.g. overgrown, dirtied) - because the map size would get very large with many vertex painted meshes. Can't speak to the affect on draw calls though, curious about this myself.

    For the most part relied on base materials using world aligned masks combined with normal direction and object specific masks.

Sign In or Register to comment.