Remove lut identity assets and code, simply calculate base coordinates for LUT programmatically.

Signed-off-by: rbarrand <rbarrand@amazon.com>
This commit is contained in:
rbarrand
2021-10-14 17:13:17 -07:00
parent c42d82386b
commit 67c14c21cc
8 changed files with 24 additions and 299133 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -5,6 +5,13 @@ For complete copyright and license terms please see the LICENSE at the root of t
SPDX-License-Identifier: Apache-2.0 OR MIT
"""
"""
This script is used by the Editor HDR Color Grading component to use a stored lut asset path
and pass it onto a Look Modification Component.
The HDR Color Grading component will be disabled as it is not compatible with the Look
Modification Component.
"""
import azlmbr
import azlmbr.legacy.general as general
@@ -78,4 +85,4 @@ if __name__ == "__main__":
entityIdList = azlmbr.entity.SearchBus(azlmbr.bus.Broadcast, 'SearchEntities', searchFilter)
for entityId in entityIdList:
activate_lut_asset(entityId, args.assetRelativePath)
activate_lut_asset(entityId, args.assetRelativePath)
@@ -19,17 +19,14 @@
float3 convert2Dto3DLutCoords(float2 uv, float width, float height)
{
float2 adjustedUv = float2(uv.x * width, uv.y * height);
float3 coords = float3(adjustedUv.x%height, 0.5 + int(adjustedUv.x/height), adjustedUv.y);
return coords/height;
}
// convert from center pixel uvs to [0,1]
float offset = 1.0/height/2.0;
float scale = 1.0 - offset*2.0;
enum class LutResolution
{
Lut16x16x16,
Lut32x32x32,
Lut64x64x64
};
float2 adjustedUv = float2(uv.x * width, uv.y * height);
float3 coords = float3(adjustedUv.x%height, 0.5 + int(adjustedUv.x/height), adjustedUv.y)/height;
return (coords - offset)/scale;
}
ShaderResourceGroup PassSrg : SRG_PerPass_WithFallback
{
@@ -44,21 +41,6 @@ ShaderResourceGroup PassSrg : SRG_PerPass_WithFallback
AddressW = Clamp;
};
Sampler LinearSampler
{
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
AddressW = Clamp;
};
// Identity LUTs
Texture3D<float4> m_identityLut16x16x16;
Texture3D<float4> m_identityLut32x32x32;
Texture3D<float4> m_identityLut64x64x64;
int m_lutResolution;
int m_shaperType;
float m_shaperBias;
@@ -104,33 +86,12 @@ struct PSOutput
PSOutput MainPS(VSOutput IN)
{
ShaperType shaperType = (ShaperType)PassSrg::m_shaperType;
int lutResolution = PassSrg::m_lutResolution;
PSOutput OUT;
// baseCoords are from 0-1
float3 baseCoords = float3(0.0, 0.0, 0.0);
LutResolution lutRes = (LutResolution)PassSrg::m_lutResolution;
switch(lutRes)
{
case LutResolution::Lut16x16x16:
{
baseCoords = convert2Dto3DLutCoords(IN.m_texCoord, 256, 16);
baseCoords = PassSrg::m_identityLut16x16x16.Sample(PassSrg::PointSampler, baseCoords, 0.0).rgb;
break;
}
case LutResolution::Lut32x32x32:
{
baseCoords = convert2Dto3DLutCoords(IN.m_texCoord, 1024, 32);
baseCoords = PassSrg::m_identityLut32x32x32.Sample(PassSrg::PointSampler, baseCoords, 0.0).rgb;
break;
}
case LutResolution::Lut64x64x64:
{
baseCoords = convert2Dto3DLutCoords(IN.m_texCoord, 4096, 64);
baseCoords = PassSrg::m_identityLut64x64x64.Sample(PassSrg::PointSampler, baseCoords, 0.0).rgb;
break;
}
}
float3 baseCoords = convert2Dto3DLutCoords(IN.m_texCoord, lutResolution*lutResolution, lutResolution);
float3 linearColor = ShaperToLinear(baseCoords, shaperType, PassSrg::m_shaperBias, PassSrg::m_shaperScale);
@@ -14,9 +14,9 @@
{
enum class LutResolution
{
Lut16x16x16,
Lut32x32x32,
Lut64x64x64
Lut16x16x16 = 16,
Lut32x32x32 = 32,
Lut64x64x64 = 64
};
}
}
@@ -28,41 +28,10 @@ namespace AZ
{
}
void LutGenerationPass::BuildInternal()
{
auto scene = GetScene();
if (scene)
{
AcesDisplayMapperFeatureProcessor* dmfp = scene->GetFeatureProcessor<AcesDisplayMapperFeatureProcessor>();
if (dmfp)
{
for (int i = 0; i < NumLuts; ++i)
{
auto assetId = AZ::RPI::AssetUtils::GetAssetIdForProductPath(LutIdentityProductPath[i], AZ::RPI::AssetUtils::TraceLevel::Error);
AZ_Assert(assetId.IsValid(), "LUT Asset is not valid.");
dmfp->GetLutFromAssetId(m_colorGradingLuts[i], assetId);
m_shaderResourceGroup->SetImageView(m_identityLutIndices[i], m_colorGradingLuts[i].m_lutStreamingImage->GetImageView());
m_colorGradingLutSizes[i] = RHI::Size(
m_colorGradingLuts[i].m_lutStreamingImage->GetDescriptor().m_size.m_width * m_colorGradingLuts[i].m_lutStreamingImage->GetDescriptor().m_size.m_width,
m_colorGradingLuts[i].m_lutStreamingImage->GetDescriptor().m_size.m_height,
1);
}
}
}
HDRColorGradingPass::BuildInternal();
}
void LutGenerationPass::InitializeInternal()
{
HDRColorGradingPass::InitializeInternal();
for (int i = 0; i < NumLuts; ++i)
{
m_identityLutIndices[i].Reset();
}
m_lutResolutionIndex.Reset();
m_lutShaperTypeIndex.Reset();
m_lutShaperScaleIndex.Reset();
@@ -92,12 +61,13 @@ namespace AZ
const auto* colorGradingSettings = GetHDRColorGradingSettings();
if (colorGradingSettings)
{
LutResolution lutResolution = colorGradingSettings->GetLutResolution();
uint32_t lutResolution = aznumeric_cast<uint32_t>(colorGradingSettings->GetLutResolution());
RHI::Size lutSize{ lutResolution * lutResolution, lutResolution, 1 };
RPI::Ptr<RPI::PassAttachment> attachment = FindOwnedAttachment(Name{ "ColorGradingLut" });
RHI::ImageDescriptor& imageDescriptor = attachment->m_descriptor.m_image;
imageDescriptor.m_size = m_colorGradingLutSizes[(int)lutResolution];
SetViewportScissorFromImageSize(m_colorGradingLutSizes[(int)lutResolution]);
imageDescriptor.m_size = lutSize;
SetViewportScissorFromImageSize(lutSize);
}
HDRColorGradingPass::BuildCommandListInternal(context);
}
@@ -38,7 +38,6 @@ namespace AZ
protected:
LutGenerationPass(const RPI::PassDescriptor& descriptor);
void BuildInternal() override;
void InitializeInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
void BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context) override;
@@ -48,17 +47,6 @@ namespace AZ
void SetViewportScissorFromImageSize(const RHI::Size& imageSize);
DisplayMapperAssetLut m_colorGradingLuts[NumLuts];
RHI::Size m_colorGradingLutSizes[NumLuts];
const char* const LutIdentityProductPath[NumLuts] = {
"lookuptables/lut_identitylinear_16x16x16.azasset",
"lookuptables/lut_identitylinear_32x32x32.azasset",
"lookuptables/lut_identitylinear_64x64x64.azasset" };
RHI::ShaderInputNameIndex m_identityLutIndices[NumLuts] = {
"m_identityLut16x16x16",
"m_identityLut32x32x32",
"m_identityLut64x64x64" };
RHI::ShaderInputNameIndex m_lutResolutionIndex = "m_lutResolution";
RHI::ShaderInputNameIndex m_lutShaperTypeIndex = "m_shaperType";