Although regarded as a standard heuristic for constructing a kd-tree, Surface Area Heuristic (SAH) suffers from degrading traversal performance as well as unnecessary acceleration structure construction due to its assumption of uniform ray distribution. In this paper, first, we propose a Grid based Ray Distribution Heuristic (GRDH) to construct a high quality kd-tree. The information of ray distribution is sampled and recorded in a sparse grid, which is also utilized to partition primitives efficiently. The heuristic only evaluating traversal cost on limited splitting candidates, is fast and easy to be implemented. Then, we introduce a novel ray tracing pipeline with two-pass construction and two-pass tracing routine to enable an ondemand construction algorithm. In the pipeline, after constructing a partially structured kd-tree, rays are classified by whether triggering transitions to construct unstructured leaf nodes, and being traced in different tracing passes. For on-demand construction, this raises the barrier of interleaving with traversal routine, as well as enables the algorithm to be flexible on multi-core computation platform. Additionally, GRDH is also combined into on-demand construction for high traversal performance. The experimental results demonstrate that the on-demand GRDH construction algorithm can achieve a speedup of 1.63~1.95 in overall frame performance for scenes with more than 360K primitives.