------------------------------------------------------------------------------
| 51 | |
| 52 | //------------------------------------------------------------------------------ |
| 53 | void vtkPBRPrefilterTexture::Load(vtkRenderer* ren) |
| 54 | { |
| 55 | vtkOpenGLRenderWindow* renWin = vtkOpenGLRenderWindow::SafeDownCast(ren->GetRenderWindow()); |
| 56 | if (!renWin) |
| 57 | { |
| 58 | vtkErrorMacro("No render window."); |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | if (!this->InputTexture) |
| 63 | { |
| 64 | vtkErrorMacro("No input cubemap specified."); |
| 65 | return; |
| 66 | } |
| 67 | |
| 68 | #ifdef GL_ES_VERSION_3_0 |
| 69 | // Mipmap generation is not supported for most texture formats (like GL_RGB32F) |
| 70 | this->InputTexture->MipmapOff(); |
| 71 | this->InputTexture->InterpolateOff(); |
| 72 | #endif |
| 73 | this->InputTexture->Render(ren); |
| 74 | this->PrefilterSize = this->InputTexture->GetTextureObject()->GetHeight(); |
| 75 | |
| 76 | if (this->GetMTime() > this->LoadTime.GetMTime() || |
| 77 | this->InputTexture->GetMTime() > this->LoadTime.GetMTime()) |
| 78 | { |
| 79 | if (this->TextureObject == nullptr) |
| 80 | { |
| 81 | this->TextureObject = vtkTextureObject::New(); |
| 82 | } |
| 83 | this->TextureObject->SetContext(renWin); |
| 84 | this->TextureObject->SetWrapS(vtkTextureObject::ClampToEdge); |
| 85 | this->TextureObject->SetWrapT(vtkTextureObject::ClampToEdge); |
| 86 | this->TextureObject->SetWrapR(vtkTextureObject::ClampToEdge); |
| 87 | this->TextureObject->SetMinificationFilter(vtkTextureObject::LinearMipmapLinear); |
| 88 | this->TextureObject->SetMagnificationFilter(vtkTextureObject::Linear); |
| 89 | this->TextureObject->SetGenerateMipmap(true); |
| 90 | this->TextureObject->SetMaxLevel(this->PrefilterLevels - 1); |
| 91 | #ifdef GL_ES_VERSION_3_0 |
| 92 | this->TextureObject->SetFormat(GL_RGB); |
| 93 | this->TextureObject->SetDataType(GL_UNSIGNED_BYTE); |
| 94 | this->TextureObject->SetInternalFormat(GL_RGB8); |
| 95 | this->TextureObject->CreateCubeFromRaw( |
| 96 | this->PrefilterSize, this->PrefilterSize, 3, VTK_UNSIGNED_CHAR, nullptr); |
| 97 | #else |
| 98 | this->TextureObject->SetFormat(GL_RGB); |
| 99 | this->TextureObject->SetInternalFormat(this->HalfPrecision ? GL_RGB16F : GL_RGB32F); |
| 100 | this->TextureObject->CreateCubeFromRaw( |
| 101 | this->PrefilterSize, this->PrefilterSize, 3, VTK_FLOAT, nullptr); |
| 102 | #endif |
| 103 | |
| 104 | this->RenderWindow = renWin; |
| 105 | |
| 106 | vtkOpenGLState* state = renWin->GetState(); |
| 107 | vtkOpenGLState::ScopedglViewport svp(state); |
| 108 | vtkOpenGLState::ScopedglEnableDisable sdepth(state, GL_DEPTH_TEST); |
| 109 | vtkOpenGLState::ScopedglEnableDisable sblend(state, GL_BLEND); |
| 110 | vtkOpenGLState::ScopedglEnableDisable sscissor(state, GL_SCISSOR_TEST); |
nothing calls this directly
no test coverage detected