ucupumar / ucupaint

Ucupaint is Blender addon to manage texture layers for Eevee and Cycles renderer.
GNU General Public License v3.0
874 stars 31 forks source link

PAINTING ON TOP OF OTHER SHADERS #132

Closed Dereuz24 closed 2 weeks ago

Dereuz24 commented 2 weeks ago

Hi there. I don't know if I'm missing something obvious here but it's worth a try.

Would it be possible to add an option to insert a layer that references another material shader/node group from the scene?

What I'm doing at the moment is connect a shader mixer between Ucupaint and the output, mask it with the alpha channel and connect the other material/shader to the mixer. Another solution has been to use two meshes, one for the shader, and another one for the painted layers.

The problem is that it's very cumbersome and slow to work this way.

Another issue that would be less common is that some shaders with custom N-panel menus do work, but once the blender file is closed it's practically ruined. Blender won't open the file again because it doesn't recognize the node tree and whatever custom menu that is precisely mapped to the node configuration.

A solution I've used has been to be to create node groups, but it's a very slow process as well to connect everything properly.

A way I imagine this working would be clicking on a new layer, "add new layer from existing material", then Ucupaint copies the node tree from that material, puts it in a group, and then mix the shader in the internal node tree in the corresponding order.

If that shader/material properties are changed, an update button could be added to refresh the node group.

A warning could be issued about the baking process not being able to bake this layer. However we can bake upper and lower layers in the outliner while still retaining this shader group in the middle at the end. Still improving performance, and allowing to use random shaders more comfortably.

ucupumar commented 2 weeks ago

I'm not sure if I get what you meant, can you explain it in a video or something, so it can be more clear?

Dereuz24 commented 2 weeks ago

I'm not sure if I get what you meant, can you explain it in a video or something, so it can be more clear?

Hi there Ucupumar sorry for the delay. Here's a screenshot of what I mean

I had a shader on another object, then I painted a layer with ucupaint with base opacity 0 and mixed both and set the factor with the color alpha.

SHADER MIX 01

I realize I didn't describe it very well. I can still bake textures, switch between bake and nodes and ucupaint works well. But I was wondering if it would be viable to have an option of just picking a shader/material that's on the scene and treat it like layer and ucupaint immediately does a similar node setup for convenience, or if doing it manually is still the best way to keep the scope of ucupaint within texture painting.

As for the other thing I described, some weird nodes break when I do this stuff but I can copy them into a group to mix them and avoid those issues (some of my blender files don't open because these specific shaders have n-panel custom menus and things get weird if you modify the node tree). So if this was possible there could be an option to copy scene materials into node groups and avoid those kind of issues, but that's secondary, the material mixing feature is the main thing I'm wondering about.

ucupumar commented 2 weeks ago

I see, so you want custom nodes as a layer? It's already on the todo list (#90). But I don't think it will be possible if the output is a shader. Maybe you can create emission only version of your shader.

Dereuz24 commented 2 weeks ago

Ah that's good! I didn't see issue 90

Yes exactly, I just wanted to be able to pick and use any node group as a base layer with a quick setup like that, but I didn't really think about the final output if we were to bake it or if I wanted it to be a real layer that can be moved around and manipulated in ucupaint outliner.

There's a lot of shaders I use that could work just as good as an emission texture with some displacement and an alpha mask so that could be a solution. But random things like toon shaders give me a lot of issues because most of them are made for eevee and many of the automatic baking stuff out there just uses cycles instead of projecting an image texture from camera view. Any random node group could come out as a black layer from a bake if something isn't precisely right so that's why I was thinking on just mixing node groups.

There's a blender addon that recently came out called Ghost Matter, it mixes any node groups from the scene with a custom mask. Anything can go into it because it creates a copy by grouping the shader or material and naming them in a way the addon recognizes. However, things get very resource intensive very fast after 3 or 4 node groups each with their own mask, so I don't know how viable that approach could be.

The emission only version could work for a lot of cases though, and if the nodes have any sort of displacement or things like that there could be an option for the user to copy that information.

But anyways thanks a lot for making this addon. At the beginning I didn't quite understand why it was made this way and then I went down the rabbit hole and it has almost anything one could hope for. This thing is unbelievable!

ucupumar commented 2 weeks ago

Maybe a shader channel could be possible in the future, but it obviously can't be baked. So I'm closing this one since it's a duplicate of issue #90

Thanks for the nice words! This addon is heavily inspired by Blender internal material system in pre-2.80 era blender. I never used substance before so maybe that's why some people find this addon a bit confusing, but I tried my best to make this addon as simple as possible.