forked from blender/blender
Code improvements + Mix node #30
@ -160,7 +160,7 @@ class BrickFunction : public mf::MultiFunction {
|
|||||||
return (3.0f * ff - 2.0f * ff * f);
|
return (3.0f * ff - 2.0f * ff * f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static float2 brick(float3 pos,
|
static float2 brick(float3 p,
|
||||||
float mortar_size,
|
float mortar_size,
|
||||||
float mortar_smooth,
|
float mortar_smooth,
|
||||||
float bias,
|
float bias,
|
||||||
@ -173,17 +173,17 @@ class BrickFunction : public mf::MultiFunction {
|
|||||||
{
|
{
|
||||||
float offset = 0.0f;
|
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) {
|
if (offset_frequency && squash_frequency) {
|
||||||
brick_width *= (rownum % squash_frequency) ? 1.0f : squash_amount;
|
brick_width *= (rownum % squash_frequency) ? 1.0f : squash_amount;
|
||||||
offset = (rownum % offset_frequency) ? 0.0f : (brick_width * offset_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 x = (p.x + offset) - brick_width * bricknum;
|
||||||
const float y = pos.y - row_height * rownum;
|
const float y = p.y - row_height * rownum;
|
||||||
|
|
||||||
const float tint = clamp_f(
|
const float tint = clamp_f(
|
||||||
brick_noise((rownum << 16) + (bricknum & 0xFFFF)) + bias, 0.0f, 1.0f);
|
brick_noise((rownum << 16) + (bricknum & 0xFFFF)) + bias, 0.0f, 1.0f);
|
||||||
|
@ -80,11 +80,11 @@ class NodeTexChecker : public mf::MultiFunction {
|
|||||||
|
|
||||||
mask.foreach_index([&](const int64_t i) {
|
mask.foreach_index([&](const int64_t i) {
|
||||||
/* Avoid precision issues on unit coordinates. */
|
/* 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 xi = abs(int(floorf(p.x)));
|
||||||
const int yi = abs(int(floorf(pos.y)));
|
const int yi = abs(int(floorf(p.y)));
|
||||||
const int zi = abs(int(floorf(pos.z)));
|
const int zi = abs(int(floorf(p.z)));
|
||||||
|
|
||||||
r_fac[i] = ((xi % 2 == yi % 2) == (zi % 2)) ? 1.0f : 0.0f;
|
r_fac[i] = ((xi % 2 == yi % 2) == (zi % 2)) ? 1.0f : 0.0f;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user