In my surface shader I want to create specular shading generated from an environment, e.g. an IBL. I cannot use the "emit light" method in the IBL, but I'd like to generate more or less the same effect. The idea is to sample the environment with a bunch of rays and extract the rays which gives a bright result. Then I can save the direction and color value from these positions and use them to simulate lights.

The sampling of the environment is done in the init() procedure. My problem is that if my object moves, the sampling changes. So my question is:

Can I somehow force the mi_sample() to generate the same values every time I call it?

With this code:
Code:
miVector point = state->point;
miVector null = {0,0,0};
state->point = null;
int count = 0;
double vec[3];
while(mi_sample(vec, &count, state, 3, &numPrimSamples))
{
	miColor ecol;
	miVector traceDir;		
	traceDir.x = (vec[0] - 0.5f) * 2.0f;
	traceDir.y = (vec[1] - 0.5f) * 2.0f;
	traceDir.z = (vec[2] - 0.5f) * 2.0f;
	mi_vector_normalize(&traceDir);
	mi_trace_environment(&ecol, state, &traceDir);
}
I get the same result if my object remains at the same position. But if I move it a bit, the result changes. But it should remain the same, thats the reason why I set the state->point to 0.

Any ideas?