Page MenuHome

Shading: Wave texture node. Direction modes and Phase Offset input.

Authored by Bartosz Moniewski (monio) on Dec 9 2019, 11:54 PM.
"Like" token, awarded by hitrpr."Yellow Medal" token, awarded by gabrielmoro."Like" token, awarded by Fracture128."Love" token, awarded by mistajuliax."Love" token, awarded by ace_dragon."Love" token, awarded by pablovazquez."Love" token, awarded by Shimoon."Love" token, awarded by LordoftheFleas."Love" token, awarded by VaguelyButter."Love" token, awarded by TheAngerSpecialist."Love" token, awarded by BennyG."Love" token, awarded by duarteframos."Like" token, awarded by NahojshiART."Love" token, awarded by threedslider."Love" token, awarded by jubi."Love" token, awarded by cheteron."Love" token, awarded by navett52."Like" token, awarded by AnadinX."Love" token, awarded by valera."Love" token, awarded by wilBr."Burninate" token, awarded by guitargeek."Love" token, awarded by Lexply."Love" token, awarded by devanshutak25."Love" token, awarded by charlie."Love" token, awarded by Linkun."Love" token, awarded by BartShoot."Love" token, awarded by enenra."Love" token, awarded by ChrisGraz."Love" token, awarded by mfink."Like" token, awarded by fin.eskimo."Like" token, awarded by mantissa."Love" token, awarded by brilliant_ape."Burninate" token, awarded by digim0nk."Like" token, awarded by Samirosman."Like" token, awarded by MetinSeven."Like" token, awarded by MrJomo."Burninate" token, awarded by Taros."Love" token, awarded by domant2."Love" token, awarded by Mizukuroi."Like" token, awarded by EAW."Love" token, awarded by belich."Like" token, awarded by manitwo."Love" token, awarded by Bariboy.



Wave texture diagonal direction is not practical.
Internet is filled with questions and discussions how to align Wave texture to an axis. Users often adds Mapping node and counter-rotate input vector to achieve this. Obviously this is unintuitive, inconvenient and have some performance impact.
In case of Rings type users sometimes zero-out one coordinate component with Separate/Combine nodes. This way texture aligns to an axis but it also makes pattern effectively 2D.

Make texture align to an axis by default. Allow users to choose different axes, including old diagonal one.

This patch adds easy to use direction modes.
Bands and Rings types work differently and need separate properties - Bands Direction and Rings Direction.

  • In Bands type we align wave across X, Y, Z or Diagonal axis. This use respective coordinate component or adds them together for diagonal direction as previously.
  • In Rings type we align wave along X, Y, Z axes or Spherical distance. This works by making corresponding coordinate components infinite, before evaluating vector length and adding 3D noise. Spherical option computes length on original vector like before.
  • Both properties are set to X by default. Old materials are handled in versioning code.

My patch also adds Phase Offset input. As name suggest it offsets wave pattern along it's direction. This feature can be used for:

  • Animation.
  • Randomization.
  • Additional distortion, possibly with texture of different properties than built-in noise.
  • Adding knots to wood materials, that often base upon this node.

Test-build for users can be downloaded here:

Diff Detail

Event Timeline

Is there a reason for Diagonal direction besides compatibility with old files?

Is there a reason for Diagonal direction besides compatibility with old files?

Main reason to keep it was compatibility but diagonal direction is still useful for some textile patterns, marble tiles and other materials.

Brecht Van Lommel (brecht) requested changes to this revision.Dec 10 2019, 8:08 PM

Overall seems reasonable.

Similar to the checker textures, these kinds of axis aligned patterns are going to cause precision issue when they align with planes at integer coordinates.

There is no perfect solution for that, but I think we should use the same trick here to nudge the input coordinates a little bit. This is from the GLSL checker texture, similar code exists for OSL and SVM.

/* Prevent precision issues on unit coordinates. */
p = (p + 0.000001) * 0.999999;

) -> ). Please run clang-format.



This revision now requires changes to proceed.Dec 10 2019, 8:08 PM
Bartosz Moniewski (monio) updated this revision to Diff 20287.EditedDec 15 2019, 3:26 AM
  • Added coordinates bias to prevent precision issues on unit coordinates.
  • Added Triangle profile.
  • Offset Sine wave to match other profiles periods. Added versioning code to offset it back, using new Phase Offset input.
  • Changed Saw profile code to match implementations of Fractional function. Works identical, more readable code.
  • Addressed comments.

I've added Triangle profile. We had this in Blender Internal's Wood and Marble textures. @Charlie Jolly (charlie) and some users suggested bringing it back. It makes sense because while it's visually similar to Sine profile it works completely different with bump and displacement.

I realized we could synchronize wave periods of all profiles for easier usage. Offsetting Sine instead of Saw and Triangle makes more sense imho.

Bartosz Moniewski (monio) marked 2 inline comments as done.
  • Fix: use sinf() instead of sin() in svm_wave.h
This revision is now accepted and ready to land.Fri, Feb 14, 6:32 PM