本文整理汇总了C++中Ptr::BindShaderParams方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::BindShaderParams方法的具体用法?C++ Ptr::BindShaderParams怎么用?C++ Ptr::BindShaderParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ptr
的用法示例。
在下文中一共展示了Ptr::BindShaderParams方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SSRNeighborShare
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;
}
示例2: LinearizeDepth
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 });
}
示例3: Render
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());
//.........这里部分代码省略.........