Procedural modeling of three-dimensional shapes plays a significant role in many areas nowadays. Methods based on the automation of the modeling process offer a variety of three-dimensional structures, saving time and money. Geometry synthesis is currently used in many fields including digital cinema, electronic entertainment and simulation. There is a need to replace designers' work with intelligent automated algorithms, especially in the case of terrain modeling. This article addresses the problem of modeling virtual caves and tunnels and presents alternative solutions in the form of a hybrid system. The innovative approach combines two independent methods well known in computer graphics: shape grammars and shape morphing for modeling three-dimensional geometry. In the modeling process, it is possible to obtain the characteristics of 3D structures with non-spherical mesh topology. The objects and their transformations are described by functions, while production grammars define the geometry modeling process. The scene graph can be expanded by classic productions and optimized by morphing productions. Obtained shapes can be freely deformed in subsequent productions. The system offers control over the process of modeling and the resulting structure can be rendered up to a high level of realism. We also propose some measures that can be used to verify the modeling results: coefficients indicating the degree of convexity of three-dimensional model topology based on the structure of inequality, the volume of the model, surface model and the number of model elements.