void PostProcessVolumetricLight::BlurVolumetricLight( const float2 & lightPosUV, const Ptr<Texture> & linearDepthTex, const Ptr<Texture> & volumetricLightTex, const Ptr<RenderTargetView> & target) { auto ps = Shader::FindOrCreate<BlurVolumetricLightPS>(); ps->SetScalar("lightPosUV", lightPosUV); ps->SetScalar("texSize", volumetricLightTex->GetTexSize()); ps->SetSRV("volumetricLightTex", volumetricLightTex->GetShaderResourceView()); ps->SetSRV("linearDepthTex", linearDepthTex->GetShaderResourceView()); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->SetSampler("linearSampler", SamplerTemplate<>::Get()); ps->Flush(); Global::GetRenderEngine()->GetRenderContext()->SetBlendState(BlendStateTemplate<false, false, true, BLEND_PARAM_ONE, BLEND_PARAM_ONE, BLEND_OP_ADD>::Get()); DrawQuad({ target }); Global::GetRenderEngine()->GetRenderContext()->SetBlendState(nullptr); }
PooledTextureRef ImageBasedLensFlare::Setup(const Ptr<Texture> & brightPassTex) { auto setupTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, brightPassTex->GetDesc() }); auto setupTex = setupTexRef->Get()->Cast<Texture>(); Global::GetRenderEngine()->GetRenderContext()->ClearRenderTarget(setupTex->GetRenderTargetView(0, 0, 1), 0.0f); auto ps = Shader::FindOrCreate<LensFlareSetupPS>(); Global::GetRenderEngine()->GetRenderContext()->SetBlendState( BlendStateTemplate<false, false, true, BLEND_PARAM_ONE, BLEND_PARAM_ONE, BLEND_OP_ADD>::Get()); int2 texSize = int2(setupTex->GetDesc().width / 2, setupTex->GetDesc().height / 2); int2 center = texSize; for (int i = 0; i < 3; ++i) { int2 xy = center - texSize / 2; ps->SetSRV("brightPassTex", brightPassTex->GetShaderResourceView()); ps->SetSampler("linearSampler", SamplerTemplate<>::Get()); ps->Flush(); DrawQuad({ setupTex->GetRenderTargetView(0, 0, 1) }, (float)xy.x(), (float)xy.y(), (float)texSize.x(), (float)texSize.y()); texSize /= 2; } for (int i = 0; i < 5; ++i) { int2 xy = center - texSize / 2; ps->SetSRV("brightPassTex", brightPassTex->GetShaderResourceView()); ps->SetSampler("linearSampler", SamplerTemplate<>::Get()); ps->Flush(); DrawQuad({ setupTex->GetRenderTargetView(0, 0, 1) }, (float)xy.x(), (float)xy.y(), (float)texSize.x(), (float)texSize.y(), 1.0f, 1.0f, -1.0f, -1.0f); texSize *= 2; } Global::GetRenderEngine()->GetRenderContext()->SetBlendState(nullptr); return setupTexRef; }
Ptr<Texture> HeightToBumpTex(const Ptr<Texture> & heightTex, float scale) { auto bumpTexDesc = heightTex->GetDesc(); bumpTexDesc.format = RENDER_FORMAT_R8G8B8A8_UNORM; bumpTexDesc.bindFlag = TEXTURE_BIND_SHADER_RESOURCE | TEXTURE_BIND_RENDER_TARGET | TEXTURE_BIND_GENERATE_MIPS; bumpTexDesc.mipLevels = 0; auto bumpTex = Global::GetRenderEngine()->GetRenderFactory()->CreateTexture(TEXTURE_2D); bumpTex->SetDesc(bumpTexDesc); bumpTex->Init(); auto ps = Shader::FindOrCreate<HeightToBumpPS>(); ps->SetScalar("texSize", heightTex->GetTexSize()); ps->SetScalar("scale", scale); ps->SetSRV("heightTex", heightTex->GetShaderResourceView()); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); DrawQuad({ bumpTex->GetRenderTargetView(0, 0, 1) }); bumpTex->GenerateMips(); return bumpTex; }
String ShininessToRoughnessTex(const String & path) { auto roughnessTexPath = path.substr(0, path.rfind('.')) + "_roughness" + TextureAsset::GetExtension(); if (Global::GetPlatform()->FileExists(roughnessTexPath)) return roughnessTexPath; auto shininessTexAsset = Asset::Find<TextureAsset>(path); if (!shininessTexAsset->IsInit()) { shininessTexAsset->Init(); auto roughnessTexDesc = shininessTexAsset->GetTexture()->GetDesc(); roughnessTexDesc.bindFlag = TEXTURE_BIND_SHADER_RESOURCE | TEXTURE_BIND_RENDER_TARGET | TEXTURE_BIND_GENERATE_MIPS; roughnessTexDesc.mipLevels = 0; auto roughnessTex = Global::GetRenderEngine()->GetRenderFactory()->CreateTexture(TEXTURE_2D); roughnessTex->SetDesc(roughnessTexDesc); roughnessTex->Init(); auto ps = Shader::FindOrCreate<ShininessToRoughnessPS>(); ps->SetSRV("shininessTex", shininessTexAsset->GetTexture()->GetShaderResourceView(0, 1, 0, 1)); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); DrawQuad({ roughnessTex->GetRenderTargetView(0, 0, 1) }); auto roughnessTexAsset = std::make_shared<TextureAsset>(); roughnessTexAsset->SetPath(roughnessTexPath); roughnessTexAsset->Register(); roughnessTexAsset->Save(); } return roughnessTexPath; }
PooledTextureRef SSR::SSRNeighborShare( const Ptr<RenderView> & view, const Ptr<Texture> & ssrResult, const Ptr<Texture> & gbuffer1, const Ptr<Texture> & depthTex, const Ptr<Texture> & ssrStencilMask) { auto resultTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, ssrResult->GetDesc() }); auto resultTex = resultTexRef->Get()->Cast<Texture>(); auto ps = Shader::FindOrCreate<SSRNeighborSharePS>(); view->BindShaderParams(ps); ps->SetScalar("texSize", ssrResult->GetTexSize()); ps->SetSRV("ssrTex", ssrResult->GetShaderResourceView()); ps->SetSRV("gbuffer1", gbuffer1->GetShaderResourceView()); ps->SetSRV("depthTex", depthTex->GetShaderResourceView(0, 0, 0, 0, false, RENDER_FORMAT_R24_UNORM_X8_TYPELESS)); ps->SetSampler("pointClampSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); DrawQuad({ resultTex->GetRenderTargetView(0, 0, 1) }, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, ssrStencilMask->GetDepthStencilView(0, 0, 1, RENDER_FORMAT_D24_UNORM_S8_UINT)); return resultTexRef; }
CUresult CuModule::FindTexRef(const std::string& name, CuModule::TexBind** ppTexBind) { for(size_t i(0); i < _textures.size(); ++i) if(name == _textures[i].name) { *ppTexBind = &_textures[i]; return CUDA_SUCCESS; } CUtexref texRef; CUresult result = cuModuleGetTexRef(&texRef, _module, name.c_str()); HANDLE_RESULT(); TexBind texBind; texBind.texRef = texRef; texBind.name = name; memset(&texBind.sampler, -1, sizeof(CuTexSamplerAttr)); _textures.push_back(texBind); CuTexSamplerAttr sampler; sampler.addressX = CU_TR_ADDRESS_MODE_WRAP; sampler.addressY = CU_TR_ADDRESS_MODE_WRAP; sampler.addressZ = CU_TR_ADDRESS_MODE_WRAP; sampler.filter = CU_TR_FILTER_MODE_LINEAR; sampler.fmt = CU_AD_FORMAT_UNSIGNED_INT8; sampler.numPackedComponents = 4; sampler.normCoord = true; sampler.readAsInteger = false; SetSampler(&_textures.back(), sampler); *ppTexBind = &_textures.back(); return CUDA_SUCCESS; }
static void GenTexture( const SDL_Surface * surface, const TextureInfo & info, unsigned & id, bool & alpha, std::ostream & error) { // detect channels int internalformat, format; GetTextureFormat(surface, info, internalformat, format, alpha); // gen texture glGenTextures(1, &id); CheckForOpenGLErrors("Texture ID generation", error); // init texture glBindTexture(GL_TEXTURE_2D, id); SetSampler(info); glTexImage2D(GL_TEXTURE_2D, 0, internalformat, surface->w, surface->h, 0, format, GL_UNSIGNED_BYTE, surface->pixels); CheckForOpenGLErrors("Texture creation", error); // If we support generatemipmap, go ahead and do it regardless of the info.mipmap setting. // In the GL3 renderer the sampler decides whether or not to do mip filtering, so we conservatively make mipmaps available for all textures. GenerateMipmap(GL_TEXTURE_2D); }
void BilateralBlur( const Ptr<ShaderResourceView> & src, const Ptr<RenderTargetView> & dst, const Ptr<ShaderResourceView> & depthTex, const std::vector<float> & weights, float depthDiffThreshold) { auto srcTex = src->GetResource()->Cast<Texture>(); auto tmpTexDesc = dst->GetResource()->Cast<Texture>()->GetDesc(); auto tmpTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, tmpTexDesc }); { auto ps = Shader::FindOrCreate<BilateralBlurXPS>(); ps->SetScalar("bilateralBlurWeights", &weights[0], (int32_t)(sizeof(float) * weights.size())); ps->SetScalar("texSize", srcTex->GetTexSize()); ps->SetScalar("depthDiffThreshold", depthDiffThreshold); ps->SetSRV("bilateralDepthTex", depthTex); ps->SetSRV("bilateralBlurInTex", src); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); DrawQuad({ tmpTexRef->Get()->Cast<Texture>()->GetRenderTargetView(0, 0, 1) }); } { auto ps = Shader::FindOrCreate<BilateralBlurYPS>(); ps->SetScalar("bilateralBlurWeights", &weights[0], (int32_t)(sizeof(float) * weights.size())); ps->SetScalar("texSize", srcTex->GetTexSize()); ps->SetScalar("depthDiffThreshold", depthDiffThreshold); ps->SetSRV("bilateralDepthTex", depthTex); ps->SetSRV("bilateralBlurInTex", tmpTexRef->Get()->Cast<Texture>()->GetShaderResourceView()); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); DrawQuad({ dst }); } }
void ToneMapping::DoToneMapping( const Ptr<Texture> & scene, const Ptr<Texture> & bloomTex, const Ptr<Texture> & adaptedExposureScale, const Ptr<Texture> & lut, const Ptr<RenderTargetView> & target) { auto ps = Shader::FindOrCreate<ToneMappingPS>(); ps->SetScalar("gamma", Global::GetRenderEngine()->GetGamma()); ps->SetSRV("sceneTex", scene->GetShaderResourceView()); ps->SetSRV("bloomTex", bloomTex->GetShaderResourceView()); ps->SetSRV("adaptedExposureScale", adaptedExposureScale->GetShaderResourceView()); ps->SetSRV("toneMappingLUT", lut->GetShaderResourceView()); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->SetSampler("linearSampler", SamplerTemplate<>::Get()); ps->Flush(); DrawQuad({ target }); }
void CubeMapToHemiPnoramic(const Ptr<Texture> & cubeMap, const Ptr<Texture> & targetPanoramic) { auto ps = Shader::FindOrCreate<CubeMapToHemiPanoramicPS>(); ps->SetSRV("cubeMap", cubeMap->GetShaderResourceView(0, 0, 0, 0, true)); ps->SetSampler("inSampler", SamplerTemplate<>::Get()); ps->Flush(); DrawQuad({ targetPanoramic->GetRenderTargetView(0, 0, 1) }); }
void LinearizeDepth(const Ptr<ShaderResourceView> & depth, const Ptr<RenderView> & view, const Ptr<RenderTargetView> & target) { auto ps = Shader::FindOrCreate<LinearizeDepthPS>(); view->BindShaderParams(ps); ps->SetSRV("depthTex", depth); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); DrawQuad({ target }); }
PooledTextureRef ImageBasedLensFlare::BrightPass(const Ptr<Texture> & sceneTex) { auto brightPassTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, sceneTex->GetDesc() }); auto ps = Shader::FindOrCreate<LensBlurBrightPassPS>(); ps->SetScalar("brightPassThreshold", _brightPassThreshold); ps->SetSRV("sceneTex", sceneTex->GetShaderResourceView()); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); DrawQuad({ brightPassTexRef->Get()->Cast<Texture>()->GetRenderTargetView(0, 0, 1) }); return brightPassTexRef; }
CUresult CuModule::BindArrayTexture(const std::string& name, CuTexture* texture, const CuTexSamplerAttr& sampler) { TexBind* texBind; CUresult result = FindTexRef(name, &texBind); HANDLE_RESULT(); SetSampler(texBind, sampler); result = cuTexRefSetArray(texBind->texRef, texture->Handle(), 0); HANDLE_RESULT(); texBind->texture = texture; texBind->mem.reset(); return CUDA_SUCCESS; }
void FFT::FFTSetup( const Ptr<Texture> & src, int32_t srcMipLevel, int32_t srcArrayOffset, const Ptr<Texture> & dst, int32_t dstMipLevel, int32_t dstArrayOffset) { auto ps = Shader::FindOrCreate<FFTSetupPS>(); ps->SetSRV("srcTex", src->GetShaderResourceView(srcMipLevel, 1, srcArrayOffset, 1)); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); DrawQuad({ dst->GetRenderTargetView(dstMipLevel, dstArrayOffset, 1) }); }
void Transform( const Ptr<ShaderResourceView> & src, const Ptr<RenderTargetView> & dst, const Vector<ColorWriteMask, 4> & colorWriteMask, const float4 & srcRect, const float4 & dstRect, const Ptr<class Sampler> & sampler, const Ptr<DepthStencilView> & dsv ) { auto rc = Global::GetRenderEngine()->GetRenderContext(); std::map<String, String> macros; for (int32_t i = 0; i < 4; ++i) { auto & writeMask = colorWriteMask[i]; String writeChannel = std::to_string(static_cast<uint32_t>(std::log2(static_cast<uint32_t>(writeMask)))); macros["COLOR_CHANNEL_" + std::to_string(i)] = writeChannel; } auto transformPS = Shader::FindOrCreate<TransformPS>(macros); transformPS->SetSampler("transformSampler", sampler ? sampler : SamplerTemplate<>::Get()); transformPS->SetSRV("srcTex", src); transformPS->Flush(); auto srcTex = src->GetResource()->Cast<Texture>(); float topLeftU = srcRect.x() / static_cast<float>(srcTex->GetDesc().width); float topLeftV = srcRect.y() / static_cast<float>(srcTex->GetDesc().height); float uvWidth = srcRect.z() / static_cast<float>(srcTex->GetDesc().width); float uvHeight = srcRect.w() / static_cast<float>(srcTex->GetDesc().height); if (uvWidth == 0.0f) uvWidth = 1.0f; if (uvHeight == 0.0f) uvHeight = 1.0f; DrawQuad({ dst }, dstRect.x(), dstRect.y(), dstRect.z(), dstRect.w(), topLeftU, topLeftV, uvWidth, uvHeight, dsv); }
PooledTextureRef SSR::BuildHZB(const Ptr<Texture> & depthTex) { auto texDesc = depthTex->GetDesc(); texDesc.format = RENDER_FORMAT_R16_FLOAT; texDesc.bindFlag = TEXTURE_BIND_SHADER_RESOURCE | TEXTURE_BIND_RENDER_TARGET; texDesc.mipLevels = 0; auto hzb0Ref = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc }); auto hzb1Ref = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc }); auto hzb0 = hzb0Ref->Get()->Cast<Texture>(); auto hzb1 = hzb1Ref->Get()->Cast<Texture>(); Transform( depthTex->GetShaderResourceView(0, 1, 0, 1, false, RENDER_FORMAT_R24_UNORM_X8_TYPELESS), hzb0Ref->Get()->Cast<Texture>()->GetRenderTargetView(0, 0, 1)); auto rc = Global::GetRenderEngine()->GetRenderContext(); auto ps = Shader::FindOrCreate<HZBBuildPS>(); for (int32_t mipLevel = 1; mipLevel < hzb0->GetDesc().mipLevels; ++mipLevel) { auto & mipSize = hzb0->GetMipSize(mipLevel - 1); auto w = mipSize.x(); auto h = mipSize.y(); float4 screenSize = float4((float)w, (float)h, 1.0f / (float)w, 1.0f / (float)h); ps->SetScalar("screenSize", screenSize); ps->SetScalar("mipLevel", (float)(mipLevel - 1)); ps->SetSRV("depthTex", hzb0->GetShaderResourceView()); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); auto & targetMipSize = hzb0->GetMipSize(mipLevel); DrawQuad({ hzb1->GetRenderTargetView(mipLevel, 0, 1) }); hzb1->CopyTo(hzb0, mipLevel, 0, 0, 0, 0, mipLevel, 0); } return hzb0Ref; }
void TextureFilter( const Ptr<ShaderResourceView> & src, const Ptr<RenderTargetView> & dst, const std::vector<float2> & uvOffsets, const std::vector<float> & weights, const Ptr<class Sampler> & sampler) { ToyGE_ASSERT(uvOffsets.size() == weights.size()); ToyGE_ASSERT(src); ToyGE_ASSERT(dst); int32_t numSamples = (int32_t)uvOffsets.size(); if (numSamples <= 0) return; auto rc = Global::GetRenderEngine()->GetRenderContext(); rc->SetViewport(GetTextureQuadViewport(dst->GetResource()->Cast<Texture>())); auto filterVS = Shader::FindOrCreate<FilterVS>({ { "NUM_SAMPLES", std::to_string(numSamples) } }); auto filterPS = Shader::FindOrCreate<FilterPS>({ { "NUM_SAMPLES", std::to_string(numSamples) } }); filterVS->SetScalar("samplesOffsets", &uvOffsets[0], (int32_t)(sizeof(uvOffsets[0]) * uvOffsets.size())); filterVS->Flush(); filterPS->SetScalar("samplesWeights", &weights[0], (int32_t)(sizeof(weights[0]) * weights.size())); filterPS->SetSRV("filterTex", src); filterPS->SetSampler("filterSampler", sampler ? sampler : SamplerTemplate<>::Get()); filterPS->Flush(); rc->SetRenderTargets({ dst }); rc->SetDepthStencil(nullptr); rc->SetDepthStencilState(DepthStencilStateTemplate<false>::Get()); rc->SetVertexBuffer({ GetQuadVBs()[0] }); rc->SetIndexBuffer(GetQuadIB()); rc->SetPrimitiveTopology(PRIMITIVE_TOPOLOGY_TRIANGLELIST); rc->DrawIndexed(0, 0); }
PooledTextureRef PostProcessVolumetricLight::Setup(const Ptr<Texture> & sceneTex, const Ptr<Texture> & linearDepthTex) { auto texDesc = sceneTex->GetDesc(); texDesc.width /= 2; texDesc.height /= 2; auto resultTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc }); auto resultTex = resultTexRef->Get()->Cast<Texture>(); auto ps = Shader::FindOrCreate<PPVolumeSetupPS>(); ps->SetSRV("sceneTex", sceneTex->GetShaderResourceView()); ps->SetSRV("linearDepthTex", linearDepthTex->GetShaderResourceView()); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); DrawQuad({ resultTex->GetRenderTargetView(0, 0, 1) }); return resultTexRef; }
PooledTextureRef ToneMapping::BrightPass(const Ptr<Texture> & sceneTex, const Ptr<Texture> & adaptedExposureScale) { auto texDesc = sceneTex->GetDesc(); texDesc.mipLevels = 1; texDesc.format = RENDER_FORMAT_R11G11B10_FLOAT; texDesc.bindFlag = TEXTURE_BIND_SHADER_RESOURCE | TEXTURE_BIND_RENDER_TARGET | TEXTURE_BIND_GENERATE_MIPS; auto brightPassTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc }); auto brightPassTex = brightPassTexRef->Get()->Cast<Texture>(); auto ps = Shader::FindOrCreate<BrightPassPS>(); ps->SetScalar("brightPassThreshold", _brightPassThreshold); ps->SetSRV("sceneTex", sceneTex->GetShaderResourceView()); ps->SetSRV("adaptedExposureScale", adaptedExposureScale->GetShaderResourceView()); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); DrawQuad({ brightPassTex->GetRenderTargetView(0, 0, 1) }); return brightPassTexRef; }
void SkyBox::Render(const Ptr<RenderTargetView> & target, const Ptr<DepthStencilView> & dsv, const Ptr<RenderView> & view) { if (!_tex) return; auto rc = Global::GetRenderEngine()->GetRenderContext(); auto translationMat = translation(view->GetCamera()->GetPos()); auto transformMat = mul(translationMat, view->GetCamera()->GetViewProjMatrix()); auto vs = Shader::FindOrCreate<SkyBoxVS>(); auto ps = Shader::FindOrCreate<SkyBoxPS>(); vs->SetScalar("transform", transformMat); ps->SetSRV("skyBoxTex", _tex->GetShaderResourceView(0, 0, 0, 0, true)); ps->SetSampler("linearSampler", SamplerTemplate<>::Get()); vs->Flush(); ps->Flush(); rc->SetViewport(GetTextureQuadViewport(target->GetResource()->Cast<Texture>())); rc->SetRenderTargets({ target }); rc->SetDepthStencil(dsv); rc->SetRasterizerState(RasterizerStateTemplate<FILL_SOLID, CULL_NONE>::Get()); rc->SetDepthStencilState(DepthStencilStateTemplate<true, DEPTH_WRITE_ZERO, COMPARISON_LESS_EQUAL>::Get()); rc->SetVertexBuffer(_sphereMesh->GetRenderData()->GetMeshElements()[0]->GetVertexBuffer()); rc->SetIndexBuffer(_sphereMesh->GetRenderData()->GetMeshElements()[0]->GetIndexBuffer()); rc->SetPrimitiveTopology(PRIMITIVE_TOPOLOGY_TRIANGLELIST); rc->DrawIndexed(0, 0); rc->SetRasterizerState(nullptr); rc->SetDepthStencilState(nullptr); }
void BilateralUpSampling( const Ptr<ShaderResourceView> & src, const Ptr<RenderTargetView> & dst, const Ptr<ShaderResourceView> & lowResDepthTex, const Ptr<ShaderResourceView> & highResDepthTex, float depthDiffThreshold) { auto srcTex = src->GetResource()->Cast<Texture>(); auto ps = Shader::FindOrCreate<BilateralUpSamplingPS>(); ps->SetScalar("texSize", srcTex->GetTexSize()); ps->SetScalar("depthDiffThreshold", depthDiffThreshold); ps->SetSRV("lowResDepthTex", lowResDepthTex); ps->SetSRV("highResDepthTex", highResDepthTex); ps->SetSRV("upSamplingInTex", src); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->Flush(); DrawQuad({ dst }); }
PooledTextureRef PostProcessVolumetricLight::RenderVolumetricLight(const float2 & lightPosUV, const Ptr<Texture> & setupTex) { auto resultTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, setupTex->GetDesc() }); auto resultTex = resultTexRef->Get()->Cast<Texture>(); auto ps = Shader::FindOrCreate<RadialBlurPS>(); ps->SetScalar("lightPosUV", lightPosUV); ps->SetScalar("density", _density); ps->SetScalar("intensity", _intensity); ps->SetScalar("decay", _decay); ps->SetScalar("frameCount", (uint32_t)Global::GetInfo()->frameCount); ps->SetSRV("sceneTex", setupTex->GetShaderResourceView()); ps->SetSampler("linearSampler", SamplerTemplate<>::Get()); ps->Flush(); DrawQuad({ resultTex->GetRenderTargetView(0, 0, 1) }); return resultTexRef; }
void FFT::FFT2DRadix2( const Ptr<Texture> & src, int32_t srcMipLevel, int32_t srcArrayOffset, const Ptr<Texture> & dst, int32_t dstMipLevel, int32_t dstArrayOffset, bool bInverse, bool bIFFTScale) { auto mipSize = src->GetMipSize(srcMipLevel); TextureDesc texDesc; texDesc.width = mipSize.x(); texDesc.height = mipSize.y(); texDesc.depth = 1; texDesc.bindFlag = TEXTURE_BIND_SHADER_RESOURCE | TEXTURE_BIND_RENDER_TARGET | TEXTURE_BIND_UNORDERED_ACCESS; texDesc.cpuAccess = 0; texDesc.format = RENDER_FORMAT_R32G32_FLOAT; texDesc.mipLevels = 1; texDesc.arraySize = 1; texDesc.bCube = false; texDesc.sampleCount = 1; texDesc.sampleQuality = 0; PooledTextureRef bfSrcRef; Ptr<Texture> bfSrc; int32_t bfSrcMipLevel = 0; int32_t bfSrcArrayOffset = 0; /*if (!bInverse) { bfSrcRef = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc }); bfSrc = bfSrcRef->Get()->Cast<Texture>(); FFT::FFTSetup(src, srcMipLevel, srcArrayOffset, bfSrc, 0, 0); } else*/ { bfSrc = src; bfSrcMipLevel = srcMipLevel; bfSrcArrayOffset = srcArrayOffset; } PooledTextureRef bfDstRef; Ptr<Texture> bfDst; int32_t bfDstMipLevel = 0; int32_t bfDstArrayOffset = 0; if (dst->GetDesc().bindFlag & TEXTURE_BIND_UNORDERED_ACCESS && dst->GetDesc().format == RENDER_FORMAT_R32G32_FLOAT) { bfDst = dst; bfDstMipLevel = dstMipLevel; bfDstArrayOffset = dstArrayOffset; } else { bfDstRef = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc }); bfDst = bfDstRef->Get()->Cast<Texture>(); } std::map<String, String> macros; macros["FFT_2D"] = ""; if (bInverse) { macros["FFT_INVERSE"] = ""; if (bIFFTScale) macros["FFT_INVERSE_SCALE"] = ""; } static int fftGroupSize = 64; macros["FFT_GROUP_SIZE"] = std::to_string(fftGroupSize); auto fftXCS = Shader::FindOrCreate<FFTRadix2_2D_XCS>(macros); auto fftYCS = Shader::FindOrCreate<FFTRadix2_2D_YCS>(macros); auto ifftScalePS = Shader::FindOrCreate<IFFTScalePS>(); float4 dataSize = float4((float)mipSize.x(), (float)mipSize.y(), 1.0f / (float)mipSize.x(), 1.0f / (float)mipSize.y()); auto rc = Global::GetRenderEngine()->GetRenderContext(); //Butterfly X { uint32_t numGroups = std::max<uint32_t>(1, texDesc.width / fftGroupSize / 2); uint32_t bfLen = 2; while (bfLen <= static_cast<uint32_t>(texDesc.width)) { fftXCS->SetScalar("dataSize", dataSize); fftXCS->SetScalar("butterflyLength", bfLen); fftXCS->SetSRV("srcTex", bfSrc->GetShaderResourceView(bfSrcMipLevel, 1, bfSrcArrayOffset, 1)); fftXCS->SetUAV("dstTex", bfDst->GetUnorderedAccessView(bfDstMipLevel, bfDstArrayOffset, 1)); fftXCS->Flush(); rc->Compute(numGroups, texDesc.height, 1); std::swap(bfSrc, bfDst); std::swap(bfSrcMipLevel, bfDstMipLevel); std::swap(bfSrcArrayOffset, bfDstArrayOffset); bfLen = bfLen << 1; } rc->ResetShader(SHADER_CS); if (bInverse && bIFFTScale) { float ifftScale = 1.0f / (float)texDesc.width; ifftScalePS->SetScalar("ifftScale", ifftScale); ifftScalePS->SetSRV("srcTex", bfSrc->GetShaderResourceView(bfSrcMipLevel, 1, bfSrcArrayOffset, 1)); ifftScalePS->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ifftScalePS->Flush(); DrawQuad({ bfDst->GetRenderTargetView(dstMipLevel, dstArrayOffset, 1) }); std::swap(bfSrc, bfDst); std::swap(bfSrcMipLevel, bfDstMipLevel); std::swap(bfSrcArrayOffset, bfDstArrayOffset); } } //Butterfly Y { uint32_t numGroups = std::max<uint32_t>(1, texDesc.height / fftGroupSize / 2); uint32_t bfLen = 2; while (bfLen <= static_cast<uint32_t>(texDesc.height)) { fftYCS->SetScalar("dataSize", dataSize); fftYCS->SetScalar("butterflyLength", bfLen); fftYCS->SetSRV("srcTex", bfSrc->GetShaderResourceView(bfSrcMipLevel, 1, bfSrcArrayOffset, 1)); fftYCS->SetUAV("dstTex", bfDst->GetUnorderedAccessView(bfDstMipLevel, bfDstArrayOffset, 1)); fftYCS->Flush(); rc->Compute(numGroups, texDesc.width, 1); std::swap(bfSrc, bfDst); std::swap(bfSrcMipLevel, bfDstMipLevel); std::swap(bfSrcArrayOffset, bfDstArrayOffset); bfLen = bfLen << 1; } rc->ResetShader(SHADER_CS); if (bInverse && bIFFTScale) { float ifftScale = 1.0f / texDesc.height; ifftScalePS->SetScalar("ifftScale", ifftScale); ifftScalePS->SetSRV("srcTex", bfSrc->GetShaderResourceView(bfSrcMipLevel, 1, bfSrcArrayOffset, 1)); ifftScalePS->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ifftScalePS->Flush(); DrawQuad({ bfDst->GetRenderTargetView(dstMipLevel, dstArrayOffset, 1) }); std::swap(bfSrc, bfDst); std::swap(bfSrcMipLevel, bfDstMipLevel); std::swap(bfSrcArrayOffset, bfDstArrayOffset); } } //Clear if (bfSrc != dst) //dst is result { bfSrc->CopyTo(dst, dstMipLevel, dstArrayOffset, 0, 0, 0, 0, 0); } }
bool Texture::LoadDDS(const std::string & path, const TextureInfo & info, std::ostream & error) { std::ifstream file(path.c_str(), std::ifstream::in | std::ifstream::binary); if (!file) return false; // test for dds magic value char magic[4]; file.read(magic, 4); if (!IsDDS(magic, 4)) return false; // get length of file: file.seekg (0, file.end); const unsigned long length = file.tellg(); file.seekg (0, file.beg); // read file into memory std::vector<char> data(length); file.read(&data[0], length); // load dds const char * texdata(0); unsigned long texlen(0); unsigned format(0), width(0), height(0), levels(0); if (!ReadDDS( (void*)&data[0], length, (const void*&)texdata, texlen, format, width, height, levels)) { return false; } // set properties m_w = width; m_h = height; m_scale = 1.0f; m_alpha = (format != GL_BGR); m_cube = false; // gl3 renderer expects srgb unsigned iformat = format; if (info.srgb) { if (format == GL_BGR) iformat = GL_SRGB8; else if (format == GL_BGRA) iformat = GL_SRGB8_ALPHA8; else if (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) iformat = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; else if (format == GL_COMPRESSED_RGBA_S3TC_DXT3_EXT) iformat = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; else if (format == GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) iformat = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; } // load texture assert(!m_id); glGenTextures(1, &m_id); CheckForOpenGLErrors("Texture ID generation", error); glBindTexture(GL_TEXTURE_2D, m_id); SetSampler(info, levels > 1); const char * idata = texdata; unsigned blocklen = 16 * texlen / (width * height); unsigned ilen = texlen; unsigned iw = width; unsigned ih = height; for (unsigned i = 0; i < levels; ++i) { if (format == GL_BGR || format == GL_BGRA) { // fixme: support compression here? ilen = iw * ih * blocklen / 16; glTexImage2D(GL_TEXTURE_2D, i, iformat, iw, ih, 0, format, GL_UNSIGNED_BYTE, idata); } else { ilen = std::max(1u, iw / 4) * std::max(1u, ih / 4) * blocklen; glCompressedTexImage2D(GL_TEXTURE_2D, i, iformat, iw, ih, 0, ilen, idata); } CheckForOpenGLErrors("Texture creation", error); idata += ilen; iw = std::max(1u, iw / 2); ih = std::max(1u, ih / 2); } // force mipmaps for GL3 if (levels == 1) GenerateMipmap(GL_TEXTURE_2D); return true; }
void ImageBasedLensFlare::LensBlur(const Ptr<Texture> & setupTex, const Ptr<Texture> & target) { int32_t tileSize = 9; //Extract Sprite Points int32_t extractWidth = (setupTex->GetDesc().width + tileSize - 1) / tileSize; int32_t extractHeight = (setupTex->GetDesc().height + tileSize - 1) / tileSize; RenderBufferDesc spPointsBufDesc; spPointsBufDesc.bindFlag = BUFFER_BIND_SHADER_RESOURCE | BUFFER_BIND_UNORDERED_ACCESS; spPointsBufDesc.elementSize = sizeof(float2) + sizeof(float3); spPointsBufDesc.numElements = extractWidth * extractHeight; spPointsBufDesc.cpuAccess = 0; spPointsBufDesc.bStructured = true; auto spPointsBufRef = BufferPool::Instance().FindFree(spPointsBufDesc); auto spPointsBuf = spPointsBufRef->Get()->Cast<RenderBuffer>(); { auto ps = Shader::FindOrCreate<ExtractSpritePointsPS>(); ps->SetScalar("spriteThreshold", _spriteThreshold); ps->SetSRV("setupTex", setupTex->GetShaderResourceView()); ps->SetUAV("spPointsBuf", spPointsBuf->GetUnorderedAccessView(0, 0, RENDER_FORMAT_UNKNOWN, BUFFER_UAV_APPEND)); ps->Flush(); DrawQuad({}, 0.0f, 0.0f, (float)extractWidth, (float)extractHeight); } //Render Sprites if (!_indirectAgsBuf) { RenderBufferDesc indirectArgsBufDesc; indirectArgsBufDesc.bindFlag = BUFFER_BIND_INDIRECT_ARGS; indirectArgsBufDesc.elementSize = 16; indirectArgsBufDesc.numElements = 1; indirectArgsBufDesc.cpuAccess = 0; indirectArgsBufDesc.bStructured = false; uint32_t initData[] = { 0, 1, 0, 0 }; _indirectAgsBuf = Global::GetRenderEngine()->GetRenderFactory()->CreateBuffer(); _indirectAgsBuf->SetDesc(indirectArgsBufDesc); _indirectAgsBuf->Init(initData); } spPointsBuf->CopyStructureCountTo(_indirectAgsBuf, 0, 0, spPointsBuf->GetDesc().numElements, RENDER_FORMAT_UNKNOWN, BUFFER_UAV_APPEND); { auto vs = Shader::FindOrCreate<LensBlurVS>(); auto gs = Shader::FindOrCreate<LensBlurGS>(); auto ps = Shader::FindOrCreate<LensBlurPS>(); vs->SetScalar("texSize", target->GetTexSize()); gs->SetScalar("texSize", target->GetTexSize()); gs->SetScalar("flareIntensity", _flareIntensity); vs->SetSRV("spPointsRenderBuf", spPointsBuf->GetShaderResourceView(0, 0, RENDER_FORMAT_UNKNOWN)); auto lensTexAsset = Asset::Find<TextureAsset>("Textures/Bokeh_Circle.dds"); if (!lensTexAsset->IsInit()) lensTexAsset->Init(); auto lensTex = lensTexAsset->GetTexture(); ps->SetSRV("lensTex", lensTex->GetShaderResourceView()); ps->SetSampler("linearSampler", SamplerTemplate<>::Get()); vs->Flush(); gs->Flush(); ps->Flush(); auto rc = Global::GetRenderEngine()->GetRenderContext(); rc->SetVertexBuffer({}); rc->SetIndexBuffer(nullptr); rc->SetPrimitiveTopology(PRIMITIVE_TOPOLOGY_POINTLIST); rc->SetViewport(GetTextureQuadViewport(target)); rc->SetRenderTargets({ target->GetRenderTargetView(0, 0, 1) }); rc->SetDepthStencil(nullptr); rc->SetDepthStencilState(DepthStencilStateTemplate<false>::Get()); rc->SetBlendState(BlendStateTemplate<false, false, true, BLEND_PARAM_SRC_ALPHA, BLEND_PARAM_ONE, BLEND_OP_ADD>::Get()); rc->DrawInstancedIndirect(_indirectAgsBuf, 0); rc->ResetShader(SHADER_GS); rc->SetBlendState(nullptr); } }
bool Texture::Load(const std::string & path, const TextureInfo & info, std::ostream & error) { if (texid) { error << "Tried to double load texture " << path << std::endl; return false; } if (!info.data && path.empty()) { error << "Tried to load a texture with an empty name" << std::endl; return false; } if (!info.data && LoadDDS(path, info, error)) { return true; } if (info.cube) { return LoadCube(path, info, error); } SDL_Surface * surface = 0; if (info.data) { Uint32 rmask, gmask, bmask, amask; #if SDL_BYTEORDER == SDL_BIG_ENDIAN rmask = 0xff000000; gmask = 0x00ff0000; bmask = 0x0000ff00; amask = 0x000000ff; #else rmask = 0x000000ff; gmask = 0x0000ff00; bmask = 0x00ff0000; amask = 0xff000000; #endif surface = SDL_CreateRGBSurfaceFrom( info.data, info.width, info.height, info.bytespp * 8, info.width * info.bytespp, rmask, gmask, bmask, amask); } else { surface = IMG_Load(path.c_str()); } if (!surface) { error << "Error loading texture file: " << path << std::endl; error << IMG_GetError() << std::endl; return false; } const unsigned char * pixels = (const unsigned char *)surface->pixels; const unsigned bytespp = surface->format->BytesPerPixel; unsigned pitch = surface->pitch; unsigned w = surface->w; unsigned h = surface->h; // downsample if requested by application std::vector<unsigned char> pixelsd; unsigned wd = w; unsigned hd = h; if (info.maxsize == TextureInfo::SMALL) { if (w > 256) wd = w / 4; else if (w > 128) wd = w / 2; if (h > 256) hd = h / 4; else if (h > 128) hd = h / 2; } else if (info.maxsize == TextureInfo::MEDIUM) { if (w > 256) wd = w / 2; if (h > 256) hd = h / 2; } if (wd < w || hd < h) { pixelsd.resize(wd * hd * bytespp); SampleDownAvg( bytespp, w, h, pitch, pixels, wd, hd, wd * bytespp, &pixelsd[0]); pixels = &pixelsd[0]; pitch = wd * bytespp; w = wd; h = hd; } // store dimensions width = w; height = h; target = GL_TEXTURE_2D; // gen texture glGenTextures(1, &texid); CheckForOpenGLErrors("Texture ID generation", error); // setup texture glBindTexture(GL_TEXTURE_2D, texid); SetSampler(info); int internalformat, format; GetTextureFormat(surface, info, internalformat, format); // upload texture data glTexImage2D(GL_TEXTURE_2D, 0, internalformat, w, h, 0, format, GL_UNSIGNED_BYTE, pixels); CheckForOpenGLErrors("Texture creation", error); // If we support generatemipmap, go ahead and do it regardless of the info.mipmap setting. // In the GL3 renderer the sampler decides whether or not to do mip filtering, // so we conservatively make mipmaps available for all textures. if (GLC_ARB_framebuffer_object) glGenerateMipmap(GL_TEXTURE_2D); SDL_FreeSurface(surface); return true; }
void AngelCore::AngelRendering::Shader::UnBindSampler(UINT startSlot, UINT numBuffer) { ID3D11SamplerState *uav = nullptr; SetSampler(startSlot, numBuffer, &uav); }
void SSR::Render(const Ptr<RenderView> & view) { auto sceneTex = view->GetViewRenderContext()->GetSharedTexture("RenderResult"); auto sceneClipDepth = view->GetViewRenderContext()->GetSharedTexture("SceneClipDepth"); auto gbuffer0 = view->GetViewRenderContext()->GetSharedTexture("GBuffer0"); auto gbuffer1 = view->GetViewRenderContext()->GetSharedTexture("GBuffer1"); TextureDesc ssrDesc = sceneTex->GetDesc(); ssrDesc.format = RENDER_FORMAT_R16G16B16A16_FLOAT; auto ssrResultTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, ssrDesc }); auto ssrResult = ssrResultTexRef->Get()->Cast<Texture>(); auto tmpDepthTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, sceneClipDepth->GetDesc() }); auto tmpDepthTex = tmpDepthTexRef->Get()->Cast<Texture>(); sceneClipDepth->CopyTo(tmpDepthTex, 0, 0, 0, 0, 0, 0, 0); auto ps = Shader::FindOrCreate<ScreenSpaceReflectionPS>(); view->BindShaderParams(ps); ps->SetScalar("frameCount", Global::GetInfo()->frameCount); ps->SetScalar("ssrMaxRoughness", _ssrMaxRoughness); ps->SetScalar("ssrIntensity", _ssrIntensity); ps->SetSRV("sceneTex", sceneTex->GetShaderResourceView()); ps->SetSRV("depthTex", tmpDepthTex->GetShaderResourceView(0, 0, 0, 0, false, RENDER_FORMAT_R24_UNORM_X8_TYPELESS)); ps->SetSRV("gbuffer0", gbuffer0->GetShaderResourceView()); ps->SetSRV("gbuffer1", gbuffer1->GetShaderResourceView()); ps->SetSampler("pointClampSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->SetSampler("linearSampler", SamplerTemplate<>::Get()); ps->Flush(); auto rc = Global::GetRenderEngine()->GetRenderContext(); rc->SetDepthStencilState( DepthStencilStateTemplate< false, DEPTH_WRITE_ZERO, COMPARISON_LESS, true, 0xff, 0xff, STENCIL_OP_KEEP, STENCIL_OP_KEEP, STENCIL_OP_KEEP, COMPARISON_NOT_EQUAL>::Get(), 0); DrawQuad( { ssrResult->GetRenderTargetView(0, 0, 1) }, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, sceneClipDepth->GetDepthStencilView(0, 0, 1, RENDER_FORMAT_D24_UNORM_S8_UINT)); auto ssrSharedRef = SSRNeighborShare(view, ssrResult, gbuffer1, tmpDepthTex, sceneClipDepth); auto ssrShared = ssrSharedRef->Get()->Cast<Texture>(); // Temporal AA for SSR auto ssrAAedResultTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, sceneTex->GetDesc() }); auto ssrAAedResultTex = ssrAAedResultTexRef->Get()->Cast<Texture>(); { auto adaptedExposureScale = view->GetViewRenderContext()->GetSharedTexture("AdaptedExposureScale"); float2 offsets[5] = { float2(0.0f, 0.0f), float2(-1.0f, 0.0f), float2(1.0f, 0.0f), float2(0.0f, -1.0f), float2(0.0f, 1.0f), }; float filterWeights[5]; float weightsSum = 0.0f; for (int i = 0; i < 5; ++i) { float2 offset = offsets[i] - float2(0.5f, -0.5f) * view->temporalAAJitter; //filterWeights[i] = CatmullRom(offset.x()) * CatmullRom(offset.y()); offset.x() *= 1.0f + 0.0f * 0.5f; offset.y() *= 1.0f + 0.0f * 0.5f; filterWeights[i] = exp(-2.29f * (offset.x() * offset.x() + offset.y() * offset.y())); weightsSum += filterWeights[i]; } for (auto & i : filterWeights) i /= weightsSum; std::map<String, String> macros; macros["TAA_DYNAMIC"] = "0"; macros["TAA_HISTORY_BICUBIC"] = "0"; auto ps = Shader::FindOrCreate<TemporalAAPS>(macros); view->BindShaderParams(ps); ps->SetScalar("texSize", ssrResult->GetTexSize()); ps->SetScalar("neighborFilterWeights", filterWeights, (int)sizeof(float) * 5); ps->SetScalar("frameCount", (uint32_t)Global::GetInfo()->frameCount); ps->SetScalar("lerpFactor", 0.125f); //ps->SetSRV("linearDepth", sceneLinearClipDepth->GetShaderResourceView()); ps->SetSRV("sceneDepth", sceneClipDepth->GetShaderResourceView(0, 0, 0, 0, false, RENDER_FORMAT_R24_UNORM_X8_TYPELESS)); ps->SetSRV("sceneTex", ssrShared->GetShaderResourceView()); //ps->SetSRV("velocityTex", velocityTex->GetShaderResourceView()); //ps->SetSRV("adaptedExposureScale", adaptedExposureScale->GetShaderResourceView()); if (_preSSRResultRef) ps->SetSRV("historyTex", _preSSRResultRef->Get()->Cast<Texture>()->GetShaderResourceView()); else ps->SetSRV("historyTex", nullptr); ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get()); ps->SetSampler("linearSampler", SamplerTemplate<>::Get()); ps->Flush(); DrawQuad( { ssrAAedResultTex->GetRenderTargetView(0, 0, 1) }, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, sceneClipDepth->GetDepthStencilView(0, 0, 1, RENDER_FORMAT_D24_UNORM_S8_UINT)); _preSSRResultRef = ssrResultTexRef; } /*rc->SetBlendState( BlendStateTemplate<false, false, true, BLEND_PARAM_ONE, BLEND_PARAM_ONE, BLEND_OP_ADD>::Get()); rc->SetDepthStencil(sceneClipDepth->GetDepthStencilView(0, 0, 1, RENDER_FORMAT_D24_UNORM_S8_UINT)); Transform( ssrAAedResultTex->GetShaderResourceView(), sceneTex->GetRenderTargetView(0, 0, 1), { COLOR_WRITE_R, COLOR_WRITE_G ,COLOR_WRITE_B ,COLOR_WRITE_A }, 0.0f, 0.0f, nullptr, sceneClipDepth->GetDepthStencilView(0, 0, 1, RENDER_FORMAT_D24_UNORM_S8_UINT));*/ rc->SetBlendState(nullptr); rc->SetDepthStencilState(nullptr); view->GetViewRenderContext()->SetSharedResource("SSR", ssrAAedResultTexRef); }