When sample or evaluate the materials we need find which type of material we will sample or evaluate. In the old version, we loop all material type and find the "true material".
But we can find it before runtime. For each entity has "shape" and "material" we will set the "closesthit" shader, so we can set the "closesthit" shader according to "material" and "shape" and do lighting, sampling in "closesthit" shader.
The performance in some scenes is increased(the samples per second of ganesha is 40 now(32 old)). But in some scenes the samples per second is decreased.