making cut faces visible

hello everyone,

my task is it to render the cut faces of the intersection of two objects.

the first object is a given, rather complex cad model and from this model i want to cut out a cuboid.

i have accomplished to cut out everything from the model, that lies in the cuboid, with a simple fragment-shader. but now i am looking at the backside of the cad model. (if the cuboid is not completely in the model).

so is there a way to draw the cut faces? (without geometry shaders)

I am thankful for any kind of help.

yea, the traditional way is to use the stencil buffer.
when you render your object you make sure that frontfaces set the stencil to 0 and back faces set it to 1.
Once that is completed you will have a stencil cutout in witch you then render the inside of the cuboid with the faces reversed, that would be your cut faces, add a little “cut metal painted red” texture to it and your good to go.