Tesan Srdjan

cncverkstad

About Me

Hobbyist
専門知識
Freelancer

Connect

LOCATION
Göteborg, Sweden
ウェブサイト

Houdini Engine

ADVANCED
プロシージャルワークフロー

Availability

I am available for Full Time Work

Recent Forum Posts

Transform any Mesh to complex Lego Geometry (Examples inkl.) 2024年10月5日4:40

Play with this .
Use first file of Konstantin, delete Wrangle normal's dont need to use transform with pscale also, use this Vex Code and make shapes that you like using merged-packed with names that you make before with nulls.
// Get gradient information
vector grad = normalize(v@grad);

// Gradient magnitude for overall control
float grad_magnitude = length(grad);

// User-defined ramps for controlling influence on X, Y, and Z
float x_influence = chramp("x_influence_ramp", abs(grad.x));
float y_influence = chramp("y_influence_ramp", abs(grad.y));
float z_influence = chramp("z_influence_ramp", abs(grad.z));

// Adjust thresholds for brick assignment
float grad_threshold_x = chf("grad_threshold_x");
float grad_threshold_y = chf("grad_threshold_y");
float grad_threshold_z = chf("grad_threshold_z");

// Introduce noise-based perturbation for variety
float noise_val = snoise(@P * chf("noise_frequency")) * chf("noise_amplitude");
grad += noise_val;  // Perturb the gradient to add variation

// Calculate blend factors with ramp-based influence
float blend_factor_x = (abs(grad.x) / grad_threshold_x) * x_influence;
float blend_factor_y = (abs(grad.y) / grad_threshold_y) * y_influence;
float blend_factor_z = (abs(grad.z) / grad_threshold_z) * z_influence;

// Clamp the blend factors to the range [0, 1]
blend_factor_x = clamp(blend_factor_x, 0.0, 1.0);
blend_factor_y = clamp(blend_factor_y, 0.0, 1.0);
blend_factor_z = clamp(blend_factor_z, 0.0, 1.0);

// Add more slope types based on gradient direction and strength
if (grad_magnitude > grad_threshold_y) {
    if (blend_factor_x > blend_factor_z) {
        // X-influenced slopes
        if (blend_factor_x > 0.9) {
            s@variant = "3x4-steep-slope";
        } else if (blend_factor_x > 0.7) {
            s@variant = "2x6-slope";
        } else if (blend_factor_x > 0.5) {
            s@variant = "2x4-slope";
        } else {
            s@variant = "2x4";
        }
        @N = normalize(set(grad.x, 0, 0));
    } else {
        // Z-influenced slopes
        if (blend_factor_z > 0.9) {
            s@variant = "3x3-steep-slope";
        } else if (blend_factor_z > 0.7) {
            s@variant = "1x3-slope";
        } else if (blend_factor_z > 0.5) {
            s@variant = "1x2-slope";
        } else {
            s@variant = "1x2";
        }
        @N = normalize(set(0, 0, grad.z));
    }
} else {
    // Y-influenced flat or gentle slopes
    if (blend_factor_y > 0.8) {
        s@variant = "1x2-flat";
    } else if (blend_factor_y > 0.6) {
        s@variant = "1x1-slope-gentle";
    } else if (blend_factor_y > 0.4) {
        s@variant = "1x1-slope";
    } else {
        s@variant = "1x1";
    }
}

// Apply orientation variation based on noise and ramps
float rotation_offset = chramp("rotation_offset_ramp", noise_val);
vector axis = normalize(v@up);  // Rotation axis remains up
@N = qrotate(quaternion(rotation_offset, axis), @N);

// Set up vector
v@up = {0, 1, 0};

// Brick placement refinement based on grid
float grid_size_x = chf("grid_size_x");
float grid_size_z = chf("grid_size_z");

// Snap the points to the grid to avoid overlap
@P.x = floor(@P.x / grid_size_x) * grid_size_x;
@P.z = floor(@P.z / grid_size_z) * grid_size_z;

// More complex pscale logic
float base_pscale = chf("base_pscale");

// Adjust pscale based on shape type (for larger bricks that cover more points)
int num_points_covered;
if (s@variant == "3x4-steep-slope" || s@variant == "2x6-slope") {
    num_points_covered = 12;
} else if (s@variant == "2x4-slope" || s@variant == "2x4") {
    num_points_covered = 8;
} else if (s@variant == "1x3-slope" || s@variant == "1x3") {
    num_points_covered = 3;
} else if (s@variant == "1x2-slope" || s@variant == "1x2") {
    num_points_covered = 2;
} else {
    num_points_covered = 1;  // Default for smaller bricks
}

// Adjust pscale based on the number of points the shape occupies
@pscale = base_pscale * float(num_points_covered) / 16.0;  // Normalize to 16-point base size

// Gradient-based scaling: stronger gradients in X, Y, or Z increase scale
float pscale_x = chramp("pscale_x_ramp", abs(grad.x)) * x_influence * base_pscale;
float pscale_y = chramp("pscale_y_ramp", abs(grad.y)) * y_influence * base_pscale;
float pscale_z = chramp("pscale_z_ramp", abs(grad.z)) * z_influence * base_pscale;

// Noise-based scaling variation: adds randomness to the scale
float noise_scale = snoise(@P * chf("pscale_noise_freq")) * chf("pscale_noise_amp");

// Combine noise with gradient scaling for final pscale
@pscale += noise_scale + (pscale_x + pscale_y + pscale_z) / 3.0;

// Ensure pscale stays within a valid range
@pscale = clamp(@pscale, chf("min_pscale"), chf("max_pscale"));

Hard edges to edge group? 2024年10月5日3:52

Play with this.
//#include <hedgedeep.vfl>

int hedge_nextequiv = hedge_nextequiv(0, @elemnum);
if ( chi("../includeunshared") ) {
    if ( @elemnum < hedge_nextequiv || hedge_nextequiv == -1 ) return;//includeunshared
} else {
    if ( @elemnum <= hedge_nextequiv || hedge_nextequiv == -1 ) return;//excludeunshared
}

// int hedge_dstpoint = vertexpoint(0, hedge_nextequiv);
int hedge_dstpoint = hedge_dstpoint(0, @vtxnum);
// printf('\n%d', hedge_srcpoint);

// if ( hedge_dstpoint != 57 ) return;
// printf('\n%d', @ptnum);

string edgeGrps[] = split(chs("../edgeGroup"));
foreach(string edgeGrp; edgeGrps) {
    if ( !inedgegroup(0, edgeGrp, @ptnum, hedge_dstpoint) ) return;
}

vector posdst = point(0, 'P', hedge_dstpoint);

vector dir = normalize(posdst - v@P);

float dot = dot(dir, normalize(chv('../dir')));
dot = chi("../bidir") ? abs(dot) : dot;
i@outgrp = ( dot > chf('../threshold') ) ^ chi("../reverseGroup");

Camera boom swing and track - geometry constaints or kinefx 2024年10月3日1:11

play with this