KirilStrezikozin / BakeMaster-Blender-Addon

Welcome to BakeMaster, a powerful and feature-packed baking solution created for Blender - an open-source 3D Computer graphics software.
Other
34 stars 6 forks source link

BUG: BakeMaster doesn't inspect node groups to get data to bake #73

Closed KirilStrezikozin closed 1 month ago

KirilStrezikozin commented 6 months ago

This bug report is:

Describe the bug soeinfeuerball (Discord) found out that BakeMaster doesn’t look inside node groups. This bug is also related to sovanima (Discord), who mentioned that BakeMaster may not work properly for complex materials. The latter is a separate issue (actually this bug fix may have fixed that one now), this bug report focuses on what soeinfeuerball faced.

To Reproduce Steps to reproduce the behavior:

  1. Add an object where materials have a node group plugged directly into material output nodes.
  2. Bake.
  3. See wrong or missing colors on image textures.

Expected behavior BakeMaster should inspect node groups and not just treat them as a single node.

Screenshots soeinfeuerball's screenshot with the original model on the right and the baked one on the left: image

Desktop (please complete the following information):

Additional context This is about reworking mat_replug

KirilStrezikozin commented 6 months ago

TODOs:

KirilStrezikozin commented 6 months ago

image

KirilStrezikozin commented 6 months ago

A spreadsheet with all ShaderNode types. Green cells are the ones BakeMaster replugs for baking and map preview.

KirilStrezikozin commented 6 months ago

makes the full list:

ShaderNodeBsdfAnisotropic
ShaderNodeBsdfDiffuse
ShaderNodeBsdfGlass
ShaderNodeBsdfGlossy
ShaderNodeBsdfHair
ShaderNodeBsdfHairPrincipled
ShaderNodeBsdfPrincipled
ShaderNodeBsdfRefraction
ShaderNodeBsdfToon
ShaderNodeBsdfTranslucent
ShaderNodeBsdfTransparent
ShaderNodeBsdfVelvet
ShaderNodeDisplacement
ShaderNodeEmission
ShaderNodeNormalMap
ShaderNodeVectorDisplacement
KirilStrezikozin commented 6 months ago

bruh pushed to master, not dev-2.6.1. master has a breaking change.

KirilStrezikozin commented 6 months ago

The new replugging algo is now used for non-cycles, non-custom map previews and baking, such as AlbedoM, AlbedoS, Metalness, Material Displacement, Decal Normal etc.

KirilStrezikozin commented 6 months ago

Time to test now.

KirilStrezikozin commented 6 months ago
KirilStrezikozin commented 6 months ago
KirilStrezikozin commented 6 months ago

this is like 90% done

p.s (after 3 days) more like 50% - the system is awesome but raw

KirilStrezikozin commented 6 months ago

damn ShaderNode.label is 64 characters max. Not even enough for a node and link restore instruction :((

KirilStrezikozin commented 6 months ago

same for ShaderNode.name

KirilStrezikozin commented 6 months ago

I have a feeling that we can change our restore instructions to fit withing the 64 characters. Let's count. A full-blown maximum length instruction is something like the following (Specular map with old existing links):

(header[0], 13 characters) BM_maRestore\n

scenario 1:

-----
~link~ (deleted on node delete)
~link~ (deleted on node delete)
~link~ (deleted on node delete)
~link~ (deleted on node delete)
~link~ (deleted on node delete)
~link~ (deleted on node delete)
~link~ (deleted on node delete)
-----
node
node
node (5x nodes)
node
node
-----
node (1x node)
~link~ (deleted on node delete)
-----

scenario 2:

-----
~link~ (deleted on node delete)
~link~ (deleted on node delete)
~link~ (deleted on node delete)
~link~ (deleted on node delete)
~link~ (deleted on node delete)
~link~ (deleted on node delete)
~link~ (deleted on node delete)
-----
node
node
node (5x nodes)
node
node
-----
link (1x link)
-----

Which makes it either 6x nodes or 5x nodes + 1x link to restore (ignoring useless restore links instructions used between created nodes, they are deleted anyway when those nodes are deleted)

KirilStrezikozin commented 6 months ago

BM_matRestore\n can be reduced to BMmaR\n (6 characters). We're left with 57. node remove instruction can be described at least with n! and a node index, \n. link instruction can be described at least with l!, node index, !, output index, !, node index, !, input index, \n.

For an instruction scenarios above, this is either:

  1. 24 characters + 6 node indexes
  2. 27 + 7 node indexes + 2 socket indexes

Where unknown numbers are up to 33 characters in total for 6 (1) and 30 for 9 (2). Makes it an average 5.5 characters for (1) and 3.33 for (2).

KirilStrezikozin commented 6 months ago

ok resolved it we having a custom str prop in bm_props for restore instructions

KirilStrezikozin commented 6 months ago
KirilStrezikozin commented 6 months ago
KirilStrezikozin commented 6 months ago
KirilStrezikozin commented 6 months ago

imo a good name for this thing I'm developing is: map-material preview-replugging

KirilStrezikozin commented 6 months ago

btw, I get sockets by doing shadernode.outputs.get(key_str, default_any), where the returned nodesocket has identifier prop like Socket_5. Just sayin in case you somehow need to retrieve nodesockets index only having its reference. Ahh well just use ...outputs.find(key_str) - this returns an index

KirilStrezikozin commented 6 months ago
KirilStrezikozin commented 6 months ago
KirilStrezikozin commented 5 months ago

kromantiking (Discord) reported this too, AlbedoM comes out black when material setup uses nested node groups. I might need the reference below for future testing of a solution for this issue: image image

(kromantiking from Discord) It is based on this material from Blenderkit: https://www.blenderkit.com/get-blenderkit/44c1d3c0-c8a5-459f-b86b-f779c5238963/

KirilStrezikozin commented 5 months ago
KirilStrezikozin commented 5 months ago
KirilStrezikozin commented 5 months ago
KirilStrezikozin commented 5 months ago
KirilStrezikozin commented 4 months ago
KirilStrezikozin commented 4 months ago
KirilStrezikozin commented 4 months ago
KirilStrezikozin commented 4 months ago
KirilStrezikozin commented 4 months ago
KirilStrezikozin commented 4 months ago
KirilStrezikozin commented 4 months ago
KirilStrezikozin commented 4 months ago
KirilStrezikozin commented 4 months ago
KirilStrezikozin commented 4 months ago
KirilStrezikozin commented 4 months ago
KirilStrezikozin commented 4 months ago

Map preview stability check:

KirilStrezikozin commented 3 months ago
KirilStrezikozin commented 3 months ago
KirilStrezikozin commented 1 month ago

Using Combined bake type + Emit pass filter in the latest commit. This preserves transparency.

KirilStrezikozin commented 1 month ago

socket_replug(...) targets with Diffuse BSDF nodes are tracked up until this moment. Next commits mentioned here will not include these alternative targets (reason - unused).

KirilStrezikozin commented 1 month ago
KirilStrezikozin commented 1 month ago