Add support for tangent stream pairing with the first UV from the model.
This commit is contained in:
@@ -169,7 +169,7 @@ namespace AZ
|
||||
const AZ::Data::Asset<ShaderResourceGroupAsset>& drawSrgAsset = shader->GetAsset()->GetDrawSrgAsset();
|
||||
|
||||
// Set all unspecified shader options to default values, so that we get the most specialized variant possible.
|
||||
// (because FindVariantStableId treats unspecified options as a request specificlly for a variant that doesn't specify those options)
|
||||
// (because FindVariantStableId treats unspecified options as a request specifically for a variant that doesn't specify those options)
|
||||
// [GFX TODO][ATOM-3883] We should consider updating the FindVariantStableId algorithm to handle default values for us, and remove this step here.
|
||||
RPI::ShaderOptionGroup shaderOptions = *shaderItem.GetShaderOptions();
|
||||
shaderOptions.SetUnspecifiedToDefaultValues();
|
||||
@@ -198,6 +198,31 @@ namespace AZ
|
||||
const ShaderVariantId finalVariantId = shaderOptions.GetShaderVariantId();
|
||||
const ShaderVariant& variant = r_forceRootShaderVariantUsage ? shader->GetRootVariant() : shader->GetVariant(finalVariantId);
|
||||
|
||||
RHI::PipelineStateDescriptorForDraw pipelineStateDescriptor;
|
||||
variant.ConfigurePipelineState(pipelineStateDescriptor);
|
||||
|
||||
// Render states need to merge the runtime variation.
|
||||
// This allows materials to customize the render states that the shader uses.
|
||||
const RHI::RenderStates& renderStatesOverlay = *shaderItem.GetRenderStatesOverlay();
|
||||
RHI::MergeStateInto(renderStatesOverlay, pipelineStateDescriptor.m_renderStates);
|
||||
|
||||
streamBufferViewsPerShader.push_back();
|
||||
auto& streamBufferViews = streamBufferViewsPerShader.back();
|
||||
|
||||
UvStreamTangentIndex uvStreamTangentIndex;
|
||||
|
||||
if (!m_modelLod->GetStreamsForMesh(
|
||||
pipelineStateDescriptor.m_inputStreamLayout,
|
||||
streamBufferViews,
|
||||
uvStreamTangentIndex,
|
||||
variant.GetInputContract(),
|
||||
m_modelLodMeshIndex,
|
||||
m_materialModelUvMap,
|
||||
m_material->GetAsset()->GetMaterialTypeAsset()->GetUvNameMap()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Data::Instance<ShaderResourceGroup> drawSrg;
|
||||
if (drawSrgAsset)
|
||||
{
|
||||
@@ -210,31 +235,13 @@ namespace AZ
|
||||
drawSrg->SetShaderVariantKeyFallbackValue(shaderOptions.GetShaderVariantKeyFallbackValue());
|
||||
}
|
||||
|
||||
RHI::ShaderInputNameIndex shaderUvStreamTangentIndex = "m_uvStreamTangentIndex";
|
||||
|
||||
drawSrg->SetConstant(shaderUvStreamTangentIndex, uvStreamTangentIndex.GetFullFlag());
|
||||
|
||||
drawSrg->Compile();
|
||||
}
|
||||
|
||||
RHI::PipelineStateDescriptorForDraw pipelineStateDescriptor;
|
||||
variant.ConfigurePipelineState(pipelineStateDescriptor);
|
||||
|
||||
// Render states need to merge the runtime variation.
|
||||
// This allows materials to customize the render states that the shader uses.
|
||||
const RHI::RenderStates& renderStatesOverlay = *shaderItem.GetRenderStatesOverlay();
|
||||
RHI::MergeStateInto(renderStatesOverlay, pipelineStateDescriptor.m_renderStates);
|
||||
|
||||
streamBufferViewsPerShader.push_back();
|
||||
auto& streamBufferViews = streamBufferViewsPerShader.back();
|
||||
|
||||
if (!m_modelLod->GetStreamsForMesh(
|
||||
pipelineStateDescriptor.m_inputStreamLayout,
|
||||
streamBufferViews,
|
||||
variant.GetInputContract(),
|
||||
m_modelLodMeshIndex,
|
||||
m_materialModelUvMap,
|
||||
m_material->GetAsset()->GetMaterialTypeAsset()->GetUvNameMap()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Use the default draw list tag from the shader variant.
|
||||
RHI::DrawListTag drawListTag = shader->GetDrawListTag();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user