Nodes: Merge Musgrave Texture Node Into Noise Texture Node #111187

Merged
Omar Emara merged 92 commits from Hoshinova/blender:merge-noise-nodes2 into main 2023-11-18 09:40:52 +01:00
Member

A continuation of #111053

The PR corresponding to https://devtalk.blender.org/t/merging-the-musgrave-texture-and-noise-texture-nodes/30646

This PR merges all functionalities of the Musgrave Texture node into the Noise Texture node.
Apart from removing duplicate functionalities and a few thousand lines of duplicate code, it effectively adds the Distortion input and the Color output to the formerly Musgrave Texture exclusive noise types (Multifractal, Ridged Multifractal, Hybrid Multifractal and Hetero Terrain).

The Noise Texture output corresponds to the Musgrave Texture fBM noise type.

The Dimension input of the Musgrave Texture corresponds to the Roughness input of the Noise Texture and can be converted as follows: $Roughness=Lacunarity^{-Dimension}$
Using Roughness instead of the Dimension input has the added advantage of fixing #112180 for all Musgrave Texture noise types, thus completing #112962

Because Lacunarity^{-Dimension} can produce values greater than 1.0 the Roughness input of the new Noise Texture will no longer be clamped to [0.0, 1.0] but instead to [0.0, $\infty$).
This allows artists to create "rougher" noise than was previously possible.

The versioning implemented in this PR ensures that the Dimension inputs are correctly converted to their respective Roughness values for all Musgrave Texture nodes and all Roughness values are correctly clamped for all Noise Texture nodes.

The Detail inputs of the Musgrave and Noise Textures despite sharing the same name unfortunately do not behave identically.
The Musgrave Texture Detail input computes one octave fewer than the Noise Texture Detail input.
That is $Detail_{Noise}=Detail_{Musgrave} -1.0$
Problems arise when Detail_{Musgrave}<1.0 as there is no corresponding Detail_{Noise} value because the Detail values are always non-negative.

The fBM and Hybrid Multifractal noise types are linear as functions of the Detail input when Detail<1.0 meaning it's possible to just scale the new outputs to match the old ones.

While not linear the Multifractal noise type is affine linear as a function of the Detail input when Detail<1.0 meaning it's possible to just scale the new outputs then add a constant offset to match the old ones.

The Ridged Multifractal and Hetero Terrain noise types aren't even affine linear making it much more difficult to match the new and old outputs. Unless... There is a bug that went undiscovered for years that makes the Musgrave Texture node to skip evaluation of the first octave. That's right, there is a bug that effectively causes the Musgrave Texture node to have the same output when the Detail is set to 0.x and 1.x, meaning that for the case Detail_{Musgrave}<1.0 we can simply substitute Detail_{Noise}=Detail_{Musgrave} avoiding the problem altogether.

As for the bug I mentioned this PR fixes it as well by simply using Detail_{Noise} instead of Detail_{Musgrave}.

The versioning implemented in this PR ensures that the Detail_{Musgrave} inputs are correctly converted to their respective Detail_{Noise} values for Musgrave Texture nodes.

Forward compatibility with Blender 4.0 is ensured by #114236.
Forward compatibility with Blender 3.6 LTS is ensured by #115015.

The output of the Noise and Musgrave Texture nodes in Blender 3.6 LTS and 4.0 is usually identical to that in Blender 4.1, but with a few exceptions:

  1. The combined Noise Texture node has a Distortion input and a Color output, which the Musgrave Texture node doesn't. These inputs/outputs are ignored and any links connected to them are deleted.
  2. The Musgrave Texture Detail input computes one octave fewer than the Noise Texture Detail input. The versioning code corrects that by setting Detail_{Musgrave}=Detail_{Noise} + 1.0 however when the Detail input in Blender 4.1 is set to a value >14.0 it will be clamped to a maximum of 15.0. This happens internally and can't be circumvented using nodes.
  3. The Musgrave Texture Dimension and Lacunarity inputs are internally clamped to a minimum of 10^{-5}.
  4. The Noise Texture Roughness input is internally clamped to a maximum of 1.0.
  5. The Lacunarity input doesn't exist in Blender 3.6 LTS, so it is ignored and any links connected to it are deleted.

Below is an image of the Noise Texture node. Left is the old version, right is the new version.
Old_vs_New.png

A continuation of https://projects.blender.org/blender/blender/pulls/111053 The PR corresponding to https://devtalk.blender.org/t/merging-the-musgrave-texture-and-noise-texture-nodes/30646 This PR merges all functionalities of the Musgrave Texture node into the Noise Texture node. Apart from removing duplicate functionalities and a few thousand lines of duplicate code, it effectively adds the Distortion input and the Color output to the formerly Musgrave Texture exclusive noise types (Multifractal, Ridged Multifractal, Hybrid Multifractal and Hetero Terrain). The Noise Texture output corresponds to the Musgrave Texture fBM noise type. The Dimension input of the Musgrave Texture corresponds to the Roughness input of the Noise Texture and can be converted as follows: $Roughness=Lacunarity^{-Dimension}$ Using Roughness instead of the Dimension input has the added advantage of fixing https://projects.blender.org/blender/blender/issues/112180 for all Musgrave Texture noise types, thus completing https://projects.blender.org/blender/blender/pulls/112962 Because $Lacunarity^{-Dimension}$ can produce values greater than 1.0 the Roughness input of the new Noise Texture will no longer be clamped to [0.0, 1.0] but instead to [0.0, $\infty$). This allows artists to create "rougher" noise than was previously possible. The versioning implemented in this PR ensures that the Dimension inputs are correctly converted to their respective Roughness values for all Musgrave Texture nodes and all Roughness values are correctly clamped for all Noise Texture nodes. The Detail inputs of the Musgrave and Noise Textures despite sharing the same name unfortunately do not behave identically. The Musgrave Texture Detail input computes one octave fewer than the Noise Texture Detail input. That is $Detail_{Noise}=Detail_{Musgrave} -1.0$ Problems arise when $Detail_{Musgrave}<1.0$ as there is no corresponding $Detail_{Noise}$ value because the Detail values are always non-negative. The fBM and Hybrid Multifractal noise types are linear as functions of the Detail input when $Detail<1.0$ meaning it's possible to just scale the new outputs to match the old ones. While not linear the Multifractal noise type is affine linear as a function of the Detail input when $Detail<1.0$ meaning it's possible to just scale the new outputs then add a constant offset to match the old ones. The Ridged Multifractal and Hetero Terrain noise types aren't even affine linear making it much more difficult to match the new and old outputs. Unless... There is a bug that went undiscovered for years that makes the Musgrave Texture node to skip evaluation of the first octave. That's right, there is a bug that effectively causes the Musgrave Texture node to have the same output when the Detail is set to 0.x and 1.x, meaning that for the case $Detail_{Musgrave}<1.0$ we can simply substitute $Detail_{Noise}=Detail_{Musgrave}$ avoiding the problem altogether. As for the bug I mentioned this PR fixes it as well by simply using $Detail_{Noise}$ instead of $Detail_{Musgrave}$. The versioning implemented in this PR ensures that the $Detail_{Musgrave}$ inputs are correctly converted to their respective $Detail_{Noise}$ values for Musgrave Texture nodes. Forward compatibility with Blender 4.0 is ensured by #114236. Forward compatibility with Blender 3.6 LTS is ensured by #115015. The output of the Noise and Musgrave Texture nodes in Blender 3.6 LTS and 4.0 is usually identical to that in Blender 4.1, but with a few exceptions: 1) The combined Noise Texture node has a Distortion input and a Color output, which the Musgrave Texture node doesn't. These inputs/outputs are ignored and any links connected to them are deleted. 2) The Musgrave Texture Detail input computes one octave fewer than the Noise Texture Detail input. The versioning code corrects that by setting $Detail_{Musgrave}=Detail_{Noise} + 1.0$ however when the Detail input in Blender 4.1 is set to a value $>14.0$ it will be clamped to a maximum of $15.0$. This happens internally and can't be circumvented using nodes. 3) The Musgrave Texture Dimension and Lacunarity inputs are internally clamped to a minimum of $10^{-5}$. 4) The Noise Texture Roughness input is internally clamped to a maximum of $1.0$. 5) The Lacunarity input doesn't exist in Blender 3.6 LTS, so it is ignored and any links connected to it are deleted. Below is an image of the Noise Texture node. Left is the old version, right is the new version. ![Old_vs_New.png](/attachments/533cf1bb-4f7b-45a0-97fe-8a156c84ed87)
Hoshinova added 26 commits 2023-08-16 16:44:19 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
e1b82960d3
-- Implement new inputs to shader and geometry nodes.
buildbot/vexp-code-patch-coordinator Build done. Details
893b425dcc
Merge branch 'main' into add-noise-inputs
buildbot/vexp-code-patch-coordinator Build done. Details
312ba903f8
-- Do versioning
buildbot/vexp-code-patch-coordinator Build done. Details
e848057d17
BLENDER_SOURCE_CODE_COMMIT commit message number: 18
Hoshinova requested review from Brecht Van Lommel 2023-08-16 16:45:31 +02:00
Hoshinova requested review from Jacques Lucke 2023-08-16 16:45:31 +02:00
Hoshinova requested review from Omar Emara 2023-08-16 16:45:32 +02:00
Hoshinova added 1 commit 2023-08-17 17:46:17 +02:00
Hoshinova added 1 commit 2023-08-17 17:47:21 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
a026f19eaa
Merge branch 'main' into merge-noise-nodes2
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova reviewed 2023-08-17 18:38:24 +02:00
@ -397,0 +425,4 @@
bNode *subNode = nodeAddStaticNode(nullptr, ntree, SH_NODE_MATH);
subNode->custom1 = NODE_MATH_SUBTRACT;
subNode->locx = node->locx;
Author
Member

Node location is off when node is inside node frame

Node location is off when node is inside node frame
Hoshinova marked this conversation as resolved
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova added 1 commit 2023-08-18 13:41:05 +02:00
Hoshinova added 1 commit 2023-08-18 13:55:57 +02:00
Hoshinova added 2 commits 2023-08-18 14:36:50 +02:00
Hoshinova reviewed 2023-08-18 16:50:53 +02:00
Hoshinova added 4 commits 2023-08-18 17:17:53 +02:00
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova added 1 commit 2023-08-19 15:05:42 +02:00
Hans Goudey changed title from Merge Musgrave Texture Node Into Noise Texture Node to Nodes: Merge Musgrave Texture Node Into Noise Texture Node 2023-08-19 23:09:55 +02:00
Hoshinova added 2 commits 2023-08-21 16:29:35 +02:00
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova added 1 commit 2023-08-21 18:44:11 +02:00
Hoshinova added 1 commit 2023-08-22 13:34:05 +02:00
Hoshinova added 1 commit 2023-08-22 13:35:02 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
eeac30cc70
Merge branch 'main' into merge-noise-nodes2
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Author
Member

A .blend file for testing the whether all shader node implementations are equivalent is here:

Noise_Test_File.blend

I still haven't found a good solution for testing Geo nodes, since the Geo nodes viewer only allows viewing one object at a time.
So Jacques you can get a little creative testing the Geo nodes implementation on your side. 😉

A .blend file for testing the whether all shader node implementations are equivalent is here: [Noise_Test_File.blend](/attachments/785d44fe-54f9-429b-9099-71794d574c14) I still haven't found a good solution for testing Geo nodes, since the Geo nodes viewer only allows viewing one object at a time. So Jacques you can get a little creative testing the Geo nodes implementation on your side. 😉
Hoshinova added 2 commits 2023-08-22 17:39:37 +02:00
Omar Emara approved these changes 2023-08-28 21:09:42 +02:00
Omar Emara left a comment
Member

I am skeptical on the use of socket->link->fromnode in the versioning code, as I am not sure when/if they get updated. It seems a loop over links is needed. Maybe @JacquesLucke knows for sure?

Main should be merged and the subversion should be updated, other than that, looks good.

I am skeptical on the use of `socket->link->fromnode` in the versioning code, as I am not sure when/if they get updated. It seems a loop over links is needed. Maybe @JacquesLucke knows for sure? Main should be merged and the subversion should be updated, other than that, looks good.
Iliya Katushenock reviewed 2023-08-28 21:21:07 +02:00
@ -408,0 +412,4 @@
if (node->type == SH_NODE_TEX_MUSGRAVE_DEPRECATED) {
STRNCPY(node->idname, "ShaderNodeTexNoise");
node->type = SH_NODE_TEX_NOISE;
NodeTexNoise *data = (NodeTexNoise *)MEM_callocN(sizeof(NodeTexNoise), __func__);

MEM_cnew<NodeTexNoise>

`MEM_cnew<NodeTexNoise>`
Author
Member

What's the difference?

What's the difference?

You should not use this if there is a specific equivalent. Code cleanliness.

You should not use this if there is a specific equivalent. Code cleanliness.
Author
Member

So it's the same?

So it's the same?
Hoshinova marked this conversation as resolved
@ -408,0 +413,4 @@
STRNCPY(node->idname, "ShaderNodeTexNoise");
node->type = SH_NODE_TEX_NOISE;
NodeTexNoise *data = (NodeTexNoise *)MEM_callocN(sizeof(NodeTexNoise), __func__);
data->base = ((NodeTexMusgrave *)node->storage)->base;

Use static_cast<NodeTexMusgrave *>() for all void * -> T * conversions

Use `static_cast<NodeTexMusgrave *>()` for all `void *` -> `T *` conversions
Hoshinova marked this conversation as resolved
@ -408,0 +440,4 @@
subNode1->locx = node->locx;
subNode1->locy = node->locy - 300.0f;
subNode1->flag |= NODE_HIDDEN;
bNodeSocket *subSock1A = static_cast<bNodeSocket *>(BLI_findlink(&subNode1->inputs, 0));

nodeFindSocket ?

`nodeFindSocket` ?
Author
Member

I asked and apparently it's the same.

I asked and apparently it's the same.

Code cleanliness.

Code cleanliness.
Author
Member

I know but using static_cast<bNodeSocket *>(BLI_findlink()) seems to be most common for the math node for some reason. See:
0edd60b4c7/source/blender/blenloader/intern/versioning_280.cc (L2136)
and
2419acf756/source/blender/blenloader/intern/versioning_280.cc (L1311).

I know but using `static_cast<bNodeSocket *>(BLI_findlink())` seems to be most common for the math node for some reason. See: https://projects.blender.org/blender/blender/src/commit/0edd60b4c77f58b680bf34655c5fe9686c0b864d/source/blender/blenloader/intern/versioning_280.cc#L2136 and https://projects.blender.org/blender/blender/src/commit/2419acf7562dbae88c7fa0f5dae4e42ed1918967/source/blender/blenloader/intern/versioning_280.cc#L1311.
Member

Right, socket->link->fromnode shouldn't be used, unless it has been set explicitly before. Not sure how often we use that in versioning code currently. If we don't use it much already, better create a new temporary Map instead of using fromnode.

Right, `socket->link->fromnode` shouldn't be used, unless it has been set explicitly before. Not sure how often we use that in versioning code currently. If we don't use it much already, better create a new temporary `Map` instead of using `fromnode`.
Omar Emara requested changes 2023-08-29 12:39:36 +02:00
Omar Emara left a comment
Member

The versioning code should be updated to not assume updated links then.

The versioning code should be updated to not assume updated links then.
Author
Member

Today marks the historical day were @mod_moder and I agree for once. MEM_cnew will be used instead of MEM_callocN!

Today marks the historical day were @mod_moder and I agree for once. `MEM_cnew` will be used instead of `MEM_callocN`!
Hoshinova added 2 commits 2023-09-22 18:00:35 +02:00
Hoshinova added 1 commit 2023-09-22 18:29:02 +02:00
Hoshinova added 3 commits 2023-09-24 17:28:37 +02:00
Author
Member

@OmarEmaraDev @JacquesLucke I've changed the versioning code to not use socket->link->fromnode.

@OmarEmaraDev @JacquesLucke I've changed the versioning code to not use `socket->link->fromnode`.
Author
Member

Unrelated to this PR, but the versioning function below mine 4aaae8d0a6/source/blender/blenloader/intern/versioning_400.cc (L638) uses socket->link->fromnode extensively.
Might want to give a note to @LukasStockner that it shouldn't be used.

Unrelated to this PR, but the versioning function below mine https://projects.blender.org/blender/blender/src/commit/4aaae8d0a654f17d62f0a11efd459d53005e0bba/source/blender/blenloader/intern/versioning_400.cc#L638 uses `socket->link->fromnode` extensively. Might want to give a note to @LukasStockner that it shouldn't be used.
Author
Member

A .blend file for testing the versioning is here:
[Versioning_Test_File.blend]

A .blend file for testing the whether all node implementations are equivalent is here:
[Noise_Test_File.blend]

Note: Both files are outdated, please use the files provided in #111187 (comment)

A .blend file for testing the versioning is here: [Versioning_Test_File.blend] A .blend file for testing the whether all node implementations are equivalent is here: [Noise_Test_File.blend] **Note: Both files are outdated, please use the files provided in https://projects.blender.org/blender/blender/pulls/111187#issuecomment-1033470**
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova reviewed 2023-09-24 18:46:57 +02:00
@ -583,0 +592,4 @@
data->dimensions = (static_cast<NodeTexMusgrave *>(node->storage))->dimensions;
data->normalize = false;
data->type = (static_cast<NodeTexMusgrave *>(node->storage))->musgrave_type;
node->storage = data;
Author
Member

Does the old node->storage need to be freed?

Does the old `node->storage` need to be freed?
Hoshinova marked this conversation as resolved
Hoshinova added 2 commits 2023-09-25 13:18:32 +02:00
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova added 1 commit 2023-09-25 14:43:29 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
5b9025fef3
-- Explicilt template instantiation for Wave Texture.

@blender-bot build

@blender-bot build
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova added 1 commit 2023-09-25 19:41:36 +02:00
Omar Emara requested changes 2023-09-26 09:23:06 +02:00
@ -588,0 +591,4 @@
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_MUSGRAVE_DEPRECATED) {
STRNCPY(node->idname, "ShaderNodeTexNoise");
node->type = VERSIONING_NODE_1;
Member

I don't understand why this is necessary. The loops where you use that value to identify the node can just compare the node pointer from the upper loop to the link->tonode pointer.

I don't understand why this is necessary. The loops where you use that value to identify the node can just compare the `node` pointer from the upper loop to the `link->tonode` pointer.
Hoshinova marked this conversation as resolved
@ -588,0 +597,4 @@
data->dimensions = (static_cast<NodeTexMusgrave *>(node->storage))->dimensions;
data->normalize = false;
data->type = (static_cast<NodeTexMusgrave *>(node->storage))->musgrave_type;
node->storage = data;
Member

Yes, do free the old storage first.

Yes, do free the old storage first.
Hoshinova marked this conversation as resolved
@ -588,0 +603,4 @@
float *detail = version_cycles_node_socket_float_value(sockDetail);
bNodeSocket *sockFac = nodeFindSocket(node, SOCK_OUT, "Fac");
if (sockFac->label[0] != '\0') {
Member

The if statement is redundant in this case. Add a comment saying why the label is cleared.

The if statement is redundant in this case. Add a comment saying why the label is cleared.
Hoshinova marked this conversation as resolved
@ -588,0 +610,4 @@
uint8_t noise_type = (static_cast<NodeTexNoise *>(node->storage))->type;
float locyoffset = 0.0f;
if (version_node_socket_is_used(sockDetail) && sockDetail->link != nullptr) {
Member

You are still using socket->link in multiple parts of the code. The link itself is the one that can be non-updated, not its to and from nodes members. Sorry for the misunderstanding.

Consider the following code:

bNodeLink detailsLink = nullptr;
bNodeLink roughnessLink = nullptr;
...
LISTBASE_FOREACH_BACKWARD (bNodeLink *, link, &ntree->links) {
  if (link->tonode != node) {
    continue;
  }
  if (STREQ(link->tosock->identifier, "Detail")) {
    detailsLink = link;
  }
  if (STREQ(link->tosock->identifier, "Roughness")) {
    roughnessLink = link;
  }
  ...
}

if (detailsLink) {
  /* Details socket is linked. */
} else {
  /* Details socket is not linked. */
}

So you essentially find all sockets at once, then handle them after. You can even do it for all nodes in the same loop with a bit more work.

You are still using `socket->link` in multiple parts of the code. The link itself is the one that can be non-updated, not its `to` and `from` nodes members. Sorry for the misunderstanding. Consider the following code: ``` bNodeLink detailsLink = nullptr; bNodeLink roughnessLink = nullptr; ... LISTBASE_FOREACH_BACKWARD (bNodeLink *, link, &ntree->links) { if (link->tonode != node) { continue; } if (STREQ(link->tosock->identifier, "Detail")) { detailsLink = link; } if (STREQ(link->tosock->identifier, "Roughness")) { roughnessLink = link; } ... } if (detailsLink) { /* Details socket is linked. */ } else { /* Details socket is not linked. */ } ``` So you essentially find all sockets at once, then handle them after. You can even do it for all nodes in the same loop with a bit more work.
Hoshinova marked this conversation as resolved
Hoshinova added 2 commits 2023-09-26 16:19:17 +02:00
Hoshinova added 1 commit 2023-09-26 16:25:25 +02:00
Hoshinova added 1 commit 2023-09-26 16:50:52 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
f9332dba07
-- Refix versioning.

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova reviewed 2023-09-26 17:06:04 +02:00
@ -588,0 +597,4 @@
data->dimensions = (static_cast<NodeTexMusgrave *>(node->storage))->dimensions;
data->normalize = false;
data->type = (static_cast<NodeTexMusgrave *>(node->storage))->musgrave_type;
MEM_freeN(node->storage);
Author
Member

Just to make sure MEM_freeN(node->storage); is enough to free the memory right? No need to tell it how much memory to free etc.?

Just to make sure `MEM_freeN(node->storage);` is enough to free the memory right? No need to tell it how much memory to free etc.?
Member

Yes, those things are stored internally so you shouldn't worry about them.

Yes, those things are stored internally so you shouldn't worry about them.
Hoshinova marked this conversation as resolved
Hoshinova added 1 commit 2023-09-27 17:45:36 +02:00
Hoshinova added 2 commits 2023-09-28 15:12:12 +02:00
Hoshinova added 1 commit 2023-09-28 16:30:12 +02:00
Hoshinova added 1 commit 2023-09-28 16:33:29 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
be27520ea1
BLENDER_SOURCE_CODE_COMMIT commit message number: 29
Author
Member

@OmarEmaraDev @JacquesLucke @brecht I've updated the test .blend files, please use the new ones.

@OmarEmaraDev @JacquesLucke @brecht I've updated the test .blend files, please use the new ones.

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Author
Member

An updated .blend file for testing the versioning is here:
Versioning_Test_File.blend

It was originally created in Blender 3.4 and contains Musgrave, Noise and Wave Texture Materials.
When loaded into 4.0 the Musgrave Textures should automatically get converted to the corresponding Noise Textures.
The output (rendered image) should be identical in both versions.

A .blend file for testing the whether all node implementations are equivalent is here:
Noise_Test_File.blend

And just for you @JacquesLucke I even looked into how Geometry nodes work 😉 .
On top of the Shader nodes test planes are a layer of test planes passing the Geometry node Noise texture outputs as a color attribute to the Material output. Simply toggle the "Geo Nodes" Collection in the Outliner to switch between the Shader and Geometry nodes test planes.
Apart from the fact that the Geometry nodes version is more blurry because it's only evaluated at mesh vertices the output (rendered image) should be identical for all node implementations.

An updated .blend file for testing the versioning is here: [Versioning_Test_File.blend](/attachments/35ea7f1a-aa78-4505-8766-c19665a74d31) It was originally created in Blender 3.4 and contains Musgrave, Noise and Wave Texture Materials. When loaded into 4.0 the Musgrave Textures should automatically get converted to the corresponding Noise Textures. The output (rendered image) should be identical in both versions. A .blend file for testing the whether all node implementations are equivalent is here: [Noise_Test_File.blend](/attachments/b5eebfbd-ffa3-4a69-96b8-f329c96f391d) And just for you @JacquesLucke I even looked into how Geometry nodes work 😉 . On top of the Shader nodes test planes are a layer of test planes passing the Geometry node Noise texture outputs as a color attribute to the Material output. Simply toggle the "Geo Nodes" Collection in the Outliner to switch between the Shader and Geometry nodes test planes. Apart from the fact that the Geometry nodes version is more blurry because it's only evaluated at mesh vertices the output (rendered image) should be identical for all node implementations.
Hoshinova reviewed 2023-09-28 20:02:13 +02:00
Hoshinova reviewed 2023-09-28 20:03:52 +02:00
@ -595,0 +611,4 @@
}
}
bNodeSocket *sockRoughness = nodeFindSocket(node, SOCK_IN, "Roughness");
Author
Member

nullptr

nullptr
Hoshinova marked this conversation as resolved
Hoshinova added 3 commits 2023-09-28 20:38:16 +02:00
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova added 1 commit 2023-09-29 14:15:59 +02:00
Hoshinova added 2 commits 2023-09-29 20:03:53 +02:00
Hoshinova added 2 commits 2023-09-30 16:03:43 +02:00
Hoshinova added 1 commit 2023-09-30 16:34:09 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
7d98386a63
BLENDER_SOURCE_CODE_COMMIT commit message number: 30
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova added 1 commit 2023-10-02 16:06:38 +02:00
Author
Member

@blender-bot package

@blender-bot package
Member

Only blender organization members with write access can start builds. See documentation for details.

Only blender organization members with write access can start builds. See [documentation](https://projects.blender.org/infrastructure/blender-bot/src/branch/main/README.md) for details.
Hoshinova added 1 commit 2023-10-04 16:18:26 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
2eb11b9c63
Merge branch 'main' into merge-noise-nodes2
Author
Member

@blender-bot package

@blender-bot package
Member

Only blender organization members with write access can start builds. See documentation for details.

Only blender organization members with write access can start builds. See [documentation](https://projects.blender.org/infrastructure/blender-bot/src/branch/main/README.md) for details.
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova added 1 commit 2023-10-04 19:21:45 +02:00
Jacques Lucke requested changes 2023-10-09 12:28:23 +02:00
Jacques Lucke left a comment
Member

Please run make format, there are some formatting issues in versioning_400.cc.

Looks like every old Musgrave node now has at least two additional nodes (Multiply and Power). This seems unnecessary when we can just change the roughness value inplace.

Please run `make format`, there are some formatting issues in `versioning_400.cc`. Looks like every old `Musgrave` node now has at least two additional nodes (`Multiply` and `Power`). This seems unnecessary when we can just change the roughness value inplace.
@ -535,3 +535,2 @@
template<typename T>
float perlin_fractal_template(
T position, float octaves, float roughness, float lacunarity, bool normalize)
float perlin_fbm(
Member

Would be nice to mention what fbm stands for here in a comment.

Would be nice to mention what `fbm` stands for here in a comment.
Hoshinova marked this conversation as resolved
@ -764,3 +563,1 @@
/* -------------------------------------------------------------------- */
/** \name Musgrave Noise
* \{ */
/* Explicilt instantiation for Wave Texture. */
Member

typo

typo
Hoshinova marked this conversation as resolved
@ -596,0 +600,4 @@
if (node->type == SH_NODE_TEX_NOISE) {
(static_cast<NodeTexNoise *>(node->storage))->type = SHD_NOISE_FBM;
bNodeSocket *sockRoughness = nodeFindSocket(node, SOCK_IN, "Roughness");
Member

roughness_socket

`roughness_socket`
Author
Member

You mean I should rename sockRoughness to roughness_socket? Why just this specific socket? It makes the naming inconsistent with the rest of the code.

You mean I should rename `sockRoughness` to `roughness_socket`? Why just this specific socket? It makes the naming inconsistent with the rest of the code.
https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Naming
Author
Member

Yeah, I know but a lot of other versioning code also uses Camel case. Should I change all variable names to snake case?

Yeah, I know but a lot of other versioning code also uses Camel case. Should I change all variable names to snake case?

No, do this only for new code. All unrelated changes can be sent as separate cleanups.

No, do this only for new code. All unrelated changes can be sent as separate cleanups.
Author
Member

@JacquesLucke You sure that I should rename all new variables? (It's quite a lot)

@JacquesLucke You sure that I should rename **all** new variables? (It's quite a lot)
Member

Yes, new code should use the snake case naming conventions mentioned in the style guide.

Yes, new code should use the snake case naming conventions mentioned in the style guide.
Hoshinova marked this conversation as resolved
@ -596,0 +612,4 @@
bNode *roughnessFromNode = nullptr;
bNodeSocket *roughnessFromSock = nullptr;
LISTBASE_FOREACH_BACKWARD_MUTABLE (bNodeLink *, link, &ntree->links) {
Member

Any reason for using LISTBASE_FOREACH_BACKWARD_MUTABLE instead of LISTBASE_FOREACH.

Any reason for using `LISTBASE_FOREACH_BACKWARD_MUTABLE` instead of `LISTBASE_FOREACH`.
Author
Member

I think @OmarEmaraDev told me to.

I think @OmarEmaraDev told me to.
Member

That was for the case when were adding and removing links inside the loop, hence the mutable and backward keywords.

That was for the case when were adding and removing links inside the loop, hence the mutable and backward keywords.
Hoshinova marked this conversation as resolved
@ -596,0 +614,4 @@
LISTBASE_FOREACH_BACKWARD_MUTABLE (bNodeLink *, link, &ntree->links) {
/* Find links, nodes and sockets. */
if ((link->tonode == node) && (STREQ(link->tosock->identifier, "Roughness"))) {
Member

Couldn't you compare link->tosock with sockRoughness?

Couldn't you compare `link->tosock` with `sockRoughness`?
Author
Member

Thought about that, but kept it like this to make the logic consistent with versioning_replace_musgrave_texture_node. But will change if you want that.

Thought about that, but kept it like this to make the logic consistent with `versioning_replace_musgrave_texture_node`. But will change if you want that.
Hoshinova marked this conversation as resolved
@ -596,0 +655,4 @@
{
version_node_input_socket_name(ntree, SH_NODE_TEX_MUSGRAVE_DEPRECATED, "Dimension", "Roughness");
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
if (node->type == SH_NODE_TEX_MUSGRAVE_DEPRECATED) {
Member

continue early for the wrong node type, instead of indenting everything below.

`continue` early for the wrong node type, instead of indenting everything below.
Hoshinova marked this conversation as resolved
@ -596,0 +678,4 @@
bNode *lacunarityFromNode = nullptr;
bNodeSocket *lacunarityFromSock = nullptr;
LISTBASE_FOREACH_BACKWARD_MUTABLE (bNodeLink *, link, &ntree->links) {
Member

LISTBASE_FOREACH

`LISTBASE_FOREACH`
Hoshinova marked this conversation as resolved
@ -596,0 +712,4 @@
if (detailLink != nullptr) {
locyoffset -= 40.0f;
/* Add Subtract Math node before Detail input. */
Member

Would be useful to add a little bit of reasoning for each of these added nodes as comments.

Would be useful to add a little bit of reasoning for each of these added nodes as comments.
Author
Member

I think the reasoning behind it is too complicated for comments to describe. The PR description is already rather complicated despite only containing hand waving explanations, so I'd rather leave it at just that rather than having some potentially misleading comments

I think the reasoning behind it is too complicated for comments to describe. The PR description is already rather complicated despite only containing hand waving explanations, so I'd rather leave it at just that rather than having some potentially misleading comments
Hoshinova marked this conversation as resolved
@ -145,6 +221,19 @@ class NoiseFunction : public mf::MultiFunction {
const VArray<float> &detail = params.readonly_single_input<float>(param++, "Detail");
const VArray<float> &roughness = params.readonly_single_input<float>(param++, "Roughness");
const VArray<float> &lacunarity = params.readonly_single_input<float>(param++, "Lacunarity");
/* Initialize to any other variable when unused to avoid unnecessary conditionals */
Member

End comments with a dot.

End comments with a dot.
Hoshinova marked this conversation as resolved

After looking at this more closely, I'm not sure about this change anymore.

From the description in the devtalk topic I had understood that the Noise Texture node already contained all the features of the Musgrave node, and agreed with the change because of that. And also assuming it would simplify the code significantly. But it seems that was only for the fbm mode and the Noise Texture is now getting an additional enum and 2 input sockets for the other modes.

For the fbm mode it is indeed redundant, but the other modes the purpose is rather different and was made for a height output that is not in the 0..1 range. Those modes make less sense for a more generic noise texture node that can be used as a building block. So in terms of organization, it's not clear to me it's helpful to merge in those modes mainly meant for modelling terrains.

Additionally, this is going to break forward compatibility which we try to avoid for minor releases like 4.1. It's possible to add some code compensating for that in 4.0 and 3.6, but it's extra code complexity.

I apologize for not checking this sooner.

After looking at this more closely, I'm not sure about this change anymore. From the description in the devtalk topic I had understood that the Noise Texture node already contained all the features of the Musgrave node, and agreed with the change because of that. And also assuming it would simplify the code significantly. But it seems that was only for the fbm mode and the Noise Texture is now getting an additional enum and 2 input sockets for the other modes. For the fbm mode it is indeed redundant, but the other modes the purpose is rather different and was made for a height output that is not in the 0..1 range. Those modes make less sense for a more generic noise texture node that can be used as a building block. So in terms of organization, it's not clear to me it's helpful to merge in those modes mainly meant for modelling terrains. Additionally, this is going to break forward compatibility which we try to avoid for minor releases like 4.1. It's possible to add some code compensating for that in 4.0 and 3.6, but it's extra code complexity. I apologize for not checking this sooner.
Author
Member

@brecht

And also assuming it would simplify the code significantly. But it seems that was only for the fbm mode and the Noise Texture is now getting an additional enum and 2 input sockets for the other modes.

The "additional" enum and 2 were already there, they've just been moved form the Musgrave to the Noise Texture.
And it removes over 2 thousand lines of code which in I'd consider a significant code simplification.

For the fbm mode it is indeed redundant, but the other modes the purpose is rather different and was made for a height output that is not in the 0..1 range. Those modes make less sense for a more generic noise texture node that can be used as a building block. So in terms of organization, it's not clear to me it's helpful to merge in those modes mainly meant for modelling terrains.

While it's true that historically the Musgrave noise modes were created for modelling terrains that's also the case for the fBM mode. It was only when artists started using it for creating other things that it became generic.
That's also one of my goals for this PR. I don't see why the other Musgrave noise modes should be confined to just creating terrain.In my eyes they're just as usable as generic noise types however the Musgrave Texture node makes using it for anything other than creating terrains very challenging because the Dimension input really only works when creating terrains, which is why I replaced it by the more generic Roughness input.

I understand that for artists used to the Dimension input it will take a little time to get used to the new Roughness input, however I believe without a doubt that the new Roughness input will be easier to use for them in the long term.
When creating procedural noise texture you usually think of the scale of the individual layers that is the Lacunarity input and the height of the individual layers that is the Roughness input as separate things. The Dimension input only controls the height of the layers but needs 2 inputs (both the Dimension and Lacunarity) input to do that. So if you change the Lacunarity value you also change the height of the layers. This kind of entanglement works for creating terrains, but also only terrains, because it was made with creating terrains in mind, but again it prevents it from being used for more generic use cases.

Apart from that I doubt that most artists actually understand what transformations the Dimension input value undergoes before it finally influences the height of the noise layers but rather just tweak it until they get their wanted result.
For that the Roughness input is far easier to use than the Dimension input, as it neither has inter-dependencies nor undergoes an exponentiation.

I could easily add an checkbox, which turns the Roughness input to the Dimension input, but I deliberately decided against it because I don't want artists use an input which they don't really understand. If there turns out to really be demand for it I can still to it in a later PR.

Additionally, this is going to break forward compatibility which we try to avoid for minor releases like 4.1. It's possible to add some code compensating for that in 4.0 and 3.6, but it's extra code complexity.

I'm aware that we try to keep forward compatibility for minor releases, which was why I tried to get it in 4.0. We also talked about that in the Nodes & Physics module meeting and as far as I've understood the decision was that we'll take the hit and break forward compatibility for this.

@brecht >And also assuming it would simplify the code significantly. But it seems that was only for the fbm mode and the Noise Texture is now getting an additional enum and 2 input sockets for the other modes. The "additional" enum and 2 were already there, they've just been moved form the Musgrave to the Noise Texture. And it removes over 2 thousand lines of code which in I'd consider a significant code simplification. >For the fbm mode it is indeed redundant, but the other modes the purpose is rather different and was made for a height output that is not in the 0..1 range. Those modes make less sense for a more generic noise texture node that can be used as a building block. So in terms of organization, it's not clear to me it's helpful to merge in those modes mainly meant for modelling terrains. While it's true that historically the Musgrave noise modes were created for modelling terrains that's also the case for the fBM mode. It was only when artists started using it for creating other things that it became generic. That's also one of my goals for this PR. I don't see why the other Musgrave noise modes should be confined to just creating terrain.In my eyes they're just as usable as generic noise types however the Musgrave Texture node makes using it for anything other than creating terrains very challenging because the Dimension input really only works when creating terrains, which is why I replaced it by the more generic Roughness input. I understand that for artists used to the Dimension input it will take a little time to get used to the new Roughness input, however I believe without a doubt that the new Roughness input will be easier to use for them in the long term. When creating procedural noise texture you usually think of the scale of the individual layers that is the Lacunarity input and the height of the individual layers that is the Roughness input as separate things. The Dimension input only controls the height of the layers but needs 2 inputs (both the Dimension and Lacunarity) input to do that. So if you change the Lacunarity value you also change the height of the layers. This kind of entanglement works for creating terrains, but also only terrains, because it was made with creating terrains in mind, but again it prevents it from being used for more generic use cases. Apart from that I doubt that most artists actually understand what transformations the Dimension input value undergoes before it finally influences the height of the noise layers but rather just tweak it until they get their wanted result. For that the Roughness input is far easier to use than the Dimension input, as it neither has inter-dependencies nor undergoes an exponentiation. I could easily add an checkbox, which turns the Roughness input to the Dimension input, but I deliberately decided against it because I don't want artists use an input which they don't really understand. If there turns out to really be demand for it I can still to it in a later PR. >Additionally, this is going to break forward compatibility which we try to avoid for minor releases like 4.1. It's possible to add some code compensating for that in 4.0 and 3.6, but it's extra code complexity. I'm aware that we try to keep forward compatibility for minor releases, which was why I tried to get it in 4.0. We also talked about that in the [Nodes & Physics module meeting](https://devtalk.blender.org/t/2023-10-03-nodes-physics-module-meeting/31538) and as far as I've understood the decision was that we'll take the hit and break forward compatibility for this.
Hoshinova added 2 commits 2023-10-13 13:39:09 +02:00
Hoshinova added 1 commit 2023-10-13 15:39:09 +02:00

And it removes over 2 thousand lines of code which in I'd consider a significant code simplification.

That's more than I thought. Maybe there is some way to do much of this simplification without breaking forward compatibility? Like can we keep the Musgrave Texture node on the user level (perhaps changed to Roughness), but have the implementation be shared? At least for Cycles and Eevee this seems possible.

The "additional" enum and 2 were already there, they've just been moved form the Musgrave to the Noise Texture.

Right, it's not more complex overall, my concern with the addition of these things is that they're rather specialized for a generic Noise Texture that is more of a building block.

While it's true that historically the Musgrave noise modes were created for modelling terrains that's also the case for the fBM mode. It was only when artists started using it for creating other things that it became generic.
That's also one of my goals for this PR. I don't see why the other Musgrave noise modes should be confined to just creating terrain.In my eyes they're just as usable as generic noise types however the Musgrave Texture node makes using it for anything other than creating terrains very challenging because the Dimension input really only works when creating terrains, which is why I replaced it by the more generic Roughness input.

I can imagine that noises like these are useful for use cases besides bump and displacement mapping. But at the moment only fBm has a Normalize option, which I think is important for it to be more generally useful, for use cases like blending weights.

Is there an interpretation of these other modes where they output values in the 0..1 range? You can of course compute min/max bounds somehow, but I'm wondering if they give a somewhat evenly distributed output in the 0..1 range then?

I understand that for artists used to the Dimension input it will take a little time to get used to the new Roughness input, however I believe without a doubt that the new Roughness input will be easier to use for them in the long term.

Right, I'm not concerned about this aspect, I agree Roughness is a better parameter.

I'm aware that we try to keep forward compatibility for minor releases, which was why I tried to get it in 4.0. We also talked about that in the Nodes & Physics module meeting and as far as I've understood the decision was that we'll take the hit and break forward compatibility for this.

I really think we should have some kind of forward compatibility, even if this landed in 4.0. Sometimes we have to break it for important reasons, but for me this is not a big enough benefit to justify it. Though removing 2k lines of code is tempting, but maybe most of that is possible without breakage.

> And it removes over 2 thousand lines of code which in I'd consider a significant code simplification. That's more than I thought. Maybe there is some way to do much of this simplification without breaking forward compatibility? Like can we keep the Musgrave Texture node on the user level (perhaps changed to Roughness), but have the implementation be shared? At least for Cycles and Eevee this seems possible. > The "additional" enum and 2 were already there, they've just been moved form the Musgrave to the Noise Texture. Right, it's not more complex overall, my concern with the addition of these things is that they're rather specialized for a generic Noise Texture that is more of a building block. > While it's true that historically the Musgrave noise modes were created for modelling terrains that's also the case for the fBM mode. It was only when artists started using it for creating other things that it became generic. > That's also one of my goals for this PR. I don't see why the other Musgrave noise modes should be confined to just creating terrain.In my eyes they're just as usable as generic noise types however the Musgrave Texture node makes using it for anything other than creating terrains very challenging because the Dimension input really only works when creating terrains, which is why I replaced it by the more generic Roughness input. I can imagine that noises like these are useful for use cases besides bump and displacement mapping. But at the moment only fBm has a Normalize option, which I think is important for it to be more generally useful, for use cases like blending weights. Is there an interpretation of these other modes where they output values in the 0..1 range? You can of course compute min/max bounds somehow, but I'm wondering if they give a somewhat evenly distributed output in the 0..1 range then? > I understand that for artists used to the Dimension input it will take a little time to get used to the new Roughness input, however I believe without a doubt that the new Roughness input will be easier to use for them in the long term. Right, I'm not concerned about this aspect, I agree Roughness is a better parameter. > I'm aware that we try to keep forward compatibility for minor releases, which was why I tried to get it in 4.0. We also talked about that in the [Nodes & Physics module meeting](https://devtalk.blender.org/t/2023-10-03-nodes-physics-module-meeting/31538) and as far as I've understood the decision was that we'll take the hit and break forward compatibility for this. I really think we should have some kind of forward compatibility, even if this landed in 4.0. Sometimes we have to break it for important reasons, but for me this is not a big enough benefit to justify it. Though removing 2k lines of code is tempting, but maybe most of that is possible without breakage.
Hoshinova added 1 commit 2023-10-13 17:50:37 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
2278e3b2da
Revert "-- Un-remove Musgrave Texture."
This reverts commit 27701ec116.
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Member

My current perspective here is that it's nice to remove unnecessarily duplicated code and to unify inputs to noise nodes where appropriate.

Beyond that, I'm more interested in a good Swap node operator so that switching between different noise types is a unified experience regardless of whether one is switching between noise, musgrave modes, voronoi modes, magic texture, etc.

I do agree that it is hard to justify breaking compatibility here.

My current perspective here is that it's nice to remove unnecessarily duplicated code and to unify inputs to noise nodes where appropriate. Beyond that, I'm more interested in a good [Swap node](https://projects.blender.org/blender/blender/issues/111438) operator so that switching between different noise types is a unified experience regardless of whether one is switching between noise, musgrave modes, voronoi modes, magic texture, etc. I do agree that it is hard to justify breaking compatibility here.
Author
Member

It really seems like forward compatibility is the main problem here. In that case I can add code to convert the Noise Texture back into the Musgrave Texture for the 3.6 and 4.0 versions.

It really seems like forward compatibility is the main problem here. In that case I can add code to convert the Noise Texture back into the Musgrave Texture for the 3.6 and 4.0 versions.

For me it's not just forward compatibility, I'm still not convinced that all these modes belong in a single node from a user point of view. I just don't see a compelling reason for it, and no good interpretation of these height fields into a 0..1 range.

Looking at the implementation more closely, it seems like a lot of the code simplification is through templating and macros, and a fair amount of versioning code is added. So probably we can still reduce the code by quite a lot even if we don't merge the nodes. In geometry nodes for example you could share a single class NoiseFunction : public mf::MultiFunction between the nodes.

I also checked if we really need all those distinct modes, if there is perhaps some way to turn some of those into float parameters for a more flexible combined mode. The differences are a lot smaller than you would expect, it's obscured by some loop unrolling and other reshuffling of the code for no good reason. But still not so easy. There are some arbitrary differences like Multifractal not being centered around zero like the other modes.

Based on this, I would not merge the nodes but rather just simplify the implementation.

For me it's not just forward compatibility, I'm still not convinced that all these modes belong in a single node from a user point of view. I just don't see a compelling reason for it, and no good interpretation of these height fields into a 0..1 range. Looking at the implementation more closely, it seems like a lot of the code simplification is through templating and macros, and a fair amount of versioning code is added. So probably we can still reduce the code by quite a lot even if we don't merge the nodes. In geometry nodes for example you could share a single `class NoiseFunction : public mf::MultiFunction` between the nodes. I also checked if we really need all those distinct modes, if there is perhaps some way to turn some of those into float parameters for a more flexible combined mode. The differences are a lot smaller than you would expect, it's obscured by some loop unrolling and other reshuffling of the code for no good reason. But still not so easy. There are some arbitrary differences like Multifractal not being centered around zero like the other modes. Based on this, I would not merge the nodes but rather just simplify the implementation.
Author
Member

For me it's not just forward compatibility, I'm still not convinced that all these modes belong in a single node from a user point of view. I just don't see a compelling reason for it, and no good interpretation of these height fields into a 0..1 range.

The only difference between the modes is that they call a different fractalization function, so I don't see why there should be multiple nodes for such a minor difference. I also don't see how that argument goes against merging the nodes. The modes already are in a single Musgrave Texture node so they would still be in a single node even if we don't merge them.

Looking at the implementation more closely, it seems like a lot of the code simplification is through templating and macros, and a fair amount of versioning code is added.

The versioning consists of 2 parts: Firstly it changes the Musgrave node Detail input to match the behavior of the Noise Texture, fixing a bug in the process. Secondly it converts the Dimension values to roughness values.
Even if we don't merge the nodes and rather only simplify the implementation it would still make sense to have these changes, so you'd need the versioning code either way.

I also checked if we really need all those distinct modes, if there is perhaps some way to turn some of those into float parameters for a more flexible combined mode. The differences are a lot smaller than you would expect, it's obscured by some loop unrolling and other reshuffling of the code for no good reason. But still not so easy. There are some arbitrary differences like Multifractal not being centered around zero like the other modes.

Perhaps we could combine some modes together. But I'm certain that it's not possible to combine them all together into a single general mode. So even if, let's say , we could combine all Multifractal modes together, you'd still have 3 distinct modes where the only difference is the fractalization function. Again, I don't see why there should be multiple nodes for such a minor difference they're all just some flavor of Perlin noise. If we have a look at the Voronoi Texture the differences are much greater yet it hasn't been split up either.

Based on this, I would not merge the nodes but rather just simplify the implementation.

Honestly, I don't see how simplifying the implementation would solve any of the problems you addressed above.

>For me it's not just forward compatibility, I'm still not convinced that all these modes belong in a single node from a user point of view. I just don't see a compelling reason for it, and no good interpretation of these height fields into a 0..1 range. The only difference between the modes is that they call a different fractalization function, so I don't see why there should be multiple nodes for such a minor difference. I also don't see how that argument goes against merging the nodes. The modes already are in a single Musgrave Texture node so they would still be in a single node even if we don't merge them. >Looking at the implementation more closely, it seems like a lot of the code simplification is through templating and macros, and a fair amount of versioning code is added. The versioning consists of 2 parts: Firstly it changes the Musgrave node Detail input to match the behavior of the Noise Texture, fixing a bug in the process. Secondly it converts the Dimension values to roughness values. Even if we don't merge the nodes and rather only simplify the implementation it would still make sense to have these changes, so you'd need the versioning code either way. >I also checked if we really need all those distinct modes, if there is perhaps some way to turn some of those into float parameters for a more flexible combined mode. The differences are a lot smaller than you would expect, it's obscured by some loop unrolling and other reshuffling of the code for no good reason. But still not so easy. There are some arbitrary differences like Multifractal not being centered around zero like the other modes. Perhaps we could combine some modes together. But I'm certain that it's not possible to combine them all together into a single general mode. So even if, let's say , we could combine all Multifractal modes together, you'd still have 3 distinct modes where the only difference is the fractalization function. Again, I don't see why there should be multiple nodes for such a minor difference they're all just some flavor of Perlin noise. If we have a look at the Voronoi Texture the differences are much greater yet it hasn't been split up either. > Based on this, I would not merge the nodes but rather just simplify the implementation. Honestly, I don't see how simplifying the implementation would solve any of the problems you addressed above.

The only difference between the modes is that they call a different fractalization function, so I don't see why there should be multiple nodes for such a minor difference. I also don't see how that argument goes against merging the nodes. The modes already are in a single Musgrave Texture node so they would still be in a single node even if we don't merge them.

I think there is a distinction between a node meant for height fields, centered around 0 without bounds. And a node for textures that produces normalized values in the 0..1 range. It might be a minor mathematical difference, but it's about purpose.

The versioning consists of 2 parts: Firstly it changes the Musgrave node Detail input to match the behavior of the Noise Texture, fixing a bug in the process. Secondly it converts the Dimension values to roughness values.
Even if we don't merge the nodes and rather only simplify the implementation it would still make sense to have these changes, so you'd need the versioning code either way.

I'm not sure it's worth breaking forward compatibility for that.

Honestly, I don't see how simplifying the implementation would solve any of the problems you addressed above.

I don't think there is a serious problem to be solved in the first place.

It's just nice if we can simplify the code and/or the user interface. So if there is no compelling reason to change the user interface and deal with the associated breakage, it would be nice to still simplify the code.

> The only difference between the modes is that they call a different fractalization function, so I don't see why there should be multiple nodes for such a minor difference. I also don't see how that argument goes against merging the nodes. The modes already are in a single Musgrave Texture node so they would still be in a single node even if we don't merge them. I think there is a distinction between a node meant for height fields, centered around 0 without bounds. And a node for textures that produces normalized values in the 0..1 range. It might be a minor mathematical difference, but it's about purpose. > The versioning consists of 2 parts: Firstly it changes the Musgrave node Detail input to match the behavior of the Noise Texture, fixing a bug in the process. Secondly it converts the Dimension values to roughness values. > Even if we don't merge the nodes and rather only simplify the implementation it would still make sense to have these changes, so you'd need the versioning code either way. I'm not sure it's worth breaking forward compatibility for that. > Honestly, I don't see how simplifying the implementation would solve any of the problems you addressed above. I don't think there is a serious problem to be solved in the first place. It's just nice if we can simplify the code and/or the user interface. So if there is no compelling reason to change the user interface and deal with the associated breakage, it would be nice to still simplify the code.
Author
Member

I think there is a distinction between a node meant for height fields, centered around 0 without bounds. And a node for textures that produces normalized values in the 0..1 range. It might be a minor mathematical difference, but it's about purpose.

When Normalize is turned off the current Noise node already produces values outside the 0.0 -1.0 range. The same holds true for the Voronoi Texture. I also don't understand why you think we should be confined to a 0.0 -1.0 range when creating textures. Sure the final texture should be in a 0.0 -1.0 range to keep energy preservation but it's very common to have values outside that range somewhere in the node tree.

I'm not sure it's worth breaking forward compatibility for that.

I add some versioning code to the 3.6-release and 4.0-release branches and voilà we have forward compatibility.

It's just nice if we can simplify the code and/or the user interface. So if there is no compelling reason to change the user interface and deal with the associated breakage, it would be nice to still simplify the code.

The Musgrave Texture has modes that the Noise Texture doesn't. Meanwhile the Noise Texture has a Distortion input and Color output which the Musgrave Texture doesn't. It's impossible to use both features simultaneously. So merging the nodes does effectively add features.

>I think there is a distinction between a node meant for height fields, centered around 0 without bounds. And a node for textures that produces normalized values in the 0..1 range. It might be a minor mathematical difference, but it's about purpose. When Normalize is turned off the current Noise node already produces values outside the 0.0 -1.0 range. The same holds true for the Voronoi Texture. I also don't understand why you think we should be confined to a 0.0 -1.0 range when creating textures. Sure the final texture should be in a 0.0 -1.0 range to keep energy preservation but it's very common to have values outside that range somewhere in the node tree. >I'm not sure it's worth breaking forward compatibility for that. I add some versioning code to the 3.6-release and 4.0-release branches and voilà we have forward compatibility. >It's just nice if we can simplify the code and/or the user interface. So if there is no compelling reason to change the user interface and deal with the associated breakage, it would be nice to still simplify the code. The Musgrave Texture has modes that the Noise Texture doesn't. Meanwhile the Noise Texture has a Distortion input and Color output which the Musgrave Texture doesn't. It's impossible to use both features simultaneously. So merging the nodes **does** effectively add features.
Author
Member

@brecht Looks like the artists on https://devtalk.blender.org/t/merging-the-musgrave-texture-and-noise-texture-nodes/30646 are happy now after resolving some communication mistakes.

There are even already example images of the new features I mentioned: https://devtalk.blender.org/t/merging-the-musgrave-texture-and-noise-texture-nodes/30646/67?u=hoshinova

@brecht Looks like the artists on https://devtalk.blender.org/t/merging-the-musgrave-texture-and-noise-texture-nodes/30646 are happy now after resolving some communication mistakes. There are even already example images of the new features I mentioned: https://devtalk.blender.org/t/merging-the-musgrave-texture-and-noise-texture-nodes/30646/67?u=hoshinova
Hoshinova added 2 commits 2023-10-20 19:37:59 +02:00
Hoshinova added 1 commit 2023-10-20 19:40:03 +02:00
buildbot/vexp-code-patch-coordinator Build done. Details
05ff4ce98b
Merge branch 'main' into merge-noise-nodes2

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova added 1 commit 2023-10-20 19:57:46 +02:00

Ok, let's do it then. Python API breaking changes are inevitable. But I guess along with Gabor noise this will be a nice improvement to texturing, and there are various other breaking changes in 4.1 as well.

If it's possible to have versioning code for 4.0 by next week Wednesday, that would be great so we can add it in time for 4.0.0.

Ok, let's do it then. Python API breaking changes are inevitable. But I guess along with Gabor noise this will be a nice improvement to texturing, and there are various other breaking changes in 4.1 as well. If it's possible to have versioning code for 4.0 by next week Wednesday, that would be great so we can add it in time for 4.0.0.
Author
Member

@brecht

If it's possible to have versioning code for 4.0 by next week Wednesday, that would be great so we can add it in time for 4.0.0.

I'm very busy right now but I'll try my best. For the 4.0 versioning I just work on the blender-v.4.0-release branch right?

As for the new features which don't exist in 4.0, like the Distortion input and Color output for the Musgrave modes, should I make the versioning code add nodes that emulate the behavior or should I just ignore these inputs/outputs?

@brecht > If it's possible to have versioning code for 4.0 by next week Wednesday, that would be great so we can add it in time for 4.0.0. I'm very busy right now but I'll try my best. For the 4.0 versioning I just work on the `blender-v.4.0-release` branch right? As for the new features which don't exist in 4.0, like the Distortion input and Color output for the Musgrave modes, should I make the versioning code add nodes that emulate the behavior or should I just ignore these inputs/outputs?

I'm very busy right now but I'll try my best.

Thanks!

For the 4.0 versioning I just work on the blender-v.4.0-release branch right?

Yes.

As for the new features which don't exist in 4.0, like the Distortion input and Color output for the Musgrave modes, should I make the versioning code add nodes that emulate the behavior or should I just ignore these inputs/outputs?

You can ignore those.

> I'm very busy right now but I'll try my best. Thanks! > For the 4.0 versioning I just work on the `blender-v.4.0-release` branch right? Yes. > As for the new features which don't exist in 4.0, like the Distortion input and Color output for the Musgrave modes, should I make the versioning code add nodes that emulate the behavior or should I just ignore these inputs/outputs? You can ignore those.
Hoshinova reviewed 2023-10-27 21:44:54 +02:00
Hoshinova left a comment
Author
Member
@brecht
@ -1272,3 +1272,4 @@
NodeTexBase base;
int dimensions;
uint8_t type;
uint8_t normalize;
Author
Member

Will Blender 4.1 read uint8_t normalize correctly? Because the memory space that used to be for uint8_t normalize in 4.0 is now used for uint8_t type.

Will Blender 4.1 interpret uint8_t normalize as uint8_t type?

Will Blender 4.1 read `uint8_t normalize` correctly? Because the memory space that used to be for `uint8_t normalize` in 4.0 is now used for `uint8_t type`. Will Blender 4.1 interpret `uint8_t normalize` as `uint8_t type`?
Hoshinova added 1 commit 2023-10-29 00:40:28 +02:00
Hoshinova added 1 commit 2023-10-29 00:42:45 +02:00
Hoshinova added 2 commits 2023-10-30 22:34:54 +01:00
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Omar Emara requested changes 2023-11-06 12:15:16 +01:00
@ -20,3 +8,1 @@
maxamp += amp;
amp *= clamp(roughness, 0.0, 1.0);
fscale *= lacunarity;
#define NOISE_FBM(T) \
Member

Judging by ea2746d468. It seems we can't use such a macro.
Unroll and add a TODO comment like Jeroen did. Same goes for the glsl file below, since using a macro for the body also didn't work.

Judging by ea2746d46844bf8132028c017f23a70c4bb689bd. It seems we can't use such a macro. Unroll and add a TODO comment like Jeroen did. Same goes for the glsl file below, since using a macro for the body also didn't work.
Author
Member

@OmarEmaraDev Not necessarily. In case of ea2746d468 it was only FRACTAL_VORONOI_X_FX(T) that was failing, while FRACTAL_VORONOI_DISTANCE_TO_EDGE_FUNCTION(T) works correctly and is still a macro in main. I suggest someone who has access to a legacy Intel platform test it and we only unroll the functions that are failing, if any.

@Jeroen-Bakker Could you do some testing?

@OmarEmaraDev Not necessarily. In case of https://projects.blender.org/blender/blender/commit/ea2746d46844bf8132028c017f23a70c4bb689bd it was only `FRACTAL_VORONOI_X_FX(T)` that was failing, while `FRACTAL_VORONOI_DISTANCE_TO_EDGE_FUNCTION(T)` works correctly and is still a macro in `main`. I suggest someone who has access to a legacy Intel platform test it and we only unroll the functions that are failing, if any. @Jeroen-Bakker Could you do some testing?
Member

Macro unrolling might fail on specific laptops where user can only use the driver from the laptop manufacturer. I don't have access to such a laptop so I am not able to test.

I would just continue with the macros and if there are issues we should manually unroll them, until we do our own GLSL compilation or transit to vulkan.

Macro unrolling might fail on specific laptops where user can only use the driver from the laptop manufacturer. I don't have access to such a laptop so I am not able to test. I would just continue with the macros and if there are issues we should manually unroll them, until we do our own GLSL compilation or transit to vulkan.
OmarEmaraDev marked this conversation as resolved
Hoshinova added 2 commits 2023-11-06 23:04:05 +01:00
Omar Emara approved these changes 2023-11-07 12:20:35 +01:00
Brecht Van Lommel approved these changes 2023-11-08 18:58:51 +01:00
Hoshinova added 1 commit 2023-11-08 22:02:51 +01:00
buildbot/vexp-code-patch-coordinator Build done. Details
78eb6d9861
-- Also clamp when detail input isn't connected.
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Hoshinova added 1 commit 2023-11-09 20:31:08 +01:00
buildbot/vexp-code-patch-coordinator Build done. Details
ae18397c4d
Merge branch 'main' into merge-noise-nodes2
Member

@blender-bot package

@blender-bot package
Member

Package build started. Download here when ready.

Package build started. [Download here](https://builder.blender.org/download/patch/PR111187) when ready.
Jacques Lucke approved these changes 2023-11-13 14:24:55 +01:00
Hoshinova added 1 commit 2023-11-17 22:12:54 +01:00
Omar Emara merged commit 0b11c591ec into main 2023-11-18 09:40:52 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
13 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#111187
No description provided.