--------------------------------------------------------------------------
| 383 | |
| 384 | //-------------------------------------------------------------------------- |
| 385 | inline std::string BaseInit(vtkRenderer* vtkNotUsed(ren), vtkVolumeMapper* mapper, |
| 386 | vtkOpenGLGPUVolumeRayCastMapper::VolumeInputMap& inputs, bool defaultLighting) |
| 387 | { |
| 388 | vtkOpenGLGPUVolumeRayCastMapper* glMapper = vtkOpenGLGPUVolumeRayCastMapper::SafeDownCast(mapper); |
| 389 | vtkVolume* vol = inputs.begin()->second.Volume; |
| 390 | const int numInputs = static_cast<int>(inputs.size()); |
| 391 | |
| 392 | std::ostringstream shaderStr; |
| 393 | if (glMapper->GetCurrentPass() != vtkOpenGLGPUVolumeRayCastMapper::DepthPass && |
| 394 | glMapper->GetUseDepthPass() && glMapper->GetBlendMode() == vtkVolumeMapper::COMPOSITE_BLEND) |
| 395 | { |
| 396 | shaderStr << "\ |
| 397 | \n //\ |
| 398 | \n vec2 fragTexCoord2 = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\ |
| 399 | \n in_inverseWindowSize;\ |
| 400 | \n vec4 depthValue = texture2D(in_depthPassSampler, fragTexCoord2);\ |
| 401 | \n vec4 rayOrigin = WindowToNDC(gl_FragCoord.x, gl_FragCoord.y, depthValue.x);\ |
| 402 | \n\ |
| 403 | \n // From normalized device coordinates to eye coordinates.\ |
| 404 | \n // in_projectionMatrix is inversed because of way VT\ |
| 405 | \n // From eye coordinates to texture coordinates\ |
| 406 | \n rayOrigin = in_inverseTextureDatasetMatrix[0] *\ |
| 407 | \n in_inverseVolumeMatrix[0] *\ |
| 408 | \n in_inverseModelViewMatrix *\ |
| 409 | \n in_inverseProjectionMatrix *\ |
| 410 | \n rayOrigin;\ |
| 411 | \n rayOrigin /= rayOrigin.w;\ |
| 412 | \n g_rayOrigin = rayOrigin.xyz;"; |
| 413 | } |
| 414 | else |
| 415 | { |
| 416 | shaderStr << "\ |
| 417 | \n // Get the 3D texture coordinates for lookup into the in_volume dataset\ |
| 418 | \n g_rayOrigin = ip_textureCoords.xyz;"; |
| 419 | } |
| 420 | |
| 421 | shaderStr << "\n\ |
| 422 | \n // Getting the ray marching direction (in dataset space)\ |
| 423 | \n vec3 rayDir = computeRayDirection();\ |
| 424 | \n\ |
| 425 | \n // 2D Texture fragment coordinates [0,1] from fragment coordinates.\ |
| 426 | \n // The frame buffer texture has the size of the plain buffer but \ |
| 427 | \n // we use a fraction of it. The texture coordinate is less than 1 if\ |
| 428 | \n // the reduction factor is less than 1.\ |
| 429 | \n // Device coordinates are between -1 and 1. We need texture\ |
| 430 | \n // coordinates between 0 and 1. The in_depthSampler\ |
| 431 | \n // buffer has the original size buffer.\ |
| 432 | \n vec2 fragTexCoord = (gl_FragCoord.xy - in_windowLowerLeftCorner) *\ |
| 433 | \n in_inverseWindowSize;\ |
| 434 | \n\ |
| 435 | \n // Multiply the raymarching direction with the step size to get the\ |
| 436 | \n // sub-step size we need to take at each raymarching step\ |
| 437 | \n g_dirStep = (ip_inverseTextureDataAdjusted *\ |
| 438 | \n vec4(rayDir, 0.0)).xyz * in_sampleDistance;\ |
| 439 | \n g_lengthStep = length(g_dirStep);\ |
| 440 | \n"; |
| 441 | |
| 442 | shaderStr << "\ |
no test coverage detected