2020-10-19 08:23:06 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
/*================================================================================================
2023-09-01 15:06:19 -04:00
SubstrateDefinitions . ush : used in ray tracing shaders and C + + code to define common constants
2020-10-19 08:23:06 -04:00
! ! ! Changing this file requires recompilation of the engine ! ! !
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
# pragma once
2023-09-23 05:42:29 -04:00
# ifndef __cplusplus
// Change this to force recompilation of all Substrate dependent shaders (for instance https://guidgenerator.com/online-guid-generator.aspx)
2024-02-12 07:17:12 -05:00
# pragma message("UESHADERMETADATA_VERSION B013B52C-494E-4FC3-9EB5-B16B754E5CA4")
2023-09-23 05:42:29 -04:00
# endif
2020-10-19 08:23:06 -04:00
2023-10-12 15:57:47 -04:00
// Closure offsets are packed into 32bits, each entry using SUBSTRATE_CLOSURE_OFFSET_BIT_COUNT bits
# define SUBSTRATE_MAX_CLOSURE_COUNT_FOR_CLOSUREOFFSET 8u
# define SUBSTRATE_CLOSURE_OFFSET_BIT_COUNT 4u
# define SUBSTRATE_CLOSURE_OFFSET_BIT_MASK 0xF
2020-10-19 08:23:06 -04:00
2023-10-12 15:57:47 -04:00
// We can only ever use SUBSTRATE_MAX_CLOSURE_COUNT_FOR_CLOSUREOFFSET for Lumen, so we use that as a global closure count limit today.
# define SUBSTRATE_MAX_CLOSURE_COUNT SUBSTRATE_MAX_CLOSURE_COUNT_FOR_CLOSUREOFFSET
2023-09-01 15:06:19 -04:00
# define SUBSTRATE_MAX_OPERATOR_COUNT 15
2020-11-18 04:00:19 -04:00
2021-05-17 16:41:40 -04:00
// It this is changed, STATE_BIT_COUNT_SHAREDLOCALBASESID and HEADER_BIT_COUNT_SHAREDLOCALBASES_COUNT also needs to be updated
2023-09-01 15:06:19 -04:00
# define SUBSTRATE_MAX_SHAREDLOCALBASES_REGISTERS 4
2020-10-19 08:23:06 -04:00
2023-09-01 15:06:19 -04:00
# define SUBSTRATE_PACKED_SHAREDLOCALBASIS_STRIDE_BYTES 4
2020-10-19 08:23:06 -04:00
2023-03-28 05:25:01 -04:00
// As of today, a fully simplified material is a slab with all features allowed. It can thus be complex if anisotropy is enabled and in this case eats up to 32bytes.
2023-09-01 15:06:19 -04:00
// SUBSTRATE_TODO: fully simplified should remove all features but fuzz maybe.
# define SUBSTRATE_FULLY_SIMPLIFIED_NUM_UINTS (32 / 4)
2020-10-19 08:23:06 -04:00
2023-09-01 15:06:19 -04:00
# define SUBSTRATE_BSDF_TYPE_SLAB 0
# define SUBSTRATE_BSDF_TYPE_VOLUMETRICFOGCLOUD 1
# define SUBSTRATE_BSDF_TYPE_UNLIT 2
# define SUBSTRATE_BSDF_TYPE_HAIR 3
# define SUBSTRATE_BSDF_TYPE_SINGLELAYERWATER 4
# define SUBSTRATE_BSDF_TYPE_EYE 5
// When more than 7 BSDF must exists, please update STATE_BIT_COUNT_BSDF and FSubstrateClassification.ShadingModels packing in Substrate.ush
2020-10-19 08:23:06 -04:00
2023-09-01 15:06:19 -04:00
// The size of Substrate material classification tiles on screen
# define SUBSTRATE_TILE_SIZE 8
# define SUBSTRATE_TILE_SIZE_DIV_AS_SHIFT 3
2021-02-22 12:41:28 -04:00
// The default thickness of a layer is considered to be 0.01 centimeter = 0.1 millimeter
2023-09-01 15:06:19 -04:00
# define SUBSTRATE_LAYER_DEFAULT_THICKNESS_CM 0.01f
2021-04-27 09:42:01 -04:00
2022-12-02 05:27:10 -05:00
// Min Fuzz Roughness to avoid numerical issue
2023-09-01 15:06:19 -04:00
# define SUBSTRATE_MIN_FUZZ_ROUGHNESS 0.02f
2022-12-02 05:27:10 -05:00
2023-09-01 15:06:19 -04:00
# define SUBSTRATE_BASE_PASS_MRT_OUTPUT_COUNT 3
2022-02-15 03:09:30 -05:00
2023-09-01 15:06:19 -04:00
# define SUBSTRATE_SSS_DATA_UINT_COUNT 2
2022-08-29 02:55:17 -04:00
2023-09-01 15:06:19 -04:00
# define SUBSTRATE_OPERATOR_WEIGHT 0
# define SUBSTRATE_OPERATOR_VERTICAL 1
# define SUBSTRATE_OPERATOR_HORIZONTAL 2
# define SUBSTRATE_OPERATOR_ADD 3
# define SUBSTRATE_OPERATOR_BSDF 4
# define SUBSTRATE_OPERATOR_BSDF_LEGACY 5
2022-03-15 09:55:16 -04:00
2023-09-01 15:06:19 -04:00
// This must map directly to ESubstrateTileMaterialType
# define SUBSTRATE_TILE_TYPE_SIMPLE 0
# define SUBSTRATE_TILE_TYPE_SINGLE 1
# define SUBSTRATE_TILE_TYPE_COMPLEX 2
# define SUBSTRATE_TILE_TYPE_COMPLEX_SPECIAL 3
# define SUBSTRATE_TILE_TYPE_ROUGH_REFRACT 4
# define SUBSTRATE_TILE_TYPE_ROUGH_REFRACT_SSS_WITHOUT 5
# define SUBSTRATE_TILE_TYPE_DECAL_SIMPLE 6
# define SUBSTRATE_TILE_TYPE_DECAL_SINGLE 7
# define SUBSTRATE_TILE_TYPE_DECAL_COMPLEX 8
# define SUBSTRATE_TILE_TYPE_COUNT 9
2022-03-15 09:55:16 -04:00
2023-10-05 08:25:08 -04:00
# define SUBSTRATE_MATERIAL_TYPE_SIMPLE 0
# define SUBSTRATE_MATERIAL_TYPE_SINGLE 1
# define SUBSTRATE_MATERIAL_TYPE_COMPLEX 2
# define SUBSTRATE_MATERIAL_TYPE_COMPLEX_SPECIAL 3
2023-12-15 02:18:24 -05:00
# define SUBSTRATE_TILE_ENCODING_16BITS 0
# define SUBSTRATE_TILE_ENCODING_8BITS 1
2024-03-26 04:25:35 -04:00
// Specular profile
# define SUBSTRATE_SPECULAR_PROFILE_ENTRY_LIGHT 0u
# define SUBSTRATE_SPECULAR_PROFILE_ENTRY_ENV 1u
# define SUBSTRATE_SPECULAR_PROFILE_ENTRY_COUNT 2u
2022-03-15 09:55:16 -04:00
// sizeof(FRHIDrawIndirectParameters) = 4 uints = 16 bytes
2023-09-01 15:06:19 -04:00
# define GetSubstrateTileTypeDrawIndirectArgOffset_Byte(x) (x * 16)
# define GetSubstrateTileTypeDrawIndirectArgOffset_DWord(x) (x * 4)
2022-03-18 13:43:33 -04:00
2022-10-31 10:15:11 -04:00
// sizeof(FRHIDispatchIndirectParameters) can vary per-platform
# ifdef __cplusplus
2023-09-01 15:06:19 -04:00
# define GetSubstrateTileTypeDispatchIndirectArgOffset_Byte(x) (x * sizeof(FRHIDispatchIndirectParameters))
# define GetSubstrateTileTypeDispatchIndirectArgOffset_DWord(x) (x * sizeof(FRHIDispatchIndirectParameters) / sizeof(uint32))
2022-10-31 10:15:11 -04:00
# else
2023-09-01 15:06:19 -04:00
# define GetSubstrateTileTypeDispatchIndirectArgOffset_Byte(x) (x * DISPATCH_INDIRECT_UINT_COUNT * 4)
# define GetSubstrateTileTypeDispatchIndirectArgOffset_DWord(x) (x * DISPATCH_INDIRECT_UINT_COUNT)
2022-10-31 10:15:11 -04:00
# endif