void HdxColorCorrectionTask::Sync(HdSceneDelegate* delegate, HdTaskContext* ctx, HdDirtyBits* dirtyBits) { HD_TRACE_FUNCTION(); HF_MALLOC_TAG_FUNCTION(); if ((*dirtyBits) & HdChangeTracker::DirtyParams) { HdxColorCorrectionTaskParams params; if (_GetTaskParams(delegate, ¶ms)) { _framebufferSize = params.framebufferSize; _colorCorrectionMode = params.colorCorrectionMode; _displayOCIO = params.displayOCIO; _viewOCIO = params.viewOCIO; _colorspaceOCIO = params.colorspaceOCIO; _looksOCIO = params.looksOCIO; _lut3dSizeOCIO = params.lut3dSizeOCIO; // Rebuild shader with new OCIO settings / shader-code. _shaderProgram.reset(); } } *dirtyBits = HdChangeTracker::Clean; }
void HdxShadowTask::Sync(HdSceneDelegate* delegate, HdTaskContext* ctx, HdDirtyBits* dirtyBits) { HD_TRACE_FUNCTION(); HF_MALLOC_TAG_FUNCTION(); GLF_GROUP_FUNCTION(); // Extract the lighting context information from the task context GlfSimpleLightingContextRefPtr lightingContext; if (!_GetTaskContextData(ctx, HdxTokens->lightingContext, &lightingContext)) { return; } GlfSimpleLightVector const glfLights = lightingContext->GetLights(); GlfSimpleShadowArrayRefPtr const shadows = lightingContext->GetShadows(); HdRenderIndex &renderIndex = delegate->GetRenderIndex(); const bool dirtyParams = (*dirtyBits) & HdChangeTracker::DirtyParams; if (dirtyParams) { // Extract the new shadow task params from exec if (!_GetTaskParams(delegate, &_params)) { return; } } if (!renderIndex.IsSprimTypeSupported(HdPrimTypeTokens->simpleLight)) { return; } // Iterate through all lights and for those that have shadows enabled // and ensure we have enough passes to render the shadows. size_t passCount = 0; for (size_t lightId = 0; lightId < glfLights.size(); lightId++) { const HdStLight* light = static_cast<const HdStLight*>( renderIndex.GetSprim(HdPrimTypeTokens->simpleLight, glfLights[lightId].GetID())); if (!glfLights[lightId].HasShadow()) { continue; } // It is possible the light is nullptr for area lights converted to // simple lights, however they should not have shadows enabled. TF_VERIFY(light); // Extract the collection from the HD light VtValue vtShadowCollection = light->Get(HdLightTokens->shadowCollection); const HdRprimCollection &col = vtShadowCollection.IsHolding<HdRprimCollection>() ? vtShadowCollection.Get<HdRprimCollection>() : HdRprimCollection(); // Creates or reuses a pass with the right geometry that will be // used during Execute phase to draw the shadow maps. if (passCount < _passes.size()) { // Note here that we may want to sort the passes by collection // to invalidate fewer passes if the collections match already. // SetRprimCollection checks for identity changes on the collection // and no-ops in that case. _passes[passCount]->SetRprimCollection(col); } else { // Create a new pass if we didn't have enough already, HdRenderPassSharedPtr p = boost::make_shared<HdSt_RenderPass> (&renderIndex, col); _passes.push_back(p); } passCount++; } // Shrink down to fit to conserve resources // We may want hysteresis here if we find the count goes up and down // frequently. if (_passes.size() > passCount) { _passes.resize(passCount); } // Shrink down to fit to conserve resources if (_renderPassStates.size() > _passes.size()) { _renderPassStates.resize(_passes.size()); } // Ensure all passes have the right params set. if (dirtyParams) { TF_FOR_ALL(it, _renderPassStates) { _UpdateDirtyParams(*it, _params); } }