the ssr-history texture is not an array
the descriptor used for SSR is different depending on the pass. In the color pass, it's used as the source of the SSRs buffers and is an array (refraction & reflection). In the SSR pass it's the history buffer and is just a 2D texture.
This commit is contained in:
committed by
Mathias Agopian
parent
9a88537e08
commit
2abacaa030
@@ -284,11 +284,13 @@ void FMaterialInstance::setParameterImpl(std::string_view const name,
|
||||
auto const& descriptorSetLayout = mMaterial->getDescriptorSetLayout();
|
||||
DescriptorType const descriptorType = descriptorSetLayout.getDescriptorType(binding);
|
||||
TextureType const textureType = texture->getTextureType();
|
||||
SamplerType const samplerType = texture->getTarget();
|
||||
|
||||
FILAMENT_CHECK_PRECONDITION(
|
||||
DescriptorSet::isTextureCompatibleWithDescriptor(textureType, descriptorType))
|
||||
DescriptorSet::isTextureCompatibleWithDescriptor(textureType, samplerType, descriptorType))
|
||||
<< "Texture format " << int(texture->getFormat())
|
||||
<< " of type " << to_string(textureType)
|
||||
<< " with sampler type " << to_string(samplerType)
|
||||
<< " is not compatible with material \"" << getMaterial()->getName().c_str() << "\""
|
||||
<< " parameter \"" << name << "\""
|
||||
<< " of type " << to_string(descriptorType);
|
||||
|
||||
@@ -345,25 +345,6 @@ void ColorPassDescriptorSet::prepareSSR(Handle<HwTexture> ssr,
|
||||
s.ssrDistance = (ssrOptions.enabled && !disableSSR) ? ssrOptions.maxDistance : 0.0f;
|
||||
}
|
||||
|
||||
void ColorPassDescriptorSet::prepareHistorySSR(Handle<HwTexture> ssr,
|
||||
mat4f const& historyProjection,
|
||||
mat4f const& uvFromViewMatrix,
|
||||
ScreenSpaceReflectionsOptions const& ssrOptions) noexcept {
|
||||
|
||||
setSampler(+PerViewBindingPoints::SSR, ssr, {
|
||||
.filterMag = SamplerMagFilter::LINEAR,
|
||||
.filterMin = SamplerMinFilter::LINEAR
|
||||
});
|
||||
|
||||
auto& s = mUniforms.edit();
|
||||
s.ssrReprojection = historyProjection;
|
||||
s.ssrUvFromViewMatrix = uvFromViewMatrix;
|
||||
s.ssrThickness = ssrOptions.thickness;
|
||||
s.ssrBias = ssrOptions.bias;
|
||||
s.ssrDistance = ssrOptions.enabled ? ssrOptions.maxDistance : 0.0f;
|
||||
s.ssrStride = ssrOptions.stride;
|
||||
}
|
||||
|
||||
void ColorPassDescriptorSet::prepareStructure(Handle<HwTexture> structure) noexcept {
|
||||
// sampler must be NEAREST
|
||||
setSampler(+PerViewBindingPoints::STRUCTURE, structure, {});
|
||||
|
||||
@@ -117,11 +117,6 @@ public:
|
||||
float refractionLodOffset,
|
||||
ScreenSpaceReflectionsOptions const& ssrOptions) noexcept;
|
||||
|
||||
void prepareHistorySSR(TextureHandle ssr,
|
||||
math::mat4f const& historyProjection,
|
||||
math::mat4f const& uvFromViewMatrix,
|
||||
ScreenSpaceReflectionsOptions const& ssrOptions) noexcept;
|
||||
|
||||
void prepareShadowMapping(backend::BufferObjectHandle shadowUniforms, bool highPrecision) noexcept;
|
||||
|
||||
void prepareDirectionalLight(FEngine& engine, float exposure,
|
||||
|
||||
@@ -198,9 +198,40 @@ DescriptorSet DescriptorSet::duplicate(
|
||||
return set;
|
||||
}
|
||||
bool DescriptorSet::isTextureCompatibleWithDescriptor(
|
||||
backend::TextureType t, backend::DescriptorType d) noexcept {
|
||||
backend::TextureType t, backend::SamplerType s, backend::DescriptorType d) noexcept {
|
||||
using namespace backend;
|
||||
|
||||
switch (s) {
|
||||
case SamplerType::SAMPLER_2D:
|
||||
if (!is2dTypeDescriptor(d)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case SamplerType::SAMPLER_2D_ARRAY:
|
||||
if (!is2dArrayTypeDescriptor(d)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case SamplerType::SAMPLER_CUBEMAP:
|
||||
if (!isCubeTypeDescriptor(d)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case SamplerType::SAMPLER_CUBEMAP_ARRAY:
|
||||
if (!isCubeArrayTypeDescriptor(d)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case SamplerType::SAMPLER_3D:
|
||||
if (!is3dTypeDescriptor(d)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case SamplerType::SAMPLER_EXTERNAL:
|
||||
break;
|
||||
}
|
||||
|
||||
// check that the descriptor type is compatible with the texture format type
|
||||
switch (d) {
|
||||
case DescriptorType::SAMPLER_2D_FLOAT:
|
||||
case DescriptorType::SAMPLER_2D_ARRAY_FLOAT:
|
||||
|
||||
@@ -86,7 +86,8 @@ public:
|
||||
}
|
||||
|
||||
static bool isTextureCompatibleWithDescriptor(
|
||||
backend::TextureType t, backend::DescriptorType d) noexcept;
|
||||
backend::TextureType t, backend::SamplerType s,
|
||||
backend::DescriptorType d) noexcept;
|
||||
|
||||
private:
|
||||
struct Desc {
|
||||
|
||||
@@ -76,7 +76,7 @@ void SsrPassDescriptorSet::prepareHistorySSR(FEngine const& engine, Handle<HwTex
|
||||
ScreenSpaceReflectionsOptions const& ssrOptions) noexcept {
|
||||
|
||||
mDescriptorSet.setSampler(engine.getPerViewDescriptorSetLayoutSsrVariant(),
|
||||
+PerViewBindingPoints::SSR, ssr, {
|
||||
+PerViewBindingPoints::SSR_HISTORY, ssr, {
|
||||
.filterMag = SamplerMagFilter::LINEAR,
|
||||
.filterMin = SamplerMinFilter::LINEAR
|
||||
});
|
||||
|
||||
@@ -54,7 +54,8 @@ enum class PerViewBindingPoints : uint8_t {
|
||||
IBL_DFG_LUT = 7, // user defined (128x128), RGB16F
|
||||
IBL_SPECULAR = 8, // user defined, user defined, CUBEMAP
|
||||
SSAO = 9, // variable, RGB8 {AO, [depth]}
|
||||
SSR = 10, // variable, RGB_11_11_10, mipmapped
|
||||
SSR = 10, // variable, 2d array, RGB_11_11_10, mipmapped
|
||||
SSR_HISTORY = 10, // variable, 2d texture, RGB_11_11_10
|
||||
FOG = 11 // variable, user defined, CUBEMAP
|
||||
};
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ static constexpr std::initializer_list<DescriptorSetLayoutBinding> ssrVariantDes
|
||||
{ DescriptorType::UNIFORM_BUFFER, ShaderStageFlags::VERTEX | ShaderStageFlags::FRAGMENT, +PerViewBindingPoints::FRAME_UNIFORMS },
|
||||
{ DescriptorType::UNIFORM_BUFFER, ShaderStageFlags::VERTEX | ShaderStageFlags::FRAGMENT, +PerViewBindingPoints::SHADOWS },
|
||||
{ DescriptorType::SAMPLER_2D_FLOAT, ShaderStageFlags::FRAGMENT, +PerViewBindingPoints::STRUCTURE, DescriptorFlags::UNFILTERABLE },
|
||||
{ DescriptorType::SAMPLER_2D_ARRAY_FLOAT, ShaderStageFlags::FRAGMENT, +PerViewBindingPoints::SSR },
|
||||
{ DescriptorType::SAMPLER_2D_FLOAT, ShaderStageFlags::FRAGMENT, +PerViewBindingPoints::SSR_HISTORY },
|
||||
};
|
||||
|
||||
// Used for generating the color pass (i.e. the main pass). This is in fact a template that gets
|
||||
|
||||
Reference in New Issue
Block a user