# SDF of cylinder slice

Hi,
I have been playing with the SDF nodes from FieldTrip, and have been quite happy. But now, I want to add a “wedge” primitive, but can’t quite figure out how to program it.
So, basically what I want is a primitive that looks like one of those Trivial Pursuit pieces - here, the red, yellow and blue:

So, what I would like is something similar to the Segment (DX11.Geometry) node, but that returns
SDF2D that I can then extrude, with inner radius, cycles and phase inputs. I need help writing the shader code!

1 Like

Maybe search for cylinder sector or circular sector.

Yeah… I understand the basic math/geometry that describes a sector of a circle.
Basically, this is what I have now:

So, the “Inner Radius” part can be handled by CombineSDF boolean operations. However, I’m not smart enough to translate my understanding of a sector into the SDF function of a wedge!
The shader code for a cylinder is:

``````float fCylinder(float3 p, float r, float height)
{
float d = length(p.xz) - r;
d = max(d, abs(p.y) - height);
return d;
}
``````

I just can’t quite see how to change that so that it’s correct for a partial cylinder, ie. a wedge shape…?

i assume you’ve been here, i guess you can extrude that Shader - Shadertoy BETA