Note that there are some explanatory texts on larger screens.

plurals
  1. PORay setup in CUDA using OpenGL-supplied matrices
    primarykey
    data
    text
    <p>I'm working on a project where I port my CUDA code for usage as a module in a big application which maintains its own OpenGL state. My module basically is a volume renderer. I am now facing the problem that I have to setup the rays of the volume renderer to exactly mimic the OpenGL camera, so that my volume renderering fits with the rest of the rendered scene.</p> <p>At the point where my CUDA code is called there is a viewing matrix (no model-view matrix) and a projection matrix set. I already extracted the frustum parameters and the camera position in world space. </p> <pre><code>u *= -c_pp.right; v *= -c_pp.top; Ray eyeRay; eyeRay.o = make_float3(c_camPosition); //origin eyeRay.d = normalize(make_float3(u, v, -c_pp.near)); //direction </code></pre> <p><code>u</code> and <code>v</code> are normalized screen coordinates running from <code>-1</code> to <code>1</code>. <code>c_pp</code> describes the view frustum using <code>top</code>, <code>right</code> and <code>near</code>. I'm now looking for the appropriate matrix I have to multiply with so that <code>eyeRay.d</code> shows in the right direction. So far using the viewing matrix or its transposed or inverted version failed.</p> <p><strong>Update</strong>:</p> <p>Changed <code>u *= -c_pp.right</code> to <code>u *= c_pp.right</code> and everything works by multiplying <code>eyeRay.d</code> with the inverse viewing matrix.</p> <p>Complete fixed code:</p> <pre><code>u *= c_pp.right; v *= -c_pp.top; Ray eyeRay; eyeRay.o = make_float3(c_camPosition); //origin eyeRay.d = make_float3(u, v, -c_pp.near)); //direction eyeRay.d = mul(c_invViewMatrix, eyeRay.d); </code></pre> <p>with <code>c_inViewMatrix</code> being the inverse view matrix.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload