One of the key advancements in Grasshopper 2 is the introduction of new high-level types: Function, Distribution, Gradient, and Field. These types increase the level of abstraction and enable more declarative definitions. (declarative vs imperative)
Focusing on Field, Grasshopper 2 provides various Field creation components, all inheriting from the Field abstract class. In its most minimal form, a Field follows this structure:
public abstract class Field
{
public abstract FieldType Type { get; }
public abstract string Name { get; }
public abstract double ScalarAt(Point3d point);
public abstract Vector3d VectorAt(Point3d point);
}
Every Field is required to implement ScalarAt or VectorAt (or both), defining how it evaluates scalar or vector values at any given point in space.
By default, creating a custom Field requires coding, which can be limiting. To address this, I developed the Field Start and Field End components.
CustomFields.ghz (270.5 KB)
Here, I created two simple fields inspired by Isopod’s Sphere and Curve Pipe SDF. Notice how these custom fields can seamlessly integrate and interact with other fields.
With this setup, users can add desired inputs and define how scalar or vector values are computed using simple Grasshopper components. The Field End component then creates a new Field type that inherits from the Field abstract class, allowing it to function like any other built-in Field in Grasshopper 2.
I’d love to hear @DavidRutten 's take on how this fits into Grasshopper 2 and @DanielPiker’s thoughts on its potential for implicit surface modeling.
You can download Kampecaris from here.
P.S. This is just a proof of concept, and currently, it is significantly slower than creating fields through coding.