Closed KirilStrezikozin closed 1 month ago
TODOs:
relink_materials
in utils.py
to recursively spin nodes and look inside node groups (later)~ the new mats_replug
will replace relink_materials
preview feat.mats_handle_replug
to recursively sping nodes and look inside node groupsA spreadsheet with all ShaderNode
types. Green cells are the ones BakeMaster replugs for baking and map preview.
makes the full list:
ShaderNodeBsdfAnisotropic
ShaderNodeBsdfDiffuse
ShaderNodeBsdfGlass
ShaderNodeBsdfGlossy
ShaderNodeBsdfHair
ShaderNodeBsdfHairPrincipled
ShaderNodeBsdfPrincipled
ShaderNodeBsdfRefraction
ShaderNodeBsdfToon
ShaderNodeBsdfTranslucent
ShaderNodeBsdfTransparent
ShaderNodeBsdfVelvet
ShaderNodeDisplacement
ShaderNodeEmission
ShaderNodeNormalMap
ShaderNodeVectorDisplacement
bruh pushed to master
, not dev-2.6.1
. master
has a breaking change.
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.
Time to test now.
restore_ii
replug restore instructions from replug_make_nodes
are wrongthis is like 90% done
p.s (after 3 days) more like 50% - the system is awesome but raw
damn ShaderNode.label
is 64 characters max. Not even enough for a node and link restore instruction :((
same for ShaderNode.name
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)
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:
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).
ok resolved it we having a custom str prop in bm_props for restore instructions
imo a good name for this thing I'm developing is: map-material preview-replugging
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 nodesocket
s index only having its reference. Ahh well just use ...outputs.find(key_str)
- this returns an index
NodeGroupInput
node, we should go to parent node_tree and continue searching from the nodegroupinput
's input of index we stopped at inside. ~This is applicable only to displacement and normal maps.~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:
(kromantiking from Discord) It is based on this material from Blenderkit: https://www.blenderkit.com/get-blenderkit/44c1d3c0-c8a5-459f-b86b-f779c5238963/
em_strength
is used for Emission maps, but value 0
is set when emission strength input socket has a link. Solution: allow to pass em_strength_from_socket
.AssertionError
below:
ShaderNodeTree.get_output_node(sc_render_engine)
instead of a for loop to retrieve active material output nodes.~ It doesn't matter, because we still need a for loop to find unconnected nodegroups.NoteTree
my recursive algorithm can handle to refactor it into an iterative algorithm? stack limit in blender is set to 2000. The current deepest stack travel if the required node is right after material output is 10. For each next node in the current node tree, add +2, in a ShaderNodeGroup, add +1 with no subsequent reduction in depth. So even for a 1000 nodes after material output (and it will make to a 2000 recursive calls only if these nodes in between material output and the ShaderNodeShader are MixShader, AddShader, Reroutes, NodeGroups, which is baffling for a general usage of blender shaders.bm_prop
toggle to tell this to inspect node outputs for sockets that look like map names and prioritize them.Map preview stability check:
[ ] TODO: alter default values for different shader node types to return more corrected ones. For example, Glossy BSDF can return default metalness as (1, 1, 1, 1)
instead of (0, 0, 0, 1)
since it is a BSDF for metallic surfaces. Similarly, Glass BSDF can return default transmission as (1, 1, 1, 1)
instead of (0, 0, 0, 1)
because it is a BSDF with a transmissive layer (both reflects and transmits light). This has to be tested before implementing actually to be true. This could allow replicating complex mixed BSDF Shaders of different natures into one PBR-compatible Shader like Principled BSDF.
Corrections:
1.0
;Progress:
Useful links:
DO THIS IN THE FUTURE.
DEBUG
bool var.
- [x] BUG: wrong colors for sRGB bakes #74 found that when baking Emit, image transparency is discarded. This should be checked here.
Using Combined bake type + Emit pass filter in the latest commit. This preserves transparency.
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).
DISPLACEMENT
, NORMAL_POST
) maps do not capture ems_socket
& ems_value
properly and when these values are evaluated in a different node tree than where Emission node is placed (fix: use mix node and multiply data by node strength).2.6.3*
, collapse custom nodes according to the bm_props
property.~ 'collapse nodes' collapsed nodes in baked materials, this doesn't affect previews.
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:
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:
Desktop (please complete the following information):
Additional context This is about reworking
mat_replug