A comparatively simple closed-form analytic expression for the gravity field of a polyhedron with linearly varying density is derived. The algorithm forms the basis for a complete gravity modeling system that is well adapted to complex sedimentary situations where compaction plays an important role. The models will provide good compatibility with seismic modeling systems by eliminating artificial reflections at internal interfaces within bodies.