Code improvements + Mix node #30

Merged
Bogdan Nagirniak merged 18 commits from BogdanNagirniak/blender:matx-code-improvements into matx-export-material 2023-09-22 18:23:13 +02:00
3 changed files with 10 additions and 10 deletions
Showing only changes of commit 8ab7eb8f24 - Show all commits

View File

@ -160,7 +160,7 @@ class BrickFunction : public mf::MultiFunction {
return (3.0f * ff - 2.0f * ff * f);
}
static float2 brick(float3 pos,
static float2 brick(float3 p,
float mortar_size,
float mortar_smooth,
float bias,
@ -173,17 +173,17 @@ class BrickFunction : public mf::MultiFunction {
{
float offset = 0.0f;
const int rownum = int(floorf(pos.y / row_height));
const int rownum = int(floorf(p.y / row_height));
if (offset_frequency && squash_frequency) {
brick_width *= (rownum % squash_frequency) ? 1.0f : squash_amount;
offset = (rownum % offset_frequency) ? 0.0f : (brick_width * offset_amount);
}
const int bricknum = int(floorf((pos.x + offset) / brick_width));
const int bricknum = int(floorf((p.x + offset) / brick_width));
const float x = (pos.x + offset) - brick_width * bricknum;
const float y = pos.y - row_height * rownum;
const float x = (p.x + offset) - brick_width * bricknum;
const float y = p.y - row_height * rownum;
const float tint = clamp_f(
brick_noise((rownum << 16) + (bricknum & 0xFFFF)) + bias, 0.0f, 1.0f);

View File

@ -80,11 +80,11 @@ class NodeTexChecker : public mf::MultiFunction {
mask.foreach_index([&](const int64_t i) {
/* Avoid precision issues on unit coordinates. */
const float3 pos = (vector[i] * scale[i] + 0.000001f) * 0.999999f;
const float3 p = (vector[i] * scale[i] + 0.000001f) * 0.999999f;
const int xi = abs(int(floorf(pos.x)));
const int yi = abs(int(floorf(pos.y)));
const int zi = abs(int(floorf(pos.z)));
const int xi = abs(int(floorf(p.x)));
const int yi = abs(int(floorf(p.y)));
const int zi = abs(int(floorf(p.z)));
r_fac[i] = ((xi % 2 == yi % 2) == (zi % 2)) ? 1.0f : 0.0f;
});