bnpr / Malt

Render framework for NPR.
https://malt3d.com
Other
952 stars 75 forks source link

Layer Blend Node not functioning properly in Render Layers #484

Closed dibli-goost closed 1 year ago

dibli-goost commented 1 year ago

Malt version

Node Groups

Blender version

Blender 3.4

OS

Windows 10

Hardware info

AMD Ryzen Threadripper 1920x 12-Core Processor, 3950 Mhz, 24 Logical Processors | 32GB RAM | Radeon RX 570 Series

Issue description and reproduction steps

The Layer Blend node doesn't seem to be functioning properly when used within a Render Layer node tree. Seems to ignore the chosen blending mode and just uses the default normal blending mode... except for "Divide", Divide is unique, it's still not quite right but it's doing something...

Layer Blends do work properly in Render node trees.

In the Blend file I've included a screen pass in both the Render Layer and Render node trees. By default the Screen Pass is being used in the Render node tree to show that it's indeed working there, to reproduce the issue, unplug that screen pass, plug the color into the background screen pass. Then plug the Render Layer screen pass into the node tree's color output.

Attachments

Layer Blend Render Layers Bug.zip

Don't see a reason in uploading the log, nothing's getting reported.

pragma37 commented 1 year ago

This is not really a bug, it's just how it is supposed to work.

Render Layers, as its name implies, renders the scene by layers. Specifically, each layer of transparency is rendered separately and then composited together. This is why Malt supports the same features for opaque and transparent materials, unlike most real-time engines. However, this also means that, in your example, at any given layer pixel, only Color A or Color B can be non-transparent. You can think of this as the layers of a painting program, you can have multiple layers, but each pixel of those layers can only have one color.

That's why we have Render and Render Layer nodes, because they are meant for different purposes.

I know this can be somewhat confusing and that requiring the user to understand the underlying implementation is not ideal, but it's also the best solution I could come up with.