Page MenuHome

Shading: Add color output option to White Noise node.
ClosedPublic

Authored by Charlie Jolly (charlie) on Jan 25 2020, 3:26 PM.

Diff Detail

Repository
rB Blender

Event Timeline

Virtually all texture nodes have a 'Fac' and 'Color' socket simultaneously exposed , is there a compelling reason to control it with a drop down here?

It was done this way as an optimisation so that the color hash is only computed if it is needed.

I've checked the other textures and there is a variety of things going on. Voronoi color is cell color. Gradient and Wave just copy fac to color so it is grey. Magic averages the color. Noise seems to be optimised for Cycles but not for GLSL or Eevee. Checker and Brick manipulate the fac to add colors. Musgrave doesn't have a color output.

Some possible choices:

  1. Leave as it is. Let the user decide what hash output they want.
  2. Display both sockets. For color mode we could average the colour into the value socket like magic texture does. For value mode we could just covert the color socket to grey like the Gradient and Wave nodes.
  3. Display and calculate both sockets. Remove option.

Notice that OSL and GLSL optimize this on their own. If the color output is not used, it will not be computed. This is not the case for SVM, so we have to add the optimization manually.

Consistency across the nodes available is more important than anything and should be the number one design rule for any UI, having inconsistent UI for the sake of micro optimizations is not the way to go imho, when in doubt consult the UI team cc: @William Reynish (billreynish)

In the past some optimizations were done by checking if the node was connected at-least in SVM if the other codepaths (glsl, osl) never had these optimizations there is no need to break with that now.

I'll leave the final decision up to brecht (don't change anything until he has given feedback) as he is the architect here but i suggest for this diff:

  1. Display both outputs, remove the drop down.
  2. Optimize SVM only calculate what is needed
  3. Leave OSL/GLSL unoptimized
  4. Handle optimization of all nodes that need it in glsl/svm in a different diff, keeping in mind that changing the UI for the sake of optimization can perhaps be done (given you have compelling benchmark numbers to justify it and a good reason why it can't be done keeping the current UI) but has to be done across all nodes, consistency is key

4 can perhaps also be an idea for GSOC ? (part of, I don't think there is enough substance for a complete GSOC project there)

Notice that OSL and GLSL optimize this on their own. If the color output is not used, it will not be computed. This is not the case for SVM, so we have to add the optimization manually.

@Omar Emara (OmarSquircleArt) That's useful to know, is this performed by the compiler?

@Ray molenkamp (LazyDodo) I'll wait for further feedback before making any changes.

Thanks both.

I don't know the technical details behind those kind of optimizations, unfortunately. I just know they happen. 😄

Brecht Van Lommel (brecht) requested changes to this revision.EditedJan 27 2020, 3:30 PM

Always show both outputs rather than using a mode switch.

For SVM you can use stack_valid() to skip computation when it's not needed, see for example svm_gradient.h.

This revision now requires changes to proceed.Jan 27 2020, 3:30 PM
Charlie Jolly (charlie) updated this revision to Diff 21166.EditedJan 27 2020, 4:08 PM

Remove mode switch and provide both outputs.

This revision is now accepted and ready to land.Jan 27 2020, 4:43 PM