// Copyright UShaderLab. All Rights Reserved. // // UE_ scene-texture reads — forward to the engine's SceneTextureLookup (MaterialTemplate.ush). Because // these take a dynamic UV they are emitted as HLSL helpers (like Noise), NOT wired intrinsics. The graph // builder places a hidden UMaterialExpressionSceneTexture node (wired to the ParameterAnchor) whenever a // body uses one of these, so the engine sets bNeedsSceneTextures and binds the scene-texture SRVs. // // Enum scheme B (see Noise.ush): under SHADERLAB_IDE the id is a real HLSL `enum` for completion/semantics; // at real compile it degrades to `int` + `#define`s aliasing the engine's PPI_* ids (defined in the material // environment), so no magic numbers are hard-coded here. // // Domain rules (enforced by the builder, mirroring the engine): SceneDepth/CustomDepth/CustomStencil work in // a translucent Surface, Decal, or PostProcess material; the full GBuffer / PostProcessInput ids require the // PostProcess (or Decal) domain. (Scene-color-behind-translucency uses a different engine path and is not // exposed here yet — read it as PostProcessInput0 in a PostProcess material instead.) #pragma once #ifdef SHADERLAB_IDE enum ESLSceneTexture { SL_ST_SceneColor, SL_ST_SceneDepth, SL_ST_CustomDepth, SL_ST_CustomStencil, SL_ST_WorldNormal, SL_ST_PostProcessInput0, SL_ST_PostProcessInput1, SL_ST_PostProcessInput2, SL_ST_PostProcessInput3, SL_ST_PostProcessInput4, }; float4 SceneTextureLookup(float2 UV, int SceneTextureIndex, bool bFiltered) { return (float4)0; } #else #define ESLSceneTexture int #define SL_ST_SceneColor PPI_SceneColor #define SL_ST_SceneDepth PPI_SceneDepth #define SL_ST_CustomDepth PPI_CustomDepth #define SL_ST_CustomStencil PPI_CustomStencil #define SL_ST_WorldNormal PPI_WorldNormal #define SL_ST_PostProcessInput0 PPI_PostProcessInput0 #define SL_ST_PostProcessInput1 PPI_PostProcessInput1 #define SL_ST_PostProcessInput2 PPI_PostProcessInput2 #define SL_ST_PostProcessInput3 PPI_PostProcessInput3 #define SL_ST_PostProcessInput4 PPI_PostProcessInput4 #endif // Full-control lookup: read any scene-texture id at UV (id is an ESLSceneTexture token). float4 UE_SceneTexture(ESLSceneTexture Id, float2 UV) { return SceneTextureLookup(UV, Id, false); } // Convenience wrappers for the common reads. float UE_SceneDepth(float2 UV) { return SceneTextureLookup(UV, SL_ST_SceneDepth, false).r; } float UE_CustomDepth(float2 UV) { return SceneTextureLookup(UV, SL_ST_CustomDepth, false).r; } float UE_CustomStencil(float2 UV) { return SceneTextureLookup(UV, SL_ST_CustomStencil, false).r; }