Files
UnrealEngineUWP/Engine/Shaders/Shared/StrataDefinitions.h

65 lines
2.6 KiB
C
Raw Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
/*================================================================================================
StrataDefinitions.ush: used in ray tracing shaders and C++ code to define common constants
!!! Changing this file requires recompilation of the engine !!!
=================================================================================================*/
#pragma once
// Change this to force recompilation of all strata dependent shaders (use https://www.random.org/cgi-bin/randbyte?nbytes=4&format=h)
#define STRATA_SHADER_VERSION 0x2a533622
#define STRATA_MAX_BSDF_COUNT 15
Big Strata core update! - Completely changed the way we evaluate and represent the material topology. - A topology is now represented as a tree to allow any horizontal/vertical operations (almost like a kdtree). - This allows for correct translucent material coverage/transmittance evaluation, as well as correct BSDFs luminance weight (finally). - All the operations to be able to do that are expended in HLSLTranslator instead of letting the compiler handle it (otherwise was too slow, leading to bugs and could not even debug shaders). This means no conditional BSDF packing. - There is no more Material/layer/BSDFs array: only a Tree or operators, some of them being BSDF at leaves. - Parameter blending has also been updated: when enabled on a node, it will be forced on all the oprator child / in the sub tree. - Parameter blending is applied on an inlinedbsdf on the StrataData. When it is the root of the parameter blending subtree, it is promoted to a fully fledged BSDF operator node to allow other regular operators. - The inlinedbsdf is not longer in premultiplied mode. Horizontal/Vertical/Add parameter blending operators have been updated to reflect that. This allows for simpler/unified/clearer code. - Vertical blending now uses the new simple "layering of two slabs with uncorelated coverage" math I have RnD'd. See GetVerticalLayeringInfo in ShadingCommon.ush. Follow up to this CL: - CompileStrataBlendFunction should use parameter blending. - Add more compilation debug output - Update material vizualisation - Fix Rough refraction - Fix decals - Fix debug probes - Pack FStrataBSDF - Move all StrataCompilationInfoCreateSingleBSDFMaterial into into the strata tree and rework cost evaluation and material LOD - Expand graph visit such as UpdateBSDFWeightAfterOperatorVisit to be specific to operators for the compiler to have to do less search to inline what we know already - Fix STRATA_TODO: operation using parameter blending are not actually discarded so they still occupy a pot in the opeartion arrays in the compiler and in the shader also. #rb charles.derousiers #preflight https://horde.devtools.epicgames.com/job/620a5f5d803d9066e67de938 #fyi charles.derousiers [CL 18993400 by Sebastien Hillaire in ue5-main branch]
2022-02-15 03:09:30 -05:00
#define STRATA_MAX_OPERATOR_COUNT 15
// It this is changed, STATE_BIT_COUNT_SHAREDLOCALBASESID and HEADER_BIT_COUNT_SHAREDLOCALBASES_COUNT also needs to be updated
#define STRATA_MAX_SHAREDLOCALBASES_REGISTERS 4
#define STRATA_PACKED_SHAREDLOCALBASIS_STRIDE_BYTES 4
#define STRATA_BSDF_TYPE_SLAB 0
#define STRATA_BSDF_TYPE_VOLUMETRICFOGCLOUD 1
#define STRATA_BSDF_TYPE_UNLIT 2
#define STRATA_BSDF_TYPE_HAIR 3
#define STRATA_BSDF_TYPE_SINGLELAYERWATER 4
// When more than 5 BSDF must exists, please update STATE_BIT_COUNT_BSDF and FStrataClassification.ShadingModels packing in Strata.ush
// The size of strata material classification tiles on screen
#define STRATA_TILE_SIZE 8
#define STRATA_TILE_SIZE_DIV_AS_SHIFT 3
// The default thickness of a layer is considered to be 0.01 centimeter = 0.1 millimeter
#define STRATA_LAYER_DEFAULT_THICKNESS_CM 0.01f
// The thin lighting model is used when the thickness becomes strictly lower than 0.1 millimeter
#define STRATA_LAYER_ISTHIN_THICKNESS_THRESHOLD_CM 0.01f
#define STRATA_BASE_PASS_MRT_OUTPUT_COUNT 2
Big Strata core update! - Completely changed the way we evaluate and represent the material topology. - A topology is now represented as a tree to allow any horizontal/vertical operations (almost like a kdtree). - This allows for correct translucent material coverage/transmittance evaluation, as well as correct BSDFs luminance weight (finally). - All the operations to be able to do that are expended in HLSLTranslator instead of letting the compiler handle it (otherwise was too slow, leading to bugs and could not even debug shaders). This means no conditional BSDF packing. - There is no more Material/layer/BSDFs array: only a Tree or operators, some of them being BSDF at leaves. - Parameter blending has also been updated: when enabled on a node, it will be forced on all the oprator child / in the sub tree. - Parameter blending is applied on an inlinedbsdf on the StrataData. When it is the root of the parameter blending subtree, it is promoted to a fully fledged BSDF operator node to allow other regular operators. - The inlinedbsdf is not longer in premultiplied mode. Horizontal/Vertical/Add parameter blending operators have been updated to reflect that. This allows for simpler/unified/clearer code. - Vertical blending now uses the new simple "layering of two slabs with uncorelated coverage" math I have RnD'd. See GetVerticalLayeringInfo in ShadingCommon.ush. Follow up to this CL: - CompileStrataBlendFunction should use parameter blending. - Add more compilation debug output - Update material vizualisation - Fix Rough refraction - Fix decals - Fix debug probes - Pack FStrataBSDF - Move all StrataCompilationInfoCreateSingleBSDFMaterial into into the strata tree and rework cost evaluation and material LOD - Expand graph visit such as UpdateBSDFWeightAfterOperatorVisit to be specific to operators for the compiler to have to do less search to inline what we know already - Fix STRATA_TODO: operation using parameter blending are not actually discarded so they still occupy a pot in the opeartion arrays in the compiler and in the shader also. #rb charles.derousiers #preflight https://horde.devtools.epicgames.com/job/620a5f5d803d9066e67de938 #fyi charles.derousiers [CL 18993400 by Sebastien Hillaire in ue5-main branch]
2022-02-15 03:09:30 -05:00
#define STRATA_OPERATOR_WEIGHT 0
#define STRATA_OPERATOR_VERTICAL 1
#define STRATA_OPERATOR_HORIZONTAL 2
#define STRATA_OPERATOR_ADD 3
#define STRATA_OPERATOR_BSDF 4
#define STRATA_OPERATOR_BSDF_LEGACY 5
#define STRATA_OPERATOR_THINFILM 6
// This must map directly to EStrataTileMaterialType
#define STRATA_TILE_TYPE_SIMPLE 0
#define STRATA_TILE_TYPE_SINGLE 1
#define STRATA_TILE_TYPE_COMPLEX 2
#define STRATA_TILE_TYPE_ROUGH_REFRACT 3
#define STRATA_TILE_TYPE_SSS_WITHOUT_ROUGH_REFRACT 4
#define STRATA_TILE_TYPE_COUNT 5
// sizeof(FRHIDrawIndirectParameters) = 4 uints = 16 bytes
#define GetStrataTileTypeDrawIndirectArgOffset_Byte(x) (x * 16)
#define GetStrataTileTypeDrawIndirectArgOffset_DWord(x) (x * 4)
// sizeof(FRHIDispatchIndirectParameters) = 3 uints = 12 bytes
#define GetStrataTileTypeDispatchIndirectArgOffset_Byte(x) (x * 12)
#define GetStrataTileTypeDispatchIndirectArgOffset_DWord(x) (x * 3)