Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing normal maps with Batch Material enabled #2847

Open
fatihmtlm opened this issue Apr 10, 2023 · 1 comment
Open

Mixing normal maps with Batch Material enabled #2847

fatihmtlm opened this issue Apr 10, 2023 · 1 comment
Labels
bug This issue describes a bug

Comments

@fatihmtlm
Copy link

fatihmtlm commented Apr 10, 2023

Description
Mixing two different normal map textures with batch material enabled produce weird results.

To Reproduce
Mix two normal map image textures with MixRGB node and control the mixing factor with a texture map. Enable the "Batch Materials" option.

image
Saved and internal means if the texture mask is imported as .png or internally generated/painted
Edit: After the merged PR #2853 from QC, The internal one can be irrelevant.

System
Blender: 3.3.5
Armory: SDK 2023.4
OS: Windows 10
Graphics card: Nvidia rtx 3060 laptop

Test File
Enable the Batch material option and Run.
Texture Mask.zip
*The blend file is the same as in the issue : Texture painted mask #2846

@fatihmtlm fatihmtlm added the bug This issue describes a bug label Apr 10, 2023
@QuantumCoderQC
Copy link
Contributor

The issue happens only if Batch Materials option is enabled and as pointed out already, does not depend on weather the texture is internal or external.

After some tests, the issue seems to be because of a few different situations. When Batch Materials option is enabled, the batching is evaluated based on the material signature. The material nodes are treated as uniforms and are assigned texture constants or material/ context constant depending on the following factors:

  1. The node is a texture node.
    OR
  2. The node has an input socket which is not connected.

Lets call such nodes the "uniform nodes".

Code: make.py

Issue 1

In material batching, only one material is exported per batch. So all the materials which could be batched must share identical naming conventions. That is, if Material.001 uses two image nodes (or uniform nodes) Img.001 and Img.002 respectively, the nodes in Material.002 must also be named the same. If not the texture constants will not match, and no texture link is found at runtime.

While this can be somehow solved by mapping out all the nodes in all the materials in a batch and comparing the relative positions of the uniform nodes, I think the current way of naming based assignment is faster and more logical. For example when the user needs to change the uniform of a material at runtime, the name of the node is known and does not change at export due a different material being used because of batching.

So this issue can be considered as a lack of documentation about the required naming conditions of nodes for batching.

Issue 2

The RGB nodes do not have an input socket. So an RGB node will never be considered as a Uniform Node. But this must be changed so the RGB nodes are always treated as Uniform Nodes when Material Batching is enabled. There might be other such nodes, but could not come up with any so far.

Issue 3

This may or may not be directly related to Material Batching. The node groups are not parsed properly. More specifically, seems like the node groups are parsed just once and this might not be enough. For example, if a node group contains two images, both treated as Uniform Nodes, only one of the nodes is exported and the other is not. Unfortunately, I am not sure about the cause of this issue yet.

Shader groups are parsed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes a bug
Projects
None yet
Development

No branches or pull requests

2 participants