void VPostProcessFXAA::SetupContext() { VRendererNodeCommon *pRendererNode = GetOwner(); VASSERT(pRendererNode != NULL && "Postprocessing effects require a valid renderer node!"); VisRenderContext_cl *pRefContext = pRendererNode->GetReferenceContext(); GetOwner()->AddContext(GetTargetContext()); GetTargetContext()->SetName("FXAA:Output"); m_spSourceTextures[0] = pRendererNode->GetGBuffer(IVRendererNode::VGBT_Accumulation); m_iNumSourceTextures = 1; VASSERT(m_spSourceTextures[0] != NULL); }
void VSimpleCopyPostprocess::SetupContext() { VASSERT_MSG(GetOwner() != NULL, "Postprocessing effects require a valid renderer node!"); GetOwner()->AddContext(GetTargetContext()); m_spSourceTextures[0] = GetOwner()->GetGBuffer(IVRendererNode::VGBT_Accumulation); m_iNumSourceTextures = 1; VASSERT(m_spSourceTextures[0] != NULL); }
void VPostProcessScreenMasks::SetupContext() { VASSERT_MSG(vdynamic_cast<VRendererNodeCommon*>(m_pOwner) != NULL, "Postprocessing effects require a valid renderer node!"); VRendererNodeCommon* pRenderNode = GetOwner(); VisRenderContext_cl* pTargetContext = GetTargetContext(); pTargetContext->SetVisibilityCollector(NULL); // no visibility collector is needed for this post processor pRenderNode->AddContext(pTargetContext); }
void VPostProcessTranslucencies::InitializePostProcessor() { if (m_bIsInitialized) return; GetTargetContext()->SetRenderFlags(VIS_RENDERCONTEXT_FLAG_SHOW_DEBUGOUTPUT|VIS_RENDERCONTEXT_FLAG_RENDER_CORONAS|VIS_RENDERCONTEXT_FLAG_RENDER_LENSFLARES); GetTargetContext()->SetName("Translucency"); #ifdef _VISION_PSP2 GetTargetContext()->ForceDepthStencilSurfaceLoad(true); #endif GetOwner()->AddContext(GetTargetContext()); m_TempParticleGroupCollection = new VisParticleGroupCollection_cl(512, 512); m_TempMeshBufferObjectCollection = new VisMeshBufferObjectCollection_cl(512, 512); Vision::Shaders.LoadShaderLibrary("\\Shaders\\BaseShaders.ShaderLib", SHADERLIBFLAG_HIDDEN); m_spForegroundMaskTechnique = Vision::Shaders.CreateTechnique("BS_ForeGroundMask", NULL); VASSERT(m_spForegroundMaskTechnique!=NULL); m_spForegroundFillPassTechnique = Vision::Shaders.CreateTechnique("BS_ForeGroundFill",NULL); VASSERT(m_spForegroundFillPassTechnique!=NULL); #if defined(_VISION_MOBILE) || defined(_VISION_PSP2) if(m_bQuarterSizeParticles) hkvLog::Warning("Quarter size particles are not supported on mobile platforms"); m_bQuarterSizeParticles = false; #else if (m_bQuarterSizeParticles) { CreateQuarterSizeShadersAndContext(); } #endif m_bIsInitialized = true; }
void VPostProcessTranslucencies::DeInitializePostProcessor() { if (!m_bIsInitialized) return; V_SAFE_DELETE(m_TempParticleGroupCollection); V_SAFE_DELETE(m_TempMeshBufferObjectCollection); #if !defined(_VISION_MOBILE) && !defined(_VISION_PSP2) m_spLowResContext = NULL; m_spLowResDepthTexture = NULL; m_spLowResColorTexture = NULL; #endif GetOwner()->RemoveContext(GetTargetContext()); m_bIsInitialized = false; }
void VSimpleCopyPostprocess::RemoveContext() { GetOwner()->RemoveContext(GetTargetContext()); }
void VPostProcessScreenMasks::RemoveContext() { GetOwner()->RemoveContext(GetTargetContext()); }
void VPostProcessFXAA::InitializePostProcessor() { if (m_bIsInitialized || !m_bActive) return; SetupContext(); // Load glow shader library BOOL bResult = Vision::Shaders.LoadShaderLibrary("\\Shaders\\FXAA.ShaderLib", SHADERLIBFLAG_HIDDEN) != NULL; VASSERT(bResult); // file not found? GetTargetContext()->GetSize(m_iWidth, m_iHeight); m_spMask = new VisScreenMask_cl(); m_spMask->SetPos(0,0); m_spMask->SetTargetSize((float)m_iWidth,(float)m_iHeight); m_spMask->SetTextureRange(0.0f, 0.0f, (float)m_iWidth, (float)m_iHeight); #ifdef _VR_DX9 m_spMask->SetUseOpenGLTexelShift(TRUE); #else m_spMask->SetUseOpenGLTexelShift(FALSE); #endif //m_spMask->SetUseOpenGLTexelShift(FALSE); m_spMask->SetTransparency(VIS_TRANSP_NONE); m_spMask->SetVisible(FALSE); m_spMask->SetDepthWrite(FALSE); m_spMask->SetWrapping(FALSE, FALSE); m_spMask->SetVisibleBitmask(0); // this mask is rendered manually via a collection // no wireframe for this mask VSimpleRenderState_t s = m_spMask->GetRenderState(); s.SetFlag(RENDERSTATEFLAG_NOWIREFRAME); m_spMask->SetRenderState(s); VTechniqueConfig vc; VString tags; tags.Format("FXAA_PRESET=%d", (int)Quality); vc.SetInclusionTags(tags); VCompiledTechnique *pTech = Vision::Shaders.CreateTechnique("FXAA", NULL, &vc, EFFECTFLAGS_FORCEUNIQUE); VASSERT(pTech!=NULL && "Could not create technique for FXAA postprocessor!"); m_spMask->SetTechnique(pTech); m_spMask->SetTransparency(VIS_TRANSP_NONE); VShaderConstantBuffer *pPS = pTech->GetShader(0)->GetConstantBuffer(VSS_PixelShader); m_iRegScreenSize = pPS->GetRegisterByName("rcpFrame"); // make frame copy only if this is not the last PP bool bFrameCopy = !IsLastComponent(); if (bFrameCopy && GetTargetContext()->GetRenderTarget() == m_spSourceTextures[0]) { m_spFrameCopyTexture = ScratchTexturePool_cl::GlobalManager().GetScratchTexture(m_iWidth, m_iHeight, m_spSourceTextures[0]->GetTextureFormat(), 0); m_spMask->SetTextureObject(m_spFrameCopyTexture); } else { m_spFrameCopyTexture = NULL; m_spMask->SetTextureObject(m_spSourceTextures[0]); } m_bIsInitialized = true; }
void VPostProcessFXAA::RemoveContext() { GetOwner()->RemoveContext(GetTargetContext()); }