Showing the changes to libraries/render-utils/src/DeferredLightingEffect.cpp (1 of 1213 files). Show all
Unified · Split
| @@ -11,9 +11,12 @@ · 10 unmodified lines | ||
| 11 | 11 | |
| 12 | 12 | #include "DeferredLightingEffect.h" |
| 13 | 13 | |
| 14 | +#include <QtCore/QFileSelector> | |
| 15 | + | |
| 14 | 16 | #include <GLMHelpers.h> |
| 15 | 17 | #include <PathUtils.h> |
| 16 | 18 | #include <ViewFrustum.h> |
| 19 | +#include <shared/FileUtils.h> | |
| 17 | 20 | |
| 18 | 21 | #include <gpu/Batch.h> |
| 19 | 22 | #include <gpu/Context.h> |
| @@ -42,6 +45,7 @@ using namespace render; · 22 unmodified lines | ||
| 42 | 45 | |
| 43 | 46 | struct LightLocations { |
| 44 | 47 | int radius{ -1 }; |
| 48 | + int keyLightBufferUnit{ -1 }; | |
| 45 | 49 | int lightBufferUnit{ -1 }; |
| 46 | 50 | int ambientBufferUnit { -1 }; |
| 47 | 51 | int lightIndexBufferUnit { -1 }; |
| @@ -58,7 +62,7 @@ enum DeferredShader_MapSlot { · 10 unmodified lines | ||
| 58 | 62 | DEFERRED_BUFFER_DEPTH_UNIT = 3, |
| 59 | 63 | DEFERRED_BUFFER_OBSCURANCE_UNIT = 4, |
| 60 | 64 | SHADOW_MAP_UNIT = 5, |
| 61 | − SKYBOX_MAP_UNIT = 6, | |
| 65 | + SKYBOX_MAP_UNIT = SHADOW_MAP_UNIT + SHADOW_CASCADE_MAX_COUNT, | |
| 62 | 66 | DEFERRED_BUFFER_LINEAR_DEPTH_UNIT, |
| 63 | 67 | DEFERRED_BUFFER_CURVATURE_UNIT, |
| 64 | 68 | DEFERRED_BUFFER_DIFFUSED_CURVATURE_UNIT, |
| @@ -71,15 +75,15 @@ enum DeferredShader_BufferSlot { · 6 unmodified lines | ||
| 71 | 75 | SCATTERING_PARAMETERS_BUFFER_SLOT, |
| 72 | 76 | LIGHTING_MODEL_BUFFER_SLOT = render::ShapePipeline::Slot::LIGHTING_MODEL, |
| 73 | 77 | LIGHT_GPU_SLOT = render::ShapePipeline::Slot::LIGHT, |
| 74 | − LIGHT_AMBIENT_SLOT, | |
| 78 | + LIGHT_AMBIENT_SLOT = render::ShapePipeline::Slot::LIGHT_AMBIENT_BUFFER, | |
| 79 | + HAZE_MODEL_BUFFER_SLOT = render::ShapePipeline::Slot::HAZE_MODEL, | |
| 75 | 80 | LIGHT_INDEX_GPU_SLOT, |
| 76 | 81 | LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT, |
| 77 | 82 | LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, |
| 78 | 83 | LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, |
| 79 | − HAZE_MODEL_BUFFER_SLOT | |
| 80 | 84 | }; |
| 81 | 85 | |
| 82 | −static void loadLightProgram(const char* vertSource, const char* fragSource, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations); | |
| 86 | +static void loadLightProgram(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, bool lightVolume, gpu::PipelinePointer& program, LightLocationsPtr& locations); | |
| 83 | 87 | |
| 84 | 88 | void DeferredLightingEffect::init() { |
| 85 | 89 | _directionalAmbientSphereLightLocations = std::make_shared<LightLocations>(); |
| @@ -91,25 +95,25 @@ void DeferredLightingEffect::init() { · 5 unmodified lines | ||
| 91 | 95 | _localLightLocations = std::make_shared<LightLocations>(); |
| 92 | 96 | _localLightOutlineLocations = std::make_shared<LightLocations>(); |
| 93 | 97 | |
| 94 | − loadLightProgram(deferred_light_vert, directional_ambient_light_frag, false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations); | |
| 95 | − loadLightProgram(deferred_light_vert, directional_skybox_light_frag, false, _directionalSkyboxLight, _directionalSkyboxLightLocations); | |
| 98 | + loadLightProgram(deferred_light_vert::getShader(), directional_ambient_light_frag::getShader(), false, _directionalAmbientSphereLight, _directionalAmbientSphereLightLocations); | |
| 99 | + loadLightProgram(deferred_light_vert::getShader(), directional_skybox_light_frag::getShader(), false, _directionalSkyboxLight, _directionalSkyboxLightLocations); | |
| 96 | 100 | |
| 97 | − loadLightProgram(deferred_light_vert, directional_ambient_light_shadow_frag, false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations); | |
| 98 | − loadLightProgram(deferred_light_vert, directional_skybox_light_shadow_frag, false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations); | |
| 101 | + loadLightProgram(deferred_light_vert::getShader(), directional_ambient_light_shadow_frag::getShader(), false, _directionalAmbientSphereLightShadow, _directionalAmbientSphereLightShadowLocations); | |
| 102 | + loadLightProgram(deferred_light_vert::getShader(), directional_skybox_light_shadow_frag::getShader(), false, _directionalSkyboxLightShadow, _directionalSkyboxLightShadowLocations); | |
| 99 | 103 | |
| 100 | − loadLightProgram(deferred_light_vert, local_lights_shading_frag, true, _localLight, _localLightLocations); | |
| 101 | − loadLightProgram(deferred_light_vert, local_lights_drawOutline_frag, true, _localLightOutline, _localLightOutlineLocations); | |
| 104 | + loadLightProgram(deferred_light_vert::getShader(), local_lights_shading_frag::getShader(), true, _localLight, _localLightLocations); | |
| 105 | + loadLightProgram(deferred_light_vert::getShader(), local_lights_drawOutline_frag::getShader(), true, _localLightOutline, _localLightOutlineLocations); | |
| 102 | 106 | } |
| 103 | 107 | |
| 104 | 108 | void DeferredLightingEffect::setupKeyLightBatch(const RenderArgs* args, gpu::Batch& batch, int lightBufferUnit, int ambientBufferUnit, int skyboxCubemapUnit) { |
| 105 | 109 | PerformanceTimer perfTimer("DLE->setupBatch()"); |
| 106 | − model::LightPointer keySunLight; | |
| 110 | + graphics::LightPointer keySunLight; | |
| 107 | 111 | auto lightStage = args->_scene->getStage<LightStage>(); |
| 108 | 112 | if (lightStage) { |
| 109 | 113 | keySunLight = lightStage->getCurrentKeyLight(); |
| 110 | 114 | } |
| 111 | 115 | |
| 112 | − model::LightPointer keyAmbiLight; | |
| 116 | + graphics::LightPointer keyAmbiLight; | |
| 113 | 117 | if (lightStage) { |
| 114 | 118 | keyAmbiLight = lightStage->getCurrentAmbientLight(); |
| 115 | 119 | } |
| @@ -144,19 +148,38 @@ void DeferredLightingEffect::unsetKeyLightBatch(gpu::Batch& batch, int lightBuff · 28 unmodified lines | ||
| 144 | 148 | } |
| 145 | 149 | } |
| 146 | 150 | |
| 147 | −static gpu::ShaderPointer makeLightProgram(const char* vertSource, const char* fragSource, LightLocationsPtr& locations) { | |
| 148 | − auto VS = gpu::Shader::createVertex(std::string(vertSource)); | |
| 149 | − auto PS = gpu::Shader::createPixel(std::string(fragSource)); | |
| 150 | − | |
| 151 | − gpu::ShaderPointer program = gpu::Shader::createProgram(VS, PS); | |
| 151 | +void DeferredLightingEffect::setupLocalLightsBatch(gpu::Batch& batch, | |
| 152 | + int clusterGridBufferUnit, int clusterContentBufferUnit, int frustumGridBufferUnit, | |
| 153 | + const LightClustersPointer& lightClusters) { | |
| 154 | + // Bind the global list of lights and the visible lights this frame | |
| 155 | + batch.setUniformBuffer(_localLightLocations->lightBufferUnit, lightClusters->_lightStage->getLightArrayBuffer()); | |
| 156 | + | |
| 157 | + batch.setUniformBuffer(frustumGridBufferUnit, lightClusters->_frustumGridBuffer); | |
| 158 | + batch.setUniformBuffer(clusterGridBufferUnit, lightClusters->_clusterGridBuffer); | |
| 159 | + batch.setUniformBuffer(clusterContentBufferUnit, lightClusters->_clusterContentBuffer); | |
| 160 | +} | |
| 152 | 161 | |
| 162 | +void DeferredLightingEffect::unsetLocalLightsBatch(gpu::Batch& batch, int clusterGridBufferUnit, int clusterContentBufferUnit, int frustumGridBufferUnit) { | |
| 163 | + if (clusterGridBufferUnit >= 0) { | |
| 164 | + batch.setUniformBuffer(clusterGridBufferUnit, nullptr); | |
| 165 | + } | |
| 166 | + if (clusterContentBufferUnit >= 0) { | |
| 167 | + batch.setUniformBuffer(clusterContentBufferUnit, nullptr); | |
| 168 | + } | |
| 169 | + if (frustumGridBufferUnit >= 0) { | |
| 170 | + batch.setUniformBuffer(frustumGridBufferUnit, nullptr); | |
| 171 | + } | |
| 172 | +} | |
| 173 | + | |
| 174 | +static gpu::ShaderPointer makeLightProgram(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, LightLocationsPtr& locations) { | |
| 175 | + gpu::ShaderPointer program = gpu::Shader::createProgram(vertShader, fragShader); | |
| 153 | 176 | gpu::Shader::BindingSet slotBindings; |
| 154 | 177 | slotBindings.insert(gpu::Shader::Binding(std::string("colorMap"), DEFERRED_BUFFER_COLOR_UNIT)); |
| 155 | 178 | slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), DEFERRED_BUFFER_NORMAL_UNIT)); |
| 156 | 179 | slotBindings.insert(gpu::Shader::Binding(std::string("specularMap"), DEFERRED_BUFFER_EMISSIVE_UNIT)); |
| 157 | 180 | slotBindings.insert(gpu::Shader::Binding(std::string("depthMap"), DEFERRED_BUFFER_DEPTH_UNIT)); |
| 158 | 181 | slotBindings.insert(gpu::Shader::Binding(std::string("obscuranceMap"), DEFERRED_BUFFER_OBSCURANCE_UNIT)); |
| 159 | − slotBindings.insert(gpu::Shader::Binding(std::string("shadowMap"), SHADOW_MAP_UNIT)); | |
| 182 | + slotBindings.insert(gpu::Shader::Binding(std::string("shadowMaps"), SHADOW_MAP_UNIT)); | |
| 160 | 183 | slotBindings.insert(gpu::Shader::Binding(std::string("skyboxMap"), SKYBOX_MAP_UNIT)); |
| 161 | 184 | |
| 162 | 185 | slotBindings.insert(gpu::Shader::Binding(std::string("linearZeyeMap"), DEFERRED_BUFFER_LINEAR_DEPTH_UNIT)); |
| @@ -186,6 +209,7 @@ static gpu::ShaderPointer makeLightProgram(const char* vertSource, const char* f · 23 unmodified lines | ||
| 186 | 209 | |
| 187 | 210 | locations->texcoordFrameTransform = program->getUniforms().findLocation("texcoordFrameTransform"); |
| 188 | 211 | |
| 212 | + locations->keyLightBufferUnit = program->getUniformBuffers().findLocation("keyLightBuffer"); | |
| 189 | 213 | locations->lightBufferUnit = program->getUniformBuffers().findLocation("lightBuffer"); |
| 190 | 214 | locations->ambientBufferUnit = program->getUniformBuffers().findLocation("lightAmbientBuffer"); |
| 191 | 215 | locations->lightIndexBufferUnit = program->getUniformBuffers().findLocation("lightIndexBuffer"); |
| @@ -196,9 +220,9 @@ static gpu::ShaderPointer makeLightProgram(const char* vertSource, const char* f · 4 unmodified lines | ||
| 196 | 220 | return program; |
| 197 | 221 | } |
| 198 | 222 | |
| 199 | −static void loadLightProgram(const char* vertSource, const char* fragSource, bool lightVolume, gpu::PipelinePointer& pipeline, LightLocationsPtr& locations) { | |
| 223 | +static void loadLightProgram(const gpu::ShaderPointer& vertShader, const gpu::ShaderPointer& fragShader, bool lightVolume, gpu::PipelinePointer& pipeline, LightLocationsPtr& locations) { | |
| 200 | 224 | |
| 201 | − gpu::ShaderPointer program = makeLightProgram(vertSource, fragSource, locations); | |
| 225 | + gpu::ShaderPointer program = makeLightProgram(vertShader, fragShader, locations); | |
| 202 | 226 | |
| 203 | 227 | auto state = std::make_shared<gpu::State>(); |
| 204 | 228 | state->setColorWriteMask(true, true, true, false); |
| @@ -229,9 +253,9 @@ static void loadLightProgram(const char* vertSource, const char* fragSource, boo · 24 unmodified lines | ||
| 229 | 253 | |
| 230 | 254 | #include <shared/Shapes.h> |
| 231 | 255 | |
| 232 | −model::MeshPointer DeferredLightingEffect::getPointLightMesh() { | |
| 256 | +graphics::MeshPointer DeferredLightingEffect::getPointLightMesh() { | |
| 233 | 257 | if (!_pointLightMesh) { |
| 234 | − _pointLightMesh = std::make_shared<model::Mesh>(); | |
| 258 | + _pointLightMesh = std::make_shared<graphics::Mesh>(); | |
| 235 | 259 | |
| 236 | 260 | // let's use a icosahedron |
| 237 | 261 | auto solid = geometry::icosahedron(); |
| @@ -256,19 +280,19 @@ model::MeshPointer DeferredLightingEffect::getPointLightMesh() { · 18 unmodified lines | ||
| 256 | 280 | delete[] indexData; |
| 257 | 281 | |
| 258 | 282 | |
| 259 | − std::vector<model::Mesh::Part> parts; | |
| 260 | − parts.push_back(model::Mesh::Part(0, nbIndices, 0, model::Mesh::TRIANGLES)); | |
| 261 | − parts.push_back(model::Mesh::Part(0, nbIndices, 0, model::Mesh::LINE_STRIP)); // outline version | |
| 283 | + std::vector<graphics::Mesh::Part> parts; | |
| 284 | + parts.push_back(graphics::Mesh::Part(0, nbIndices, 0, graphics::Mesh::TRIANGLES)); | |
| 285 | + parts.push_back(graphics::Mesh::Part(0, nbIndices, 0, graphics::Mesh::LINE_STRIP)); // outline version | |
| 262 | 286 | |
| 263 | 287 | |
| 264 | − _pointLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(model::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL)); | |
| 288 | + _pointLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(graphics::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL)); | |
| 265 | 289 | } |
| 266 | 290 | return _pointLightMesh; |
| 267 | 291 | } |
| 268 | 292 | |
| 269 | −model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { | |
| 293 | +graphics::MeshPointer DeferredLightingEffect::getSpotLightMesh() { | |
| 270 | 294 | if (!_spotLightMesh) { |
| 271 | − _spotLightMesh = std::make_shared<model::Mesh>(); | |
| 295 | + _spotLightMesh = std::make_shared<graphics::Mesh>(); | |
| 272 | 296 | |
| 273 | 297 | int slices = 16; |
| 274 | 298 | int rings = 3; |
| @@ -353,12 +377,12 @@ model::MeshPointer DeferredLightingEffect::getSpotLightMesh() { · 78 unmodified lines | ||
| 353 | 377 | delete[] indexData; |
| 354 | 378 | |
| 355 | 379 | |
| 356 | − std::vector<model::Mesh::Part> parts; | |
| 357 | − parts.push_back(model::Mesh::Part(0, indices, 0, model::Mesh::TRIANGLES)); | |
| 358 | − parts.push_back(model::Mesh::Part(0, indices, 0, model::Mesh::LINE_STRIP)); // outline version | |
| 380 | + std::vector<graphics::Mesh::Part> parts; | |
| 381 | + parts.push_back(graphics::Mesh::Part(0, indices, 0, graphics::Mesh::TRIANGLES)); | |
| 382 | + parts.push_back(graphics::Mesh::Part(0, indices, 0, graphics::Mesh::LINE_STRIP)); // outline version | |
| 359 | 383 | |
| 360 | 384 | |
| 361 | − _spotLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(model::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL)); | |
| 385 | + _spotLightMesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(graphics::Mesh::Part), (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL)); | |
| 362 | 386 | } |
| 363 | 387 | return _spotLightMesh; |
| 364 | 388 | } |
| @@ -439,7 +463,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, · 74 unmodified lines | ||
| 439 | 463 | const DeferredFrameTransformPointer& frameTransform, |
| 440 | 464 | const DeferredFramebufferPointer& deferredFramebuffer, |
| 441 | 465 | const LightingModelPointer& lightingModel, |
| 442 | − const model::HazePointer& haze, | |
| 466 | + const graphics::HazePointer& haze, | |
| 443 | 467 | const SurfaceGeometryFramebufferPointer& surfaceGeometryFramebuffer, |
| 444 | 468 | const AmbientOcclusionFramebufferPointer& ambientOcclusionFramebuffer, |
| 445 | 469 | const SubsurfaceScatteringResourcePointer& subsurfaceScatteringResource) { |
| @@ -501,9 +525,11 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, · 55 unmodified lines | ||
| 501 | 525 | auto lightAndShadow = lightStage->getCurrentKeyLightAndShadow(); |
| 502 | 526 | const auto& globalShadow = lightAndShadow.second; |
| 503 | 527 | |
| 504 | − // Bind the shadow buffer | |
| 528 | + // Bind the shadow buffers | |
| 505 | 529 | if (globalShadow) { |
| 506 | − batch.setResourceTexture(SHADOW_MAP_UNIT, globalShadow->map); | |
| 530 | + for (unsigned int i = 0; i < globalShadow->getCascadeCount(); i++) { | |
| 531 | + batch.setResourceTexture(SHADOW_MAP_UNIT+i, globalShadow->getCascade(i).map); | |
| 532 | + } | |
| 507 | 533 | } |
| 508 | 534 | |
| 509 | 535 | auto& program = deferredLightingEffect->_directionalSkyboxLight; |
| @@ -511,7 +537,7 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, · 1 unmodified line | ||
| 511 | 537 | |
| 512 | 538 | auto keyLight = lightAndShadow.first; |
| 513 | 539 | |
| 514 | − model::LightPointer keyAmbientLight; | |
| 540 | + graphics::LightPointer keyAmbientLight; | |
| 515 | 541 | if (lightStage && lightStage->_currentFrame._ambientLights.size()) { |
| 516 | 542 | keyAmbientLight = lightStage->getLight(lightStage->_currentFrame._ambientLights.front()); |
| 517 | 543 | } |
| @@ -556,19 +582,20 @@ void RenderDeferredSetup::run(const render::RenderContextPointer& renderContext, · 38 unmodified lines | ||
| 556 | 582 | batch._glUniform4fv(locations->texcoordFrameTransform, 1, reinterpret_cast< const float* >(&textureFrameTransform)); |
| 557 | 583 | |
| 558 | 584 | // Setup the global lighting |
| 559 | − deferredLightingEffect->setupKeyLightBatch(args, batch, locations->lightBufferUnit, locations->ambientBufferUnit, SKYBOX_MAP_UNIT); | |
| 585 | + deferredLightingEffect->setupKeyLightBatch(args, batch, locations->keyLightBufferUnit, locations->ambientBufferUnit, SKYBOX_MAP_UNIT); | |
| 560 | 586 | |
| 561 | 587 | // Haze |
| 562 | 588 | if (haze) { |
| 563 | − batch.setUniformBuffer(HAZE_MODEL_BUFFER_SLOT, haze->getHazeParametersBuffer()); | |
| 589 | + batch.setUniformBuffer(HAZE_MODEL_BUFFER_SLOT, haze->getHazeParametersBuffer()); | |
| 564 | 590 | } |
| 565 | − | |
| 591 | + | |
| 566 | 592 | batch.draw(gpu::TRIANGLE_STRIP, 4); |
| 567 | 593 | |
| 568 | − deferredLightingEffect->unsetKeyLightBatch(batch, locations->lightBufferUnit, locations->ambientBufferUnit, SKYBOX_MAP_UNIT); | |
| 569 | − | |
| 594 | + deferredLightingEffect->unsetKeyLightBatch(batch, locations->keyLightBufferUnit, locations->ambientBufferUnit, SKYBOX_MAP_UNIT); | |
| 570 | 595 | |
| 571 | − batch.setResourceTexture(SHADOW_MAP_UNIT, nullptr); | |
| 596 | + for (auto i = 0; i < SHADOW_CASCADE_MAX_COUNT; i++) { | |
| 597 | + batch.setResourceTexture(SHADOW_MAP_UNIT+i, nullptr); | |
| 598 | + } | |
| 572 | 599 | } |
| 573 | 600 | } |
| 574 | 601 | |
| @@ -619,12 +646,8 @@ void RenderDeferredLocals::run(const render::RenderContextPointer& renderContext · 44 unmodified lines | ||
| 619 | 646 | |
| 620 | 647 | auto& lightIndices = lightClusters->_visibleLightIndices; |
| 621 | 648 | if (!lightIndices.empty() && lightIndices[0] > 0) { |
| 622 | − // Bind the global list of lights and the visible lights this frame | |
| 623 | − batch.setUniformBuffer(deferredLightingEffect->_localLightLocations->lightBufferUnit, lightClusters->_lightStage->getLightArrayBuffer()); | |
| 624 | − | |
| 625 | − batch.setUniformBuffer(LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT, lightClusters->_frustumGridBuffer); | |
| 626 | − batch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, lightClusters->_clusterGridBuffer); | |
| 627 | − batch.setUniformBuffer(LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, lightClusters->_clusterContentBuffer); | |
| 649 | + deferredLightingEffect->setupLocalLightsBatch(batch, LIGHT_CLUSTER_GRID_CLUSTER_GRID_SLOT, LIGHT_CLUSTER_GRID_CLUSTER_CONTENT_SLOT, LIGHT_CLUSTER_GRID_FRUSTUM_GRID_SLOT, | |
| 650 | + lightClusters); | |
| 628 | 651 | |
| 629 | 652 | // Local light pipeline |
| 630 | 653 | batch.setPipeline(deferredLightingEffect->_localLight); |
| @@ -726,11 +749,11 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { · 95 unmodified lines | ||
| 726 | 749 | auto textureCache = DependencyManager::get<TextureCache>(); |
| 727 | 750 | { |
| 728 | 751 | PROFILE_RANGE(render, "Process Default Skybox"); |
| 729 | − auto textureCache = DependencyManager::get<TextureCache>(); | |
| 730 | − | |
| 731 | − auto skyboxUrl = PathUtils::resourcesPath().toStdString() + "images/Default-Sky-9-cubemap.ktx"; | |
| 752 | + QFileSelector fileSelector; | |
| 753 | + fileSelector.setExtraSelectors(FileUtils::getFileSelectors()); | |
| 754 | + auto skyboxUrl = fileSelector.select(PathUtils::resourcesPath() + "images/Default-Sky-9-cubemap.ktx"); | |
| 732 | 755 | |
| 733 | − _defaultSkyboxTexture = gpu::Texture::unserialize(skyboxUrl); | |
| 756 | + _defaultSkyboxTexture = gpu::Texture::unserialize(skyboxUrl.toStdString()); | |
| 734 | 757 | _defaultSkyboxAmbientTexture = _defaultSkyboxTexture; |
| 735 | 758 | |
| 736 | 759 | _defaultSkybox->setCubemap(_defaultSkyboxTexture); |
| @@ -741,12 +764,12 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { · 4 unmodified lines | ||
| 741 | 764 | if (lightStage) { |
| 742 | 765 | |
| 743 | 766 | // Allocate a default global light directional and ambient |
| 744 | − auto lp = std::make_shared<model::Light>(); | |
| 745 | − lp->setType(model::Light::SUN); | |
| 767 | + auto lp = std::make_shared<graphics::Light>(); | |
| 768 | + lp->setType(graphics::Light::SUN); | |
| 746 | 769 | lp->setDirection(glm::vec3(-1.0f)); |
| 747 | 770 | lp->setColor(glm::vec3(1.0f)); |
| 748 | 771 | lp->setIntensity(1.0f); |
| 749 | − lp->setType(model::Light::SUN); | |
| 772 | + lp->setType(graphics::Light::SUN); | |
| 750 | 773 | lp->setAmbientSpherePreset(gpu::SphericalHarmonics::Preset::OLD_TOWN_SQUARE); |
| 751 | 774 | |
| 752 | 775 | lp->setAmbientIntensity(0.5f); |
| @@ -760,14 +783,15 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { · 7 unmodified lines | ||
| 760 | 783 | _defaultLight = lp; |
| 761 | 784 | |
| 762 | 785 | // Add the global light to the light stage (for later shadow rendering) |
| 763 | − _defaultLightID = lightStage->addLight(lp); | |
| 786 | + // Set this light to be the default | |
| 787 | + _defaultLightID = lightStage->addLight(lp, true); | |
| 764 | 788 | lightStage->addShadow(_defaultLightID); |
| 765 | 789 | } |
| 766 | 790 | |
| 767 | 791 | auto backgroundStage = renderContext->_scene->getStage<BackgroundStage>(); |
| 768 | 792 | if (backgroundStage) { |
| 769 | 793 | |
| 770 | − auto background = std::make_shared<model::SunSkyStage>(); | |
| 794 | + auto background = std::make_shared<graphics::SunSkyStage>(); | |
| 771 | 795 | background->setSkybox(_defaultSkybox); |
| 772 | 796 | |
| 773 | 797 | // capture deault background |
| @@ -782,7 +806,7 @@ void DefaultLightingSetup::run(const RenderContextPointer& renderContext) { · 8 unmodified lines | ||
| 782 | 806 | auto hazeStage = renderContext->_scene->getStage<HazeStage>(); |
| 783 | 807 | if (hazeStage) { |
| 784 | 808 | |
| 785 | − auto haze = std::make_shared<model::Haze>(); | |
| 809 | + auto haze = std::make_shared<graphics::Haze>(); | |
| 786 | 810 | |
| 787 | 811 | _defaultHaze = haze; |
| 788 | 812 | _defaultHazeID = hazeStage->addHaze(_defaultHaze); |