Semianalytic expressions are derived for the first-order derivative of a pressure field in a laterally homogeneous waveguide, with respect to an arbitrary three-dimensional refractive index perturbation in either the water column or ocean bottom. These expressions for the ''environmental derivative,'' derived using an adjoint method, require a three-dimensional spatial correlation between two Green's functions, weighted by an environmental parameter basis function, with the Green's functions expressed in terms of normal modes. When a particular set of orthogonal spatial basis functions is chosen, the three-dimensional spatial integral can be converted into a set of one-dimensional integrations over depth and azimuth. The use of the orthogonal basis permits environmental derivatives to be computed for an arbitrary sound-speed perturbation. To illustrate the formulas, a simple sensitivity study is presented that explores under what circumstances three-dimensional plane-wave and cylindrical perturbations produce non-negligible horizontal refraction effects, for a fixed source/receiver geometry. Other potential applications of these formulas include benchmarking three-dimensional propagation codes, and computing Cramer-Rao bounds for three-dimensional environmental parameter estimates, including internal wave components.