mkeeter / antimony

CAD from a parallel universe
2.09k stars 159 forks source link

help on blend node #192

Open Cdriko opened 6 years ago

Cdriko commented 6 years ago

hello I try to use the blend node, to get the same result than this with shape.js

but it seems to do anything totaly different. I'm right ?

wich parameter can I set to get the same result?

mkeeter commented 6 years ago

Can you share your Antimony code?

Cdriko commented 6 years ago

I would like to reproduce the blending function used by shapejs

the source is here

in /MathUtil.java line 1668

blendMin and Max

The result is the rounding of edges, wich its nicer and easyer to print.

not a morph kind like I see in antimony gyro.Variable1.zip

Cdriko commented 6 years ago

sorry it's line 1728 : public static final double blendQuadric

Cdriko commented 6 years ago

I've tried to transpose the GLSL code, but I don't no exactly what put in the "output" function (follow doesn't work)

import fab

title('BlendQ')
input('a', fab.types.Shape)
input('b', fab.types.Shape)
input('q', float)

def blendQuadratic(x):
    return (1.0-x)*(1.0-x)*0.25

def blendMax(a,b,w):
    dd=max(a,b)
    if (w<=0.0):
        return dd
    d=abs(a-b)
    if(d<w):
        return dd+w*blendQuadratic(d/w)
    else:
        return dd

output('shape', 0.5*blendMax(a,b,q))
Cdriko commented 6 years ago

in fact, I want to create the blend function defined in libfive examples :

(define (blend a b m)
  (min a b (+ (sqrt (abs a))
              (sqrt (abs b))
              (- m)) ))

(the result is rounding joint edges) but I fail to write it in correct F-rep syntax