make material to write depth and not to write color

I want to render mesh in depth mode(only modify depth buffer, and keep color), how can I achieve this? I tried to set material in transparent mode, and found that in this mode, depth could not be modified. In opacity mode, I cannot keep color unchanged. Thanks.