RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
1.02k stars 186 forks source link

FarClip in custom camera #118

Closed favreau closed 7 years ago

favreau commented 7 years ago

Hi, I am trying to set the far clip in a camera, using the setRay(..., far, near) API but this does not seem to work. The nearClip value works fine, but the farClip appears to be ignored and produces identical results regardless of the value. I am currently using the 1.1.2 release. Thanks. Cyrille

johguenther commented 7 years ago

You use setRay in your own camera implementation and the SciVis renderer? The parameter order is actually setRay(ray, origin, direction, near, far).

favreau commented 7 years ago

OOps, apologies for the mistake in the API, I am using setRay correctly, and with the parameters in the right order setRay(..., near, far). I am indeed using my own camera implementation for custom clipping. And I am also using a custom renderer (https://github.com/BlueBrain/Brayns/blob/master/plugins/engines/ospray/ispc/render/ExtendedOBJRenderer.ispc) but I don't see why this should prevent the 'far' parameters from working. In order to isolate my problem, I will apply my changes to the OSPRay examples and see how it goes. I'll get back to you promptly.

favreau commented 7 years ago

Ok, I run the same test using OSPRay only. I run the ospGlutViewer with a sample obj file, and set the 'far' value in the perspective camera (line 55 of PerspectiveCamera.ispc) with some dummy value matching the size of the mesh, for ex: setRay(ray, org, normalize(dir), self->super.nearClip, 1.f ); The 'far' value does not seem to have any effect, whatever I set it to.

ingowald commented 7 years ago

Confused, but confirmed.

I just double-checked all code, and the values get set corretly - but I agree that when I repeated exactly this experiment (hardcoding the distance in PerspectvieCamera_setRay() I do not get any impact. Weird indeed.

Looking into it right now.

Ingo

On 01/18/2017 02:11 AM, Cyrille Favreau wrote:

Ok, I run the same test using OSPRay only. I run the ospGlutViewer with a sample obj file, and set the 'far' value in the perspective camera (line 55 of PerspectiveCamera.ispc) with some dummy value matching the size of the mesh, for ex: setRay(ray, org, normalize(dir), self->super.nearClip, 1.f ); The 'far' value does not seem to have any effect, whatever I set it to.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ospray/OSPRay/issues/118#issuecomment-273421953, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwZtaUsDVNgFNsv_fQ5ir71be1xATnaks5rTddfgaJpZM4Ll85k.

ingowald commented 7 years ago

OK, found it - ospray/render/Renderer.ispc, line 114 (in my branch) :

     camera->initRay(camera,screenSample.ray,cameraSample);
     screenSample.ray.t = tMax;

Seems Johannes added that line to allow a depth texture to overwrite that ray's own t value. Suggest changing that to

ray.t = min(ray.t,tMax).

Johannes - agreed?

Ingo

PS: @cryrille - as a quick-fix you should be able to uncomment this line until Johannes pushes a real fix.

On 01/18/2017 02:11 AM, Cyrille Favreau wrote:

Ok, I run the same test using OSPRay only. I run the ospGlutViewer with a sample obj file, and set the 'far' value in the perspective camera (line 55 of PerspectiveCamera.ispc) with some dummy value matching the size of the mesh, for ex: setRay(ray, org, normalize(dir), self->super.nearClip, 1.f ); The 'far' value does not seem to have any effect, whatever I set it to.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ospray/OSPRay/issues/118#issuecomment-273421953, or mute the thread https://github.com/notifications/unsubscribe-auth/ABwZtaUsDVNgFNsv_fQ5ir71be1xATnaks5rTddfgaJpZM4Ll85k.

favreau commented 7 years ago

Looking much better !! Many thanks for that. Waiting for Johannes' agreement to close the issue then. Thanks again.

favreau commented 7 years ago

Hi guys, any idea when this fix will be merged? Thanks.

jeffamstutz commented 7 years ago

The fix is currently in devel, which means that it will make it into our next release. We only merge master when we do a release (it always points to the latest release). We should be doing a release soon, currently targeting the first half of February.

favreau commented 7 years ago

Sounds cool. Thanks for that :-) I'll keep an eye on the next release then.