of gravitationally bound ultracold neutrons in rough waveguides. Phys. Rev. A, 83, 033618 1-9 (2011 We investigate the propagation of ultracold neutrons through a rough waveguide in conjunction with recent experiments in which the ultracold neutrons were beamed between a perfect mirror and a rough scatterer and absorber. The main goal is to find a way to resolve the lowest gravitationally quantized discrete states in the peV range. We compare the neutron count for various types of mirrors with Gaussian, power-law, and exponential correlation functions of surface inhomogeneities. The main conclusion is that all the information about inhomogeneities, including their amplitude, correlation radius, and the rate of decay of the correlation function, enter the exit neutron count via just a single constant , which effectively renormalizes the amplitude of roughness. To observe well-defined quantum steps, one should have an experimental setup with > 40. For a wide variety of correlation functions, the constant is proportional to the square of the amplitude of the surface roughness and is inversely proportional to the square root of the correlation radius. The strong dependence of on roughness parameters and the shape of the correlation function opens a novel way for improving the resolution of gravitationally bound states by optimizing the roughness pattern without reverting to an undesirable strong roughness. We discuss how to optimize the scatterer and absorber by first generating numerically the desired roughness profile and then transferring it to the mirror. We also study the effect of beam preparation on the initial occupancies of gravitational states before the beam enters the waveguide. It turns out that there are simple ways to manipulate the beam in front of the waveguide that can help to resolve the gravitationally bound quantum states. Our results are in good agreement with available experimental data.