#pragma kernel ShadeOpaque_Fptl SHADE_OPAQUE_ENTRY=ShadeOpaque_Fptl USE_FPTL_LIGHTLIST=1 #pragma kernel ShadeOpaque_Clustered SHADE_OPAQUE_ENTRY=ShadeOpaque_Clustered USE_CLUSTERED_LIGHTLIST=1 #define LIGHTLOOP_TILE_PASS 1 #define LIGHTLOOP_TILE_DIRECT 1 #define LIGHTLOOP_TILE_INDIRECT 1 #define LIGHTLOOP_TILE_ALL 1 #define USE_FPTL_LIGHTLIST 1 //------------------------------------------------------------------------------------- // Include //------------------------------------------------------------------------------------- #include "Common.hlsl" // Note: We have fix as guidelines that we have only one deferred material (with control of GBuffer enabled). Mean a users that add a new // deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem), // the deferred shader will require to use multicompile. #define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl #include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs.hlsl" #include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl" #include "Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/Lighting.hlsl" // This include Material.hlsl //------------------------------------------------------------------------------------- // variable declaration //------------------------------------------------------------------------------------- DECLARE_GBUFFER_TEXTURE(_GBufferTexture); TEXTURE2D(_CameraDepthTexture); SAMPLER2D(sampler_CameraDepthTexture); RWTexture2D uavOutput; [numthreads(TILE_SIZE, TILE_SIZE, 1)] void SHADE_OPAQUE_ENTRY(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupId : SV_GroupID) { // input.positionCS is SV_Position uint2 pixelCoord = dispatchThreadId; PositionInputs posInput = GetPositionInput(pixelCoord.xy, _ScreenSize.zw); float depth = LOAD_TEXTURE2D(_CameraDepthTexture, posInput.unPositionSS).x; UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput); float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS); FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS); BSDFData bsdfData; float3 bakeDiffuseLighting; DECODE_FROM_GBUFFER(gbuffer, bsdfData, bakeDiffuseLighting); PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); float3 diffuseLighting; float3 specularLighting; LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, diffuseLighting, specularLighting); uavOutput[pixelCoord] = float4(diffuseLighting + specularLighting, 1.0); }