浏览代码

Simplify DecodeFromGBuffer()

/main
Evgenii Golubev 7 年前
当前提交
2ceb2598
共有 2 个文件被更改,包括 19 次插入23 次删除
  1. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/Deferred.compute
  2. 40
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/Deferred.compute


uint2 tileCoord = uint2(tileIndex & 0xFFFF, tileIndex >> 16);
uint2 pixelCoord = tileCoord * GetTileSize() + groupThreadId;
uint featureFlags = TileVariantToFeatureFlags(VARIANT);
uint featureFlags = TileVariantToFeatureFlags(VARIANT, tileIndex);
#else
// Direct

40
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Material/Lit/Lit.hlsl


return NUM_FEATURE_VARIANTS - 1;
}
// This function need to return a compile time value, else there is no optimization
uint TileVariantToFeatureFlags(uint variant)
#ifdef USE_INDIRECT
uint TileVariantToFeatureFlags(uint variant, uint tileIndex)
return kFeatureVariantFlags[variant];
if (variant == NUM_FEATURE_VARIANTS - 1)
{
// We don't have any compile-time feature information.
// Therefore, we load the feature classification data at runtime to avoid
// entering every single branch based on feature flags.
return g_TileFeatureFlags[tileIndex];
}
else
{
// Return the compile-time feature flags.
return kFeatureVariantFlags[variant];
}
#endif // USE_INDIRECT
//-----------------------------------------------------------------------------
// Helper functions/variable specific to this material

// Isolate material features.
tileFeatureFlags &= MATERIAL_FEATURE_MASK_FLAGS;
if (tileFeatureFlags == 0)
{
// We have no feature information, so this is a feature classification pass.
tileFeatureFlags = MATERIAL_FEATURE_MASK_FLAGS;
}
else if (tileFeatureFlags == MATERIAL_FEATURE_MASK_FLAGS)
{
#ifdef USE_INDIRECT
// We don't have detailed compile-time feature information.
// Therefore, we load the feature classification data at runtime to avoid
// entering every single branch based on feature flags.
uint numTileX = (_ScreenSize.x + (TILE_SIZE_FPTL - 1)) / TILE_SIZE_FPTL;
uint index = (positionSS.y / TILE_SIZE_FPTL) * numTileX + (positionSS.x / TILE_SIZE_FPTL);
tileFeatureFlags = g_TileFeatureFlags[index];
#endif
}
bsdfData.materialFeatures = tileFeatureFlags; // Only tile-uniform feature evaluation
GBufferType0 inGBuffer0 = LOAD_TEXTURE2D(_GBufferTexture0, positionSS);

float3 unused;
// Call the regular function, compiler will optimized out everything not used.
// Note that all material feature flag bellow are in the same GBuffer (inGBuffer2) and thus material classification only sample one Gbuffer
return DecodeFromGBuffer(positionSS, 0, bsdfData, unused);
return DecodeFromGBuffer(positionSS, UINT_MAX, bsdfData, unused);
}
//-----------------------------------------------------------------------------

正在加载...
取消
保存