Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Moniewski <monio>2020-02-17 14:31:38 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-02-17 15:24:07 +0300
commit67d12bb5192d04a596e216f63cff2875fdd8cfbf (patch)
treec4d866f343ec9b87f713ebd004a8f343ab6f5307 /source/blender/blenloader/intern/versioning_cycles.c
parentae9bbb4d0360aea694b46ee698d24dbc1476ebf3 (diff)
Shading: add direction modes and phase offset to wave texture node
* Direction mode X, Y and Z to align with axes rather than diagonal or spherical as previously. X is the new default, existing files will use diagonal or spherical for compatibility. * Phase offset to offset the wave along its direction, for purposes like animation and distortion. https://developer.blender.org/D6382
Diffstat (limited to 'source/blender/blenloader/intern/versioning_cycles.c')
-rw-r--r--source/blender/blenloader/intern/versioning_cycles.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c
index 466dd02b3b3..77167d887cf 100644
--- a/source/blender/blenloader/intern/versioning_cycles.c
+++ b/source/blender/blenloader/intern/versioning_cycles.c
@@ -1250,6 +1250,31 @@ static void update_noise_and_wave_distortion(bNodeTree *ntree)
}
}
+/* Wave Texture node: Restore previous texture directions and offset.
+ * 1. In 2.81, Wave texture had fixed diagonal direction (Bands) or
+ * mapping along distance (Rings). Now, directions are customizable
+ * properties, with X axis being new default. To fix this we set new
+ * direction options to Diagonal and Spherical.
+ * 2. Sine profile is now negatively offseted by PI/2 to better match
+ * other profiles. To fix this we set new Phase Offset input to PI/2
+ * in nodes with Sine profile.
+ */
+static void update_wave_node_directions_and_offset(bNodeTree *ntree)
+{
+ for (bNode *node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == SH_NODE_TEX_WAVE) {
+ NodeTexWave *tex = (NodeTexWave *)node->storage;
+ tex->bands_direction = SHD_WAVE_BANDS_DIRECTION_DIAGONAL;
+ tex->rings_direction = SHD_WAVE_RINGS_DIRECTION_SPHERICAL;
+
+ if (tex->wave_profile == SHD_WAVE_PROFILE_SIN) {
+ bNodeSocket *sockPhaseOffset = nodeFindSocket(node, SOCK_IN, "Phase Offset");
+ *cycles_node_socket_float_value(sockPhaseOffset) = M_PI_2;
+ }
+ }
+ }
+}
+
void blo_do_versions_cycles(FileData *UNUSED(fd), Library *UNUSED(lib), Main *bmain)
{
/* Particle shape shared with Eevee. */
@@ -1489,4 +1514,13 @@ void do_versions_after_linking_cycles(Main *bmain)
}
FOREACH_NODETREE_END;
}
+
+ if (!MAIN_VERSION_ATLEAST(bmain, 283, 4)) {
+ FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
+ if (ntree->type == NTREE_SHADER) {
+ update_wave_node_directions_and_offset(ntree);
+ }
+ }
+ FOREACH_NODETREE_END;
+ }
}