The qualitative and quantitative accuracy of SPECT images is degraded by physical factors of attenuation, Compton scatter and spatially varying collimator geometric response. This paper presents a 3D ray-tracing technique for modelling attenuation, scatter and geometric response for SPECT imaging in an inhomogeneous attenuating medium. The model is incorporated into a three-dimensional projector-backprojector and used with the maximum-likelihood expectation-maximization algorithm for reconstruction of parallel-beam data. A transmission map is used to define the inhomogeneous attenuating and scattering object being imaged. The attenuation map defines the probability of photon attenuation between the source and the scattering site, the scattering angle at the scattering site and the probability of attenuation of the scattered photon between the scattering site and the detector. The probability of a photon being scattered through a given angle and being detected in the emission energy window is approximated using a Gaussian function. The parameters of this Gaussian function are determined using physical measurements of parallel-beam scatter line spread functions from a non-uniformly attenuating phantom. The 3D ray-tracing scatter projector-backprojector produces the scatter and primary components. Then, a 3D ray-tracing projector-backprojector is used to model the geometric response of the collimator. From Monte Carlo and physical phantom experiments, it is shown that the best results are obtained by simultaneously correcting attenuation, scatter and geometric response, compared with results obtained with only one or two of the three corrections. It is also shown that a 3D scatter model is more accurate than a 2D model. A transmission map is useful for obtaining measurements of attenuation and scatter in SPECT data, which can be used together with a model of the geometric response of the collimator to obtain corrected images with quantitative and diagnostically accurate information.