The optimal texture shape considering surface roughness is determined by solving the average Reynolds equation, selecting Jakobsson-Floberg-Olsson boundary conditions, and using a genetic algorithm. The effects of surface roughness as indicated by the combined root-mean-square (RMS), surface pattern parameter, and operating parameters on the friction coefficient, area ratio, and depth of the optimal self-defined shape and optimal dimple were studied. Results show that the friction coefficient will be significantly reduced during the shape optimization considering the effect of surface roughness. The variation laws of the optimal dimple area ratio with the combined RMS, surface pattern parameter, minimum film thickness, sliding speed and the variation law of the optimal depth of the optimal self-defined shape with surface roughness and working parameters are obtained. Finally, this study concludes that the influence of roughness parameters on the optimal dimple shape is greater than that on the optimal self-defined shape under different sliding speeds.