void InstantRadiosity::renderShadowMaps(MeshWithColors *scene) { // YOUR CODE HERE // Loop through all lights, and call the shadow map renderer for those that are enabled. // (see App::renderFrame for an example usage of the SM rendering call) for (auto iter = m_indirectLights.begin(); iter != m_indirectLights.end(); ++iter) { if (iter->isEnabled()) iter->renderShadowMap(m_gl, scene, &m_smContext); } }
void Game::draw() { deviceContext->ClearRenderTargetView(renderTargetView, color); deviceContext->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); renderShadowMap(); drawAllGameObjects(); // render volumetric light(s) HR(swapChain->Present(0, 0)); }
void IndexedDirectionalLightRenderer::render( Renderer& renderer, const DirectionalLight* light, const IndexedLightingRenderData& data, int lightIdx ) { if ( !m_lightingShader ) { return; } // first - render a shadow map, if this light is set to cast shadows bool drawShadows = light->castsShadows(); if ( drawShadows ) { renderShadowMap( renderer, light, data ); } // and now render the light contribution renderLighting( renderer, light, data, drawShadows, lightIdx ); }
void DeferredSpotLightsPass::render(IViewer* viewer, World& world, const SceneContext& sceneContext, unsigned int lightMapFrameBuffer, const DeferredInitRenderStage& initStage) { GraphicsInterface::beginPerformanceEvent("Spot"); { // Shadow Map std::vector<SpotLight*> spotLights = sceneContext.spotLights(); for (std::vector<SpotLight*>::iterator light = spotLights.begin(); light != spotLights.end(); ++light) { if ((*light)->castsShadows()) { SpotLight* spotLight = (*light); renderShadowMap(spotLight, world); } } } { // Lighting std::vector<SpotLight*> spotLights = sceneContext.spotLights(); for (std::vector<SpotLight*>::iterator light = spotLights.begin(); light != spotLights.end(); ++light) { GraphicsInterface::beginPerformanceEvent("Light"); SpotLight* spotLight = (*light); { // render lighting IEffect* lightEffect = (*light)->castsShadows() ? lightEffectShadow_ : lightEffectNoShadow_; renderLight(spotLight, lightEffect, viewer, initStage.normalViewSpaceMap()); } { // accumulate into lightmap accumulateLight(spotLight, initStage.colorMap(), lightMapFrameBuffer); } GraphicsInterface::endPerformanceEvent(); } } GraphicsInterface::endPerformanceEvent(); }
// renderStage0 - Render distant land at beginning of scene 0, after sky void DistantLand::renderStage0() { DECLARE_MWBRIDGE IDirect3DStateBlock9 *stateSaved; UINT passes; // Get Morrowind camera matrices device->GetTransform(D3DTS_VIEW, &mwView); device->GetTransform(D3DTS_PROJECTION, &mwProj); // Set variables derived from current camera configuration setView(&mwView); adjustFog(); setupCommonEffect(&mwView, &mwProj); // Select distant static set selectDistantCell(); isRenderCached &= (Configuration.MGEFlags & USE_MENU_CACHING) && mwBridge->IsMenu(); if(!isRenderCached) { ///LOG::logline("Sky prims: %d", recordSky.size()); if(isDistantCell()) { // Save state block manually since we can change FVF/decl device->CreateStateBlock(D3DSBT_ALL, &stateSaved); effect->BeginPass(PASS_SETUP); effect->EndPass(); // Shadow map early render if(Configuration.MGEFlags & USE_SHADOWS) { if(mwBridge->CellHasWeather() && !mwBridge->IsMenu()) { effectShadow->Begin(&passes, D3DXFX_DONOTSAVESTATE); renderShadowMap(); effectShadow->End(); } } // Distant everything; bias the projection matrix such that // distant land gets drawn behind anything Morrowind would draw D3DXMATRIX distProj = mwProj; distProj._33 += kDistantZBias; effect->SetMatrix(ehProj, &distProj); effect->Begin(&passes, D3DXFX_DONOTSAVESTATE); if(!mwBridge->IsUnderwater(eyePos.z)) { // Draw distant landscape if(mwBridge->IsExterior()) { effect->BeginPass(PASS_RENDERLAND); renderDistantLand(effect, &mwView, &distProj); effect->EndPass(); } // Draw distant statics, with alpha dissolve as they pass the near view boundary DWORD p = mwBridge->CellHasWeather() ? PASS_RENDERSTATICSEXTERIOR : PASS_RENDERSTATICSINTERIOR; effect->SetFloat(ehDissolveRange, 7168.0); effect->BeginPass(p); cullDistantStatics(&mwView, &distProj); renderDistantStatics(); effect->EndPass(); } // Sky scattering and sky objects (should be drawn late as possible) if((Configuration.MGEFlags & USE_ATM_SCATTER) && mwBridge->CellHasWeather()) { effect->BeginPass(PASS_RENDERSKY); renderSky(); effect->EndPass(); } // Update reflection if(mwBridge->CellHasWater()) renderWaterReflection(&mwView, &distProj); // Update water simulation if(Configuration.MGEFlags & DYNAMIC_RIPPLES) simulateDynamicWaves(); effect->End(); // Reset matrices effect->SetMatrix(ehView, &mwView); effect->SetMatrix(ehProj, &mwProj); // Save distant land only frame to texture if(~Configuration.MGEFlags & NO_MW_MGE_BLEND) texDistantBlend = PostShaders::borrowBuffer(1); // Restore render state stateSaved->Apply(); stateSaved->Release(); } else { // Clear water reflection to avoid seeing previous cell environment reflected // Must be done every frame to react to lighting changes clearReflection(); // Update water simulation if(Configuration.MGEFlags & DYNAMIC_RIPPLES) { // Save state block manually since we can change FVF/decl device->CreateStateBlock(D3DSBT_ALL, &stateSaved); effect->Begin(&passes, D3DXFX_DONOTSAVESTATE); simulateDynamicWaves(); effect->End(); // Restore render state stateSaved->Apply(); stateSaved->Release(); } } } // Clear stray recordings recordMW.clear(); recordSky.clear(); }