From 4ccbecfa8ff613a760e8a58d297a57d30545207c Mon Sep 17 00:00:00 2001 From: TomasKiniulis <50582134+TomasKiniulis@users.noreply.github.com> Date: Fri, 22 May 2020 15:41:02 +0300 Subject: [PATCH 01/11] Enable "MSAA Within Forward" Camera Frame Setting by default when new Render Pipeline asset is created (#348) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixing merge issue for SSR transparent * Fix universal and yamato after merge. * fixuniversal after merge * renormalize files * Update 9801_ShurikenLightModule.unity * Make isEditorCameraPreview and sky public (#6147) * Update HDAdditionalCameraData.cs * Update SkySettings.cs * Update 9801_ShurikenLightModule.unity * Update HDAdditionalCameraData.cs * Update 9801_ShurikenLightModule.unity * Fixing ray tracing tests (#6158) * Fixed transparent SSR for shader graph. (#6163) * - Fixed transparent SSR for shader graph. * changelog * Added old graphics tests and modifications (#6143) * Update scenes * update blendstates * added OSX reference images * win reference images * fix lit light difference * Update blendstates-c-lit-unlit * disable check memory alloc due to ref probe issues * update ref images * rename test 1709 to 1711 * rename test 1709 to 1711 - bis Co-authored-by: sebastienlagarde * Fix issue with blend mode and with keyword (#6164) * Fixed an issue with emissive light meshes not being in the RAS (#6174) * Hdrp/pt8 (#6090) * Added support for anisotropy. * Tidied the code up, plus moved to correlated G term for aniso GGX. * Added anisotropic refractive sampling. * Disable path tracing for the shading graph preview camera. * Added support for alpha culling. * Fixed issue with transmission rays. * Updated Changelog. * Added support for punctual and directional light cookies. * Updated Changelog. * Added support for area light cookies. * Fixed bug with area cookies atlas not being properly generated when rebuilding library. * Made sure maxDepth > minDepth always, and added support for AO from mask. * Added support for transparent shadows. * Updated Changelog. * Toggling path tracing on/off does not reset iteration anymore. * Reverted change on enable, was causing minor issues. * Made sure we don't have transparent behaviour when shader is set to opaque. * Minor changes. * Tweaks on transparency behaviour. * Updated changelog. * Added path-tracing specific payload. * Added support for iridescence. * Updated Changelog. * Added multiple scattering compensation for specular. * Added Path tracing test. * PT test part 2. * Updated Changelog. * Added proper area light range attenuation. * Fixed issue with alpha clipping in ray-tracing. * Cosmetic. * Fix on the rect area light range. * In the editor, dragging manipulators around now resets accumulation. * Added material dirtiness tracking. * Does not apply intensity clamping to camera rays. * Reste PT iteration when saving a shader graph. * Added dirtiness tracking for acceleration structure and lights. * Added support for bg color. * Minor change to progress bar display. * Minor change to iteration counter, so that it never goes over the max. * Updated path tracing test. * Added finer estimates of lights during global pdf computation. * Refined light estimates during light list creation. * Updated PT test after changes to light sampling. * Minor change on samples count dirtiness handling. * Cosmetic, plus include guards. * Separated the path intersection structure from the ray tracing one. * Cosmetic, plus taking SSS weight into account to reduce diffuse. * Added SSS support for path tracing, and made some minor changes to the ray-traced version. * Minor code refactor. * ... * ... * Post-merge cleansing. * Fixed minor issues in CreateMaterialData(). * Fixed issue with test framework and resolution change. * Avoid error msg on null instance in PathTracing.cs. * Pathtracer new automated scenes (#6053) * Add global GI automated test scene * Adding transparency test scene * Update max samples of transparency scene to 32 * Added area light test scene / Updating reference image * Transparency scene settings + ref image * Scene added to build (Editor build settings) * Update tranparency image ref * Updating scene to 1 spp and ref image Also moving the asset to common assets folder * Re-added support for unlit shader graph. Co-authored-by: remi-chapelain <57442369+remi-chapelain@users.noreply.github.com> * Update RTSSS Screenshots (#6177) * Fix DX12 and DXR Player build and Updating the test screenshots for DXR player tests (#6130) * Fix DX12 and DXR Player build Updating the test screenshots for DXR player tests * fix shader graph case Co-authored-by: sebastienlagarde * Update CHANGELOG.md * Fix shader compilation issue with Vulkan and Raytracing (#6181) * update path tracing and 1219 test * Fix hdasset migration code not being called after a package upgrade (#6179) * Fix the HDRP asset migration code not being called after a package upgrade * Updated changelog Co-authored-by: sebastienlagarde * Fix custom pass out of bounds (#6176) * Fix draw renderers custom pass out of bound exception * Updated changelog Co-authored-by: sebastienlagarde * Fix PBR master node (#6182) * Fix PBR shader render states * Updated changelog * Fix some typos in the debug menu (#6097) * fix some typos * Revert typo fix that break public API * Changelog * Add regenerated shader includes Co-authored-by: sebastienlagarde * Fixed ray traced point and spot lights shadows not rejecting history when semi-transparent or colored. (#6108) * Fixed ray traced point and spot lights shadows not rejecting history when semi-transparent or colored. * Removing unwanted skip closest hit Co-authored-by: sebastienlagarde * Diffuse Shadow Denoiser Improvement. (#5851) * - Added a new mode that improves the filtering of ray traced shadows (directional, point and spot) based on the distance to the occluder. Added new test scenes to test the denoiser improvement * Update changelog * Fix an issue with the shadow denoiser grabiing data outside of the screen * changing light parameter to internal * Fixed a warning due to StaticLightingSky when reloading domain in some cases. (#6193) * Fixed the MaxLightCount being display when the light volume debug menu is on ColorAndEdge. (#6211) * Fixed the MaxLightCount being display when the light volume debug menu is on ColorAndEdge. * Update com.unity.render-pipelines.high-definition/CHANGELOG.md Co-Authored-By: Motiejus Viltrakis <36502659+iM0ve@users.noreply.github.com> Co-authored-by: sebastienlagarde Co-authored-by: Motiejus Viltrakis <36502659+iM0ve@users.noreply.github.com> * Update documentation to mention more explicitely the lack of support of vertex animation (#6207) * Update documentation to mention more explicitely the lack of support of vertex animation * Update Ray-Tracing-Getting-Started.md Co-authored-by: sebastienlagarde * Make subsection in decal debug menu to specify "affect transparents" (#6200) * Make subsection in decal debug menu * changelog Co-authored-by: sebastienlagarde * Added coverage for Enabled GPU Instanced material (#6183) For light layers automated test * Support cookie on light backing for Disc Area Light (#6138) * Added support for light cookies in the baking backends. * Updated light conversion script to reflect the latest changes made to the API. * Added support for directional light cookie sizes. * Added support for cookies on rectangular area lights. * Enable Area::Disc Light on backing with cookie * Update ChangeLog * Update CHANGELOG.md Co-authored-by: uygar Co-authored-by: sebastienlagarde * Hdrp /lookdev/fix crash on adding volume as viewed game object (#6129) * Update Volume's Layer when moving them to LookDev's stage * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Add smoothness remark (#6226) * Removed unexpected file * Removed legacy VR code from HDRP (#5923) * Removed legacy VR code * do not set CullingOptions.Stereo with xrsdk * re-add and tag previous function signature as obsolete Co-authored-by: sebastienlagarde * Improve light clipping and culling #2 (#4711) * Improve area light culling * Simplify * Clip box lights at the attenuation range * Save 1x ALU * Add missing feature flags * Chanelog Co-authored-by: EvgeniiG <7ee2cc898cca1b5fc49df740c2081dfc681e0a28> Co-authored-by: Sebastien Lagarde * Hdrp/fix/decal material ui errors (#6225) * Fixed error in the console when switching shader to decal in the material UI * Updated changelog Co-authored-by: sebastienlagarde * Fix z-fighting in sceneview when scene lighting is off (#6213) * Do not override the depth state of transparent materials in RenderDebugView * Changelog * Changelog - add case number Co-authored-by: sebastienlagarde * Mention default post processing in default volumes. (#6232) * Fix cubemap inspector so that thumbnail for cubemap work (#6231) * Fix for missing thumbnail on cubemaps * Changelog * Better default angles Co-authored-by: sebastienlagarde * fix ray tracing with VR single-pass (#6242) * - Fix an exception in ray tracing that happens if two LOD levels are using the same mesh renderer. (#6198) Co-authored-by: sebastienlagarde * update location of reference screenshots after merge * Added debug exposure to light hierarchy debug. (#6215) Co-authored-by: sebastienlagarde * - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. (#6251) Co-authored-by: sebastienlagarde * Hdrp/pt9 (#6184) * Added support for anisotropy. * Tidied the code up, plus moved to correlated G term for aniso GGX. * Added anisotropic refractive sampling. * Disable path tracing for the shading graph preview camera. * Added support for alpha culling. * Fixed issue with transmission rays. * Updated Changelog. * Added support for punctual and directional light cookies. * Updated Changelog. * Added support for area light cookies. * Fixed bug with area cookies atlas not being properly generated when rebuilding library. * Made sure maxDepth > minDepth always, and added support for AO from mask. * Added support for transparent shadows. * Updated Changelog. * Toggling path tracing on/off does not reset iteration anymore. * Reverted change on enable, was causing minor issues. * Made sure we don't have transparent behaviour when shader is set to opaque. * Minor changes. * Tweaks on transparency behaviour. * Updated changelog. * Added path-tracing specific payload. * Added support for iridescence. * Updated Changelog. * Added multiple scattering compensation for specular. * Added Path tracing test. * PT test part 2. * Updated Changelog. * Added proper area light range attenuation. * Fixed issue with alpha clipping in ray-tracing. * Cosmetic. * Fix on the rect area light range. * In the editor, dragging manipulators around now resets accumulation. * Added material dirtiness tracking. * Does not apply intensity clamping to camera rays. * Reste PT iteration when saving a shader graph. * Added dirtiness tracking for acceleration structure and lights. * Added support for bg color. * Minor change to progress bar display. * Minor change to iteration counter, so that it never goes over the max. * Updated path tracing test. * Added finer estimates of lights during global pdf computation. * Refined light estimates during light list creation. * Updated PT test after changes to light sampling. * Minor change on samples count dirtiness handling. * Cosmetic, plus include guards. * Separated the path intersection structure from the ray tracing one. * Cosmetic, plus taking SSS weight into account to reduce diffuse. * Added SSS support for path tracing, and made some minor changes to the ray-traced version. * Minor code refactor. * ... * ... * Post-merge cleansing. * Fixed minor issues in CreateMaterialData(). * Fixed issue with test framework and resolution change. * Avoid error msg on null instance in PathTracing.cs. * Pathtracer new automated scenes (#6053) * Add global GI automated test scene * Adding transparency test scene * Update max samples of transparency scene to 32 * Added area light test scene / Updating reference image * Transparency scene settings + ref image * Scene added to build (Editor build settings) * Update tranparency image ref * Updating scene to 1 spp and ref image Also moving the asset to common assets folder * Fog support WIP... * Added support for fog attenuation. * Cosmetic. * Set a maxSampleCount to 1 for tests only in play mode. * Updated Changelog. * Cosmetic. * Take min and max depth into account for fog color. * Make sure we are inside the light cluster when buidling light list. * Simplified signature of RenderPathTracing() func, replaced RaytracingFrameIndex with RaytracingSampleIndex. * Taking max fog distance into account. * Fog max dist part2. * Added a new test scene for the fog * move reference screenshots Co-authored-by: remi-chapelain <57442369+remi-chapelain@users.noreply.github.com> Co-authored-by: Remi Chapelain Co-authored-by: Sebastien Lagarde * Hdrp/volume debug (#6058) * New widget DebugUI.Table * Opened some Volume related API * New volume debug panel * Fixed a bug when debugging editor cameras * Fixed table border color. Updated documentation * Handles inactive and removed components * Don't show deprecated volume components. Sort by name * Revert unwanted modification * Handle disabled volumes * Hides volumes that don't affect the final value * Code documentation * Add range check * Fix player build * Fix volume influence detection * Refresh display when components changes * Fix error on player build * Reduce popping * Use editor camera as anchor point * Select all layers for the scene camera * Un-open profileRef API * Remove ref to profileRef * Proper component name, show text for non supported parameters * Fix profile duplication when using volume debug menu * Updated unsupported parameters message. Show a name as fallback if it exists Co-authored-by: sebastienlagarde * Fixing HDRP_DXR_TEST not having local package at right location (#6107) * Clearer naming of tile and cluster categories for environment lights (#6227) * Rename Environment to Probes * changelog Co-authored-by: sebastienlagarde * Fixed an issue with refraction model and ray traced recursive rendering (case 1198578). (#6267) Co-authored-by: sebastienlagarde * fix for Fogbugz 1214609 - HDRP Wizard addively increases the Light Intesity instead of setting it (#6266) * Fixed an issue where a dynamic sky changing any frame may not update the ambient probe. (#6235) * Fixed an issue where a dynamic sky changing any frame may not update the ambient probe. * Update changelog Co-authored-by: sebastienlagarde * Add XR setting to control camera jitter for temporal effects (#6259) * add XR setting to control camera jitter for temporal effects * cleanup unused code path * revert changes to scenes * Deprecate Utilities namespace (#6219) * (case 1204677) Copied namespace Utility to UnityEngine.Rendering and made it obsolete. * Updated changelog * Updated comment * Updated comment Co-authored-by: sebastienlagarde * Remove deprecated namespace Utilities. [Requires #6219] (#6220) * (case 1204677) Copied namespace Utility to UnityEngine.Rendering and made it obsolete. * Updated changelog * Updated comment * Removal of deprecated API * Updated changelog * Remove deprecated api Co-authored-by: Sebastien Lagarde * Fix issue on thumbnail generation so that no error on new project and thumbnail are generated at first import (#6265) * Fix issue with static preview for cubemap being called without a material initialized * Fix the issue preventing thumbnail to be preserved upon reimport on load * Comment * changelog * Change asset swap to legacy method * comment and white line removal * Fix for baked probe import cycle * Added comment * Oops missing a file Co-authored-by: sebastienlagarde * Add custom pass opaque rendering error message (#6330) * Added an error message when rendering opaque objects with an HDRP asset in DeferredOnly mode * Updated custom pass doc * Updated changelog * Fix issue of debug display variant with shader graph not compiling (#6325) * move #define DEBUG_DISPLAY into debugdisplay.hlsl * fix builtindata * fix includes * fix shader * fix XR culling with multiple cameras (#6314) Co-authored-by: sebastienlagarde * fix XR single-pass with Mock HMD plugin (#6313) Co-authored-by: sebastienlagarde * fix sRGB mismatch with XR SDK (#6311) Co-authored-by: sebastienlagarde * Partial fix LookDev opened when CoreRP package reimported (#6291) * Fix null texture usage happening on CoreRP upgrade * Partially fix garbage collected stylesheet issue. (Need more work on UIElement side, see case 1228706 ) * Update CHANGELOG.md * Clean log Co-authored-by: sebastienlagarde * Hdrp/fix default volume switch (#6250) * Fixed an issue where default volume would not update when switching profile. * Update changelog * Fixed an issue when setting the default volume for the first time where the hdrp asset would not be dirtied Co-authored-by: sebastienlagarde * Reflection probe cameras are now created with the correct type (#6245) Co-authored-by: sebastienlagarde * Fixed an issue where AO override would not override specular occlusion. (#6222) * Fixed an issue where AO override would not override specular occlusion. * Update changelog Co-authored-by: sebastienlagarde * Fixed an issue where Volume inspector might not refresh correctly in some cases. (#6252) * Fixed an issue where Volume inspector might not refresh correctly in some cases. * Update changelog Co-authored-by: sebastienlagarde * render XR mirror view only for camera with no RT (#6306) Co-authored-by: sebastienlagarde * Split set rendering feature set and API validity check (#6301) * Split set rendering feature set and API validity check * changelog Co-authored-by: sebastienlagarde * Hdrp/probe scale 1219246 (#6288) * Fix when scale down < 0 all direction of box Influence Volume * Update Change log * Hdrp/fix/particle light shadows (#6111) * Tried to fix particle light shadows * Fixed particle shadows * Updated changelog Co-authored-by: sebastienlagarde * Recording of accumulation motion blur and path tracing (#6114) * Pt and accumulation motion blur recording Fix merge issues Fix merge issues #2 Bugfix: accumulation with one sample Chengelog Don't set the fixed-time in the subframe manager - should be set in the recorder Properly set and reset the fixed time Updated documentation Small fix to make physics simulation work with scaled time / accumulation mb Post rebase fixes and disable accumulation when using only one sub-frame * Fix post merge issues * hdrp resources asset file * remove duplicate code * Move most compute shaders to use multi_compile API (#6307) * Squashed commit of the following: commit ed9e485efc69a7949e34f0512666d522470dc73e Author: FrancescoC-Unity Date: Fri Mar 20 11:47:59 2020 +0100 Revert "Squashed commit of the following:" This reverts commit 0dd46577be82abeaefc839cbcd9f3875b05d48e6. commit 0dd46577be82abeaefc839cbcd9f3875b05d48e6 Author: FrancescoC-Unity Date: Fri Mar 20 10:39:28 2020 +0100 Squashed commit of the following: commit 0e1815814ce8204cfa42ae3050ba655fe769c550 Merge: ac6809ec032 2b018dfe8a9 Author: Sebastien Lagarde Date: Thu Mar 19 18:19:45 2020 +0100 Merge branch 'master' into HDRP/staging commit 2b018dfe8a9f5f304e4b95d6279dda60f632c9dc Author: sebastienlagarde Date: Thu Mar 19 18:19:02 2020 +0100 Merge Hdrp/staging (#6293) * Custom pass cleanup (#5507) * Fix custom pass cleanup issue with multiple volumes * Updated changelog * Delay discard of fragments during decal projection (#5283) * Delay discard of fragments during decal projection Metal Shading Language declares that fragment discard invalidates derivatives for the rest of the quad, so we need to reorder when we discard during decal projection, or we get artifacts along the edges of the projection (any partial quads get bad partial derivatives regardless of whether they are computed implicitly or explicitly). * Better re-arrangement of decal code * Update TerrainLitPasses.hlsl * Update TerrainLitPasses.hlsl * Update TerrainLitPasses.hlsl * Update ShaderPassDecal.hlsl Co-authored-by: sebastienlagarde * Fixing unnecessary memory allocations in the ray tracing cluster build and Updating the screen shots for the ray tracing tests (#5465) * Fixing unnecessary memory allocations in the ray tracing cluster build Updating the screen shots for the ray tracing tests * Update test scene and screenshots * - Discarding the ray tracing history for AO, reflection, diffuse shadows and GI when the viewport size changes. - Update and disable some tests that still need to be updated * Add a counter for ray tracing frame index and update screenshots * Fixing the Area Shadows Denoiser Test Co-authored-by: sebastienlagarde * Change the default volume used by the ray tracing tests to make them work again (#5510) * Change the default volume used for the ray tracing tests, fixes the tests back. * Fix access to the ray tracing frame index in ray tracing ambient occlusion (doesn't change behavior) * Missing term in the ray tracing frame index access (#5511) * Fix colum headers (#5517) * Fix colum headers * Update CHANGELOG.md * Rename post formats (#5505) * Renamed the post processing format to the new convention * Updated changelog Co-authored-by: sebastienlagarde * Fixed the first frame flash with auto exposure (#5491) * Fixed flashes with low and high exposure scenes when Automatic Exposure is in use * Moved postfx history reset to per-camera reset Co-authored-by: sebastienlagarde * Update DefaultSettingsVolumeProfile.asset * Hdrp/small enhencements for DXR (#5493) * Add Warning for DXR and AsyncExecution in FrameSettings * move restarting at end of all fix in wizard for DXR * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Hdrp/update default scenes (#5485) * Replace default scenes with scene prepared for scene-template * Update of DefaultSettingsProfile * Update DXR scene * Add ScreenSpaceShadow to Camera's default FrameSettings * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Refactoring pre-existing materials to share code between rasterization and ray tracing (#5441) * Refactoring pre-existing materials to share code between rasterization and ray tracing Update the test scene * update changelog * Changing the color of an unlit in the reflection test scene * review corrections * Fixing unlit shader graph * Fix specular AA related issue * Update the reflection test * Fix an issue with debug display for ray tracing shaders Always use ray tracing frame index 0 for ray tracing tests Update tests screenshots Update ray traced reflection test scene Co-authored-by: sebastienlagarde * Hdrp/staging thin (#5509) * Adding a REFRACTION_THIN model. * Fixed thin distance. * ... and fixed it. * Updated changelog, removed unused REFRACTION attrs from Fabric template. * Added a REFRACTION_THIN_DISTANCE macro. * Finished support for thin refraction. * Fixed LitTesselation (was missing thin refraction model). * fix issue when merging Refactoring of DoAlphaTest * Fixed an issue where passing a null ProfilingSampler would cause a null ref exception. (#5555) * Fixing the area shadow denoised test (#5544) * Fix leak in Sky when matcap view (#5556) * skip pre render sky in matcap view * changelog Co-authored-by: sebastienlagarde * Fix compilation issues of ApplyExposure on platforms that don't support VR (#5575) * Fix * changelog * Remove Preview from physically based sky * HDRP asset migration (#5580) * Initialize the HDRP asset version to the latest one so new assets are not migrated * Updated changelog * Hdrp/remove wind resources (#5578) * Remove wind resources Remove wind resources no longer used and containing big files * Update changelog * revert: Hdrp/update default scenes (#5485) * Fix issue with missing texture in test * Disable POM test in 1708 SG_OnSG as it is unstable * Add missing texture in runtime test * update caption for geometric normal debug in forward * add missing texture to runtime test * Create Textures.meta * fix SG on decal SG * Fixed an issue where ambient occlusion and screen space reflections editors would generate null ref exceptions when HDRP was not set as the current pipeline. (#5577) * Fixed a null reference exception in the probe UI when no HDRP asset is present. (#5582) * Fixed a null reference exception in the probe UI when no HDRP asset is present. * Indentation Co-authored-by: sebastienlagarde * Fix custom pass outline (#5590) * Fixed custom pass outline resolution screen resolution dependent * Updated changelog Co-authored-by: sebastienlagarde * Fixed a null reference exception in the HDRI Sky editor when no HDRP asset is present. (#5596) Co-authored-by: sebastienlagarde * Fix decal orientation when created from script. (#5592) * Fixed all migration classes to default to latest version so that Decals created by script to get migrated. Fixed decal created through context menu so that they get the proper rotation convention. * Update changelog * Moved the GetEnumLastValue to TypeInfo class * Updated super old test scenes to the proper latest version for decals Co-authored-by: sebastienlagarde * Refactor of HDCamera (accesibility mostly) [Skip CI] (#5548) * Refactor of HDCamera - Made internal/private APIs that should not have been public - Fixed naming convention for private members - Moved everything by accessibility for clarity (public, internal, then private) * Added Doc and returned some API public. * Fix visibility of Density Volumes in reflections [Skip CI] (#5589) * Oblique projection frustum fix, first try * HDCamera frustum now recalculates near and far plane to avoid issues with oblique projection matrices. * Update changelog * Added comments * Indentation * Fixed camera relative position of frustum * Indentation * Fixed a null reference exception in Path Tracing, Recursive Rendering and raytraced Global Illumination editors when no HDRP asset is present. (#5597) Co-authored-by: sebastienlagarde * Fix ray tracing tests and add a test scene for lights and cookies in ray tracing (#5604) * expose StartSinglePass() and StopSinglePass() as public interface for XRPass (#5605) * Add missing custom pass API documentation (#5530) * Add missing custom pass API documentation * Fix doc spells and grammar * Stencil Refactor and Material migration fixes (#5581) * Remove leftover code * commit to switch machine * Remove hard coded stencil values in shaders * clear stencil * tmp commit, start of splitting decal in dbuffer and normal patchup * Make decal patching up run after GBuffer * Remove hardcoded value for SSS split lighting * Tmp commit to switch branch * Finalize build coarse stencil (with debug leftover and render graph NOT handled) * The AA bits (the easy one :-) ) * split in two enums * Distortion vectors bit sorted * SSR bit * Motion vector bit * decals bit * Lighting bits * Use HTile for SSR * HTile SSS -> Incomplete, verify and test. * SSS fixes, but still not working (probably not HTile related, but main stencil) * Make decal patch normal work and remove stencil bit * some leftover fixes * was commited by mistake * Update materials * Revert "Update materials" This reverts commit 4a0de82ef51750b77546020d77ad6b5d773e60af. * Fix issues with MSAA and with migration * Forgot this out * update materials and maps * default materials * don't have SSR on unlit * Fix some leftovers * Renaming * Revert "update materials and maps" This reverts commit 103f1cb71d8fffa49b0c2ef57f1b41b36d0a3dbf. * Revert "default materials" This reverts commit 978740acd825562717a01437dcc0c74fc4cfefb0. * Fix migration * white line * Fix migration * Add render queue overide to the material placer. Also add PackageInfo.cs to HDRP, so the graphic tests can call it's internal methods and objects. * Default material post migration * com.unity.testing.hdrp post reimport * Updated materials from test * Disable tests that are to be updated or not needed anymore * Fix VFX issues (To be fixed better by @PaulDemeulenaere ) * Lit hardcoded default was off * Update VFX Test materials ( @PaulDemeulenaere for awareness ) * Fix issue with stencil in TAA * Revert lighting data * revert light map data * Revert other lighting asset * Cleanup post processor. * Update DXR test material * Update commnets * Early (need testing) new migration workflow * Revert "Early (need testing) new migration workflow" This reverts commit 2db025002d66165dd00e90f5f5d3c944ed53f361. * Update post processor * Add manual option to migrate * Add dialog box Co-authored-by: RemyUnity <32760367+RemyUnity@users.noreply.github.com> * Push updated hdrp version in test project (#5617) * Push m_LastMaterialVersion update * Dont open dialog on yamato * Update test projects with recent stencil refector PR (#5618) * Update runtime test project * Create HDRPProjectSettings.asset * update DXR project * Revert "update caption for geometric normal debug in forward" This reverts commit 150d68279b891529be272b37f374c36b879646f4. * Run reimport during update (to avoid unwanted extra dialog during dialog box) (#5620) * Make user stencil bits public (#5616) * Expose bits to user * Update documentation * Update HDStencilUsage.cs Co-authored-by: sebastienlagarde * Implement history rejection based on object velocity (#5532) * Implement history rejection based on object velocity * Update changelog * Fix an issue with ambient occlusion denoising being broken after adding the history rejection feature Adding the GPU Light type for history validation and rejection Co-authored-by: sebastienlagarde * Fixed initial state of material created through the context menu. (#5603) * Fixed an issue where materials newly created from the contextual menu would have an invalid state, causing various problems until it was edited. * Forgot DecalUI (for non shader graph decals) Co-authored-by: sebastienlagarde * Update HDLightUI.Skin.cs * Cookie and planar atlas (#5518) * Added support for cookie atlas * Begin to move planar reflection into atlas * Added texture atlas for planar reflection probe plus a limit to on screen planar probes * Removed debug log * Fixed planar probe atlas scale issue and useless mipmap generation of the atlas * Refactor Texture2D atlas * Move ScaleBias for planar probes to a separate list * Fix cookie mode for directional lights * Added error log for non square cookie textures in the atlas * Fix merge * Fixed cookie atlas * Trying to fix area light cookies * Fixed area light cookie * Disable mipmap for non area light cookies * Added cookie atlas format control + fixed size warnings in HDRP cookie ui * Add resolution in Capture Settings reflection probe drawer * Removed warnings * Added the point light cookie texture array in the debug menu * Fix cookies in ray tracing + celestial body texture * Update dynamic light cookie screenshot * Update Animated cookie test + fix reflection probe texture format * Fix area light cookie * Update HDRP asset cookie and planar atlas sizes * Increase cookie atlas size for area light test * Simplify code * Fix cookie mip clamp * Fixed compilation and CG alloc * Added atlas layouting when there is no more space * Fix directional light cookie * Updated reference image of cookie area lights * Fix hardcoded format and cookie layout * Remove useless mip update * Fix area light cookie x flip * Added the debug exposure option for debug planar reflection atlas * reverted the fix for area light cookie x flip * Tried to simplify the code of the atlas * Update reference image * Added an error when max planar reflection probe on screen is reached * Fixed space parenthesis * Fixed mipmap not updated properly and area light cookie convolution temp texture format * Fixed atlas reset mips * Update tooltip and fixed cookie insertion order when there is no more space in the atlas * Enable exposure on cookie atlas debug * Fix debug overlap * Update reference image * Added migration code for the cookie atlas size and fixed point light cookie debug exposure * Added planar atlas size upgrade code * Updated planar reflection atlas message * Fixed resolution dependent cookie mip maps * Updated changelog * Fixed cookies for ray tracing * Fix cookie in the ray tracing light loop requested without being reserved * Clamp UV when doing the area light convolution * Update reference images * Remove debug symbols * Fixed area light convolution UV limit * Fixed half pixel clamp and updated reference images * Fixed planar reflection mip map edge bleeding and update reference images * Updated more image reference * Updated DXR cookie test scene * Fix default material transparent created with ZWrite enabled (#5621) * Fixed transparent material craeted with ZWrite enabled * Updated changelog Co-authored-by: sebastienlagarde * Hdrp/fix decal gizmo mouseover (#5626) * Remove controlID on projection direction of DecalProjector that conflict with other handles * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Hdrp/smallfixes lookdev (#5619) * Fix zoom being stuck around 0 * fix crash forbiding view manipulation while using directly hdri without passing by an environment * Fix hitch in FPS displacement mode * Fix when user destroy the EnvironmentLibrary being used. * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Mask was never set for some debug pixel deferred shaders [Skip CI] (#5627) * Mask was never set * changelog * Added comments Co-authored-by: sebastienlagarde * Fixed an issue where creating decals at runtime could cause a null reference exception. (#5594) Co-authored-by: sebastienlagarde * Make APIs internal when they should be - 1 - [Skip CI] (#5531) * First pass of making APIs internal when they should be. * Indentation * Compilation fixes + review feedback. * Make APIs internal when they should be - 2 - [Skip CI] (#5533) * First pass of making APIs internal when they should be. * Indentation * WIP * Missing file * More * Revert some changes based on review feedback * Compilation fix * Compilation fixes + review feedback. * Updated HDUtils accessibility * More editor internals. * Better (not hardcoded) stencil handling in VFX (#5624) * Stencil update for vfx * Fix issues * fix missing templates * Avoid displaying material upgrader dialog on new project (#5631) * Don't run dialog on new project creation * skip only on first creation * Check file existence before showing dialog * typo * Push test materials after ZWrite PR (#5632) * Update HDRP_Test project * Update DXR test assets * Update run time tests * Discard invalid pixels when doing deferred lighting in compute (for camera stacking) (#5339) * Discard invalid pixels when doing deferred lighting in compute (as required for camera stacking) Small comment modification Update changelog * Use stencil buffer (instead of normals) to discard pixels in deferred compute * Remove not required if statement when binding the stencil * Small fixes to API visibility. (#5637) * Fixed some more public APIs to internal. * Made hasCustomRender public again. * Moved the tier defining from the asset to the concerned volume components. (#5519) * Alpha post-processing bugfixes and improvements (#5512) * Bug fix for post processing alpha with chrommatic aberation + minor fixes * Avoid double blending in DOF * Unit tests for alpha post-processing (TAA/DoF) Vulkan test images Vulkan meta files * Fix runtime tests (#5639) * Update runtime test screenshots * Update planar resolution * Add test (#5641) * fix material and project settings for VFX (#5642) * Revert change to GBuffer (normalbuffer usage) as it broke the raytracing code * Fix various issues with time and animated materials (#5480) * Fix various issues with time and animated materials * Changelog * Add getters * Only update time once per frame * Fix animation in reflection * Fix null ref exception * Re-applied code after impossible merge. * Comment change * Remove commented code. Co-authored-by: JulienIgnace-Unity Co-authored-by: sebastienlagarde * fix graphic test (#5651) * renaming test 1901 -> 1451 and 1709 -> 1710 * Update EditorBuildSettings.asset * Update 1710_Decals_Normal_Patch.png * update screenshots * update scene backgroud * Update manifest.json * Update decal patch screenshots * update 4052_TAA * Changing the tier system for a preset mode system and removing unnecessary options (#5646) * Changing from a tier management to a "mode" management for reflection and GI and removing the ability to enable/disable deferred and ray bining (they are now implied by performance mode) * Update the scene scenes * Update changelog * Fixing an instability with the light shadows in ray tracing * Update to light explorer (#5615) - Fixed SkyType display when no Visual Environment is present - Changed fog display to reflect the updated fog system - Changed Global to "Mode" as it is in Volume UI now. Co-authored-by: sebastienlagarde * Update 1710_Decals_Normal_Patch.png * disable TAA test for XR * Hdrp/add documentation tool (#5655) * Add the documentation tool to HDRP test project * Fixed window serialization * Update the documentation for the diffusion profile (#5654) * Update the documentation for the diffusion profile * Update Diffusion-Profile.md Co-authored-by: sebastienlagarde * Add missing hdlight api (useVolumetrics) (#5652) * Add missing API to the HDAdditionalLightData * Updated changelog * Global Settings API doc. (#5649) * Fog Volume Component API doc. (#5645) * Debug Display API doc. (#5643) * Color picker API doc. * FullScreen Debug API doc. * Decal debug API doc * False Color debug API doc * Lighting Debug API doc * Material Debug API doc. * DebugDisplaySettings API doc. * Restored contact shadow fade debug. * API documentation for sky related classes. (#5640) * API documentation for sky related classes. * Document the PBR sky * Hdrp/small wizard fixes for dxr (#5633) * Add ScreenSpaceShadow to Camera's default FrameSettings * Forbid to atmpt creating default scene if the hdrpAsset is not right (we depend on its resources) * Update CHANGELOG.md * Add OS and Hardware check in wizard for DXR * Update CHANGELOG.md * Fixe typos * Add missing check on Shadows * Update Documentation Co-authored-by: sebastienlagarde * Documentation (#5613) Co-authored-by: sebastienlagarde * Fix custom pass disable stencil (#5545) * Disable the strencil in custom passes when overwriting the depth and not writing into it * Updated changelog * Rephrase doc Co-authored-by: sebastienlagarde * Add option to exclude camera motion contribution from motion blur (#5656) * Remove camera component from motion blur if desired * changelog * Documentation update Co-authored-by: sebastienlagarde * Implement Semi-transparent Shadows for Point and Spot lights (#5490) * Make the shadow behavior for transparent and transmissive objects more intuitive. * Update changelog * Implementing semi transparent ray traced shadows for point and spot light Adding a test scene for both cases Moving contact shadow ray tracing code to a seperate file Changing the direction of contact shadow rays to be coherent with the other shadows * update changelog * Update the test scenes Co-authored-by: sebastienlagarde * fix shader warning in termporal AA * Support semi-transparent shadows for unlit shader and unlit shader graph (#5663) * Not doing ray tracing when the stencil bit is off for ssr (#5665) adding a test case for it * Restored serialization of deprecated parameters to fix migration. (#5666) * Shadow Atlas is no longer allocated for area lights when they are disabled in the shader config file. (#5662) Co-authored-by: sebastienlagarde * Updated HDRP documentation (#5664) * Updated HDRP asset doc * Update the upgrade guide for cookies and planars * Added warning in the material sorting priority doc for depth write * Added a section about surface option properties for ShaderGraphs * Fix link name * Alpha output documentation (#5658) * Update documentation for HDRI-Sky-Backplate (AO) (#5670) * Avoid MRT Clear on PS4 [Skip CI] (#5675) * Avoid MRT Clear on PS4 * changelog * Update HDRenderPipeline.cs * Update HDRenderPipeline.cs Co-authored-by: sebastienlagarde * Change name of option (#5681) * More code share between inspector materials (#5635) * Share stencil code for inspector materials (Akin to what happens in shadergraph) * changelog * Add comment and fix issue * Better handling of setting state (if not available, don't write it) * Update BaseLitGUI.cs Co-authored-by: sebastienlagarde * Expose alpha cutoff material for ShaderGraphs (#5667) * Expose alpha clip to material UI for ShaderGraphs * Updated changelog * Replace #if by #ifdef * Fix debug menu bitfield (#5683) * Fixed runtime debug menu bitfield controls * Updated changelog * Hdrp/update default scenes (#5634) * Replace default scenes with scene prepared for scene-template * Update of DefaultSettingsProfile * Update DXR scene * fix missing profile in default scene dxr * Update CHANGELOG.md * Fix missing HDRI Sky references in DXR new scene * Fixed VFX Tests Default volume profile * Changed Default Volume settings to an empty one. * Missing volume asset files + update manifest and meta Co-authored-by: JulienIgnace-Unity Co-authored-by: sebastienlagarde * - Fixed the radius value used for ray traced directional light. (#5682) - Fixed compilation issues with the layered lit in ray tracing shaders. - Changed the way the length parameter is used for ray traced contact shadows. - Added contact shadow test scenes Co-authored-by: sebastienlagarde * fixed XR autotests viewport size rounding (#5684) Co-authored-by: sebastienlagarde * Material samples bis (#5686) * Add ball * update Material samples #5638 * Update CHANGELOG.md * Remove unused version property from Material * Updating the documentation for ray tracing (#5680) * Updating the documentation for ray tracing * review corrections * Fix mip slider reflectionprobe (#5689) * Remove the slider knob when the reflection probe preview has no mipmap * Updated changelog * edit VR documentation (#5685) Co-authored-by: sebastienlagarde * Better directional PCSS blur handling (#5688) * Use correct penumbra calculation for directional. * Update visual test * Need cleaning uo * Cleaning * screenshot update * Small cleanup * typo leftover * changelog Co-authored-by: sebastienlagarde * Update 001-HDTemplate.png * Adding the initial implementation of sub-surface scattering (#5625) * Initial implementation of ray traced sub surface scattering Added a test scene for ray traced sub surface scaterring * Update changelog * Updating the tests * Update 8103_PrePostPass.unity * Remove unnecessary skip of material upgrade dialog box. (#5692) * Remove unnecessary skip of material upgrade dialog box. * Update changelog Co-authored-by: sebastienlagarde * Fix warning after metal fixup (#5704) * Various API doc update. (#5705) * Various doc + FrameSettings WIP * Finished frame settings API doc and added various other missing doc. Also made internal wrongly public API in HDRP * Fix density volume blend distance (#5698) * Fixed adjusting positive axis of Blend Distance slides the negative axis * Updated changelog * edit VR doc (#5699) * Hdrp/wizard update vr installation (#5706) * Add installatation checker in UsedPackageRetriever * Add PackageInstaller * Add better control on the displayed HelpBox * Update VR fixes * fix typo * Move Install Config Package Button above with HDRP Package info * Update CHANGELOG.md * Update documentation Co-authored-by: sebastienlagarde * Removing unused alpha threshold depth prepass and post pass for fabric shader graph (#5711) Co-authored-by: sebastienlagarde * Fix default volume profiles location (#5710) * Ray traced reflection smoothness fade and fallback fixes. (#5700) * Fix fall back for ray traced reflections when denoising is enabled Make Smoothness Fade start work with ray traced reflections Fix the blend of reflections based on the weight Add the contact shadow test scenes back * Change the name of the weight function and add it to all shading models Co-authored-by: sebastienlagarde * Fix iridescence color space (#5691) * Fix iridescence color space * Fixed compilation and updated test screenshots * fix test Co-authored-by: JulienIgnace-Unity * Fix Terrain Detail Mesh (stop to spam) [Require C++ PR] (#5690) * disable support of Terrain Detail Fix for error spam issue in HDRP: https://fogbugz.unity3d.com/f/cases/1211848/ * Update CHANGELOG.md * Update HDRenderPipeline.cs * Update HDRenderPipeline.cs * [Waiting for C++] Disable probes in renderers (#5648) * Disable probes section in the Renderer editors * Updated changelog Co-authored-by: sebastienlagarde * Merge Hdrp/fix/case 1210058 to master (#5612) * Fix for 1210058 - NaNs at certain view angles Issue is caused by NaNs/INFs when computing basis on extremely thin (subpixel-width) geometry. Putting some safeguards fixes the issue * Update CHANGELOG.md to reflect 1210058 fix. * Updated fix for issue #1210058 Overwrite the UVs to fix the derivatives. * Updated fix for issue #1210058 Make sure the UVs are zero if unused to fix the derivatives. * Undo last.change -- UV fix addresses NaNs Zeroing the unused UV1 channel on the material seems to do the trick. * Changelog adjustments to be moved Current version puts everything in HDRP, so there is no change in core. * Update CHANGELOG.md Reflect fix for NaNs * Fixed UV1 for lightmaps and detail maps. * update comment * Update NormalSurfaceGradient.hlsl Co-authored-by: JulienIgnace-Unity Co-authored-by: sebastienlagarde * Minor code cleanup * Added script documentation for SSR, SSAO (ray tracing), GI, Light Cluter, RayTracingSettings, Ray Counters, ray traced SSS andRecursive Rendering. (#5732) * Added script documentation for SSR, SSAO (ray tracing), GI, Light Cluster, RayTracingSettings, Ray Counters, ray traced SSS andRecursive Rendering. * udpate changelog * Implementation of ScreenSpaceReflections for Transparent materials (#4968) Co-authored-by: sebastienlagarde * Fix HDRP duplicated frame settings (#5850) * - Added a fallback for ray traced area light shadows in case the material is forward or the lit mode is forward. (#5749) - Fixed a bug related to ray traced area light shadow history. Co-authored-by: sebastienlagarde * Fix cookie index usage (#5871) * Hdrp/merge staging (#5943) * fix case 1205791 custom mesh issue (#5551) * fic case 1205791 custom mesh issue * Updated changelog * Added a call to Dirty() (#5420) * Added a call to Dirty() * Updated changelog Co-authored-by: Marc Templin * Fix shadergraph analytics. (#5912) * Fix analytics. * Added changelog * Fix for case 1200161 Save as subgraph issue (#5503) * Fix for case 1200161 * Edited CHANGELOG.md * Added comment to the code Co-authored-by: Sharlene Tan <43795986+sharlenet@users.noreply.github.com> Co-authored-by: Marc Templin * fix for unreported keyword bug (#5863) * Fixed fogbugz case 1197958 (#5671) * * Fixed fogbugz case 1197958. * * Updated CHANGELOG.md. * * Added spacing. * Added #if ENABLE_VR && ENABLE_VR_MODULE guard to XR code. * Added Logic to Inject render pass to base renderer (#5901) * Moved render pass injection code from Forward Renderer to ScriptableRenderer to be able to use for all renderers. * added changelog * Disabling the GetDefaultRenderer() test for now until it is redone. (#5924) * [Yamato] [skip ci] Setting up master to run on 2020.1 (#5936) * added 2020.1 and fast to editors * added 2020.1/staging and fast to the rest of the files * [CI] Bors setup (#5841) * Create bors.toml * Update bors.toml * Update bors.toml * Update upm-ci-projects.yml * Create testcommit * Update bors.toml * adding trying trigger * add staging trigger * Delete testcommit * use squash merge * updating job that bors will run * [skip ci] update job that bors will run * Fixed MAD and RCP definitions in OpenGL. (#5922) Co-authored-by: Martin Thorzen <35328557+martint-unity@users.noreply.github.com> Co-authored-by: Marc Templin Co-authored-by: Sharlene Tan <43795986+sharlenet@users.noreply.github.com> Co-authored-by: Zachary Diller Co-authored-by: thomas-zeng <49886741+thomas-zeng@users.noreply.github.com> Co-authored-by: Felipe Lira Co-authored-by: Elvar Örn Unnþórsson Co-authored-by: Liis Kivistik Co-authored-by: Sophia <16596228+sophiaaar@users.noreply.github.com> * Fix whitespace * Misc fixes for the sky (#5974) * Static lighting sky now takes the default volume into account. * Fixed a leak in the PBR sky renderer. * Added a tooltip to the Ambient Mode parameter in the Visual Environment volume component. * Update changelog * Fixed null ref * Fixed an issue where having ambient mode set to dynamic might prevent the sky from being included in baking. * Forces an update of static sky when changing it in the Environment panel. * Fixed a problem with static sky when multiple skies are rendered at the same time. * Revert probes renderer PR (#5990) * Re-enable the probes section of renderers as it was not supposed to be disabled * Updated changelog * Fix a leak in the sky system. (#5967) * Fixed a cubemap leak when rendering previews for the first time. Also changed the debug name of the cubemap used for static lighting. * Update changelog. * Fixed an assert getting fired for the wrong reason. * Added a new light layer debug mode (#5942) * Moved lighting debug settings in containers * Light layers debug mode * Categories for Lighting Debug Panel Documentation * Light layers debug mode documentation * DebugUI.BitField now uses correct display names * Added unit test scene * Added changelog * Revert "Added changelog" This reverts commit a148fc2f97ef5288123f8f16485ba35f57b80f5e. * Updated CHANGELOG * Disable light layer debug mode after testing * reset all debug display settings * Renamed Shadow Layers option * Editable layer color. Defaults to color blind friendly colors * Fix when enabling an exclusive setting * Updated screenshots with new colors * Simplified variable API * Renamed class * Fix division by 0. Updated doc Co-authored-by: Adrien * Hdrp/ssr toggle (#5996) * Added an "enable" checkbox to the SSR volume component. * Update changelog * Fix build when not in editor (#6024) * Fixed SSR in scene 1710 (#6028) * Fix merge error * Removed MSAA Buffers allocation when lit shader mode is set to "deferred only" (#6012) * Removed MSAA Buffers allocation when lit shader mode is set to "deferred only". * Removed MSAA SSS Buffer allocation when deferred only. * Invalid cast for realtime reflection probes (case 1220504) (#6026) * Invalid cast for realtime reflection probes (case 1220504) * Updated changelog Co-authored-by: sebastienlagarde * Aov Buffers tests (#6023) * Deactivate Preview Camera for HDCameraEditor to prevent it from rende… (#6022) * Deactivate Preview Camera for HDCameraEditor to prevent it from rendering in the render loop (case 1105163) * Updated changelog Co-authored-by: sebastienlagarde * Disable reflection probes section (#5994) * Disable reflection probes in the renderer components * Updated changelog * Remove version guard for terrainDetailUnsupported Co-authored-by: sebastienlagarde * Integrate first skeleton of post process in render graph. (#5856) * Fixed execution error without raytracing * Prepare Prepass refacto * Another round of preparation * Renamed XRPassScope to XRSinglePassScope * RenderAfterPostProcess is now static * Add AfterPostProcess to RenderGraph (WIP) * AfterPostProcess implementation * Fixed wrong RTHandle allocation * Fixed light layers texture binding during deferred lighting pass * Implemented Post Process Final Pass with RenderGraph * Post merge fixes * Fixed some issues with missing buffers in SSS and deferred lighting compute shaders. * Fixed alpha in post processes * Fix DXR Tests (#6073) * Made ssr enable parameter true by default. (#6076) * Add comment (#6056) * Hdrp /tests/shuriken light module (#6021) * Add shurikent light module test * Fixed Simulate * Fix texts and image ratio Co-authored-by: sebastienlagarde * Hdrp/pt7 (#5831) * Added support for anisotropy. * Tidied the code up, plus moved to correlated G term for aniso GGX. * Added anisotropic refractive sampling. * Disable path tracing for the shading graph preview camera. * Added support for alpha culling. * Fixed issue with transmission rays. * Updated Changelog. * Added support for punctual and directional light cookies. * Updated Changelog. * Added support for area light cookies. * Fixed bug with area cookies atlas not being properly generated when rebuilding library. * Made sure maxDepth > minDepth always, and added support for AO from mask. * Added support for transparent shadows. * Updated Changelog. * Toggling path tracing on/off does not reset iteration anymore. * Reverted change on enable, was causing minor issues. * Made sure we don't have transparent behaviour when shader is set to opaque. * Minor changes. * Tweaks on transparency behaviour. * Updated changelog. * Added path-tracing specific payload. * Added support for iridescence. * Updated Changelog. * Added multiple scattering compensation for specular. * Added Path tracing test. * PT test part 2. * Updated Changelog. * Added proper area light range attenuation. * Fixed issue with alpha clipping in ray-tracing. * Cosmetic. * Fix on the rect area light range. * In the editor, dragging manipulators around now resets accumulation. * Added material dirtiness tracking. * Does not apply intensity clamping to camera rays. * Reste PT iteration when saving a shader graph. * Added dirtiness tracking for acceleration structure and lights. * Added support for bg color. * Minor change to progress bar display. * Minor change to iteration counter, so that it never goes over the max. * Updated path tracing test. * Hdrp/rendergraph cleanup (#6083) * Fixed execution error without raytracing * Prepare Prepass refacto * Another round of preparation * Renamed XRPassScope to XRSinglePassScope * RenderAfterPostProcess is now static * Add AfterPostProcess to RenderGraph (WIP) * AfterPostProcess implementation * Fixed wrong RTHandle allocation * Fixed light layers texture binding during deferred lighting pass * Implemented Post Process Final Pass with RenderGraph * Post merge fixes * Fixed some issues with missing buffers in SSS and deferred lighting compute shaders. * Fixed alpha in post processes * Removed RenderGraphResource and RenderGraphMutableResource in favor of more explicit RendererListHandle and TextureHandle * Fixed decal normal patch pass * Fixed stencil resolve render pass * Fixed RenderDBuffer render pass function capturing variables. * Fixed wrong variable capture and restored ClearLightList to the render graph implementation of BuildGPULightList * Various fixes of things that diverged compared to regular path. * Unified renderer list and texture invalid handle error. * Revert wrong change * post merge fix * Removed useless comment. * Missing doc * Hdrp /fix light prefab infinite reload on inspector gui (#6054) * fix infinite reload loop for light prefab * Update CHANGELOG.md * Fixed an issue where fog sky color mode could sample NaNs in the sky cubemap (#6027) * Fixed an issue where fog sky color mode could sample NaNs in the sky cubemap. * Update changelog. # Conflicts: # com.unity.render-pipelines.high-definition/CHANGELOG.md * Fixed sampling of the sky texture in a more general way (not just fog) updated tests screenshots as well. * Missing screenshot * Fixed the issue properly by generating 7 mips of convolution. * Reverted screenshots * Reverted useless change. * Fix culling group was not disposed error in the build (#5880) * Fix culling group was not disposed error in build * Fix culling was not disposed error in build * Updated changelog Co-authored-by: sebastienlagarde * Fix Material Samples : Revert correct GUIDs (#5875) * Revert correct GUID Change the GUID of the prefab to the correct one referenced in the scene * Fix fern material GUID * Hdrp/light multiplier (#6077) * Allow the light dimmer to get values higher than one * Changelog Co-authored-by: sebastienlagarde * Update documentation typo (#5860) * Add warning and workaround instructions if XR single-pass is enabled after the first frame with XR SDK (#5853) * added warning and workaround instructions if XR single-pass is enabled after the first frame with XR SDK * edit VR doc * Updated CHANGELOG.md * Updated VR-Overview.md Co-authored-by: sebastienlagarde Co-authored-by: Sharlene Tan <43795986+sharlenet@users.noreply.github.com> * Remove info box on Visual Environment and replaced it with info on documentation (#6099) * Remove info box and update documentation * changelog Co-authored-by: sebastienlagarde * Update 9801_ShurikenLightModule.png * Add missing exposure and mipmap sliders to the planar reflection probe preview (#5847) * Added planar reflection probe preview mip and exposure sliders * Updated changelog * Disable mip map as we don't have them anymore * Re-edited changelog * Use SRP macros in shader Co-authored-by: sebastienlagarde * Fix upgrade cookie planar size (#6104) * Fixed the size of the planar reflection / cookie atlas after an upgrade of the HDRP asset * Updated changelog * Fixing merge issue for SSR transparent * Fix universal and yamato after merge. * fixuniversal after merge * renormalize files * Update 9801_ShurikenLightModule.unity * Make isEditorCameraPreview and sky public (#6147) * Update HDAdditionalCameraData.cs * Update SkySettings.cs * Update 9801_ShurikenLightModule.unity * Update HDAdditionalCameraData.cs * Update 9801_ShurikenLightModule.unity * Fixing ray tracing tests (#6158) * Fixed transparent SSR for shader graph. (#6163) * - Fixed transparent SSR for shader graph. * changelog * Added old graphics tests and modifications (#6143) * Update scenes * update blendstates * added OSX reference images * win reference images * fix lit light difference * Update blendstates-c-lit-unlit * disable check memory alloc due to ref probe issues * update ref images * rename test 1709 to 1711 * rename test 1709 to 1711 - bis Co-authored-by: sebastienlagarde * Fix issue with blend mode and with keyword (#6164) * Fixed an issue with emissive light meshes not being in the RAS (#6174) * Hdrp/pt8 (#6090) * Added support for anisotropy. * Tidied the code up, plus moved to correlated G term for aniso GGX. * Added anisotropic refractive sampling. * Disable path tracing for the shading graph preview camera. * Added support for alpha culling. * Fixed issue with transmission rays. * Updated Changelog. * Added support for punctual and directional light cookies. * Updated Changelog. * Added support for area light cookies. * Fixed bug with area cookies atlas not being properly generated when rebuilding library. * Made sure maxDepth > minDepth always, and added support for AO from mask. * Added support for transparent shadows. * Updated Changelog. * Toggling path tracing on/off does not reset iteration anymore. * Reverted change on enable, was causing minor issues. * Made sure we don't have transparent behaviour when shader is set to opaque. * Minor changes. * Tweaks on transparency behaviour. * Updated changelog. * Added path-tracing specific payload. * Added support for iridescence. * Updated Changelog. * Added multiple scattering compensation for specular. * Added Path tracing test. * PT test part 2. * Updated Changelog. * Added proper area light range attenuation. * Fixed issue with alpha clipping in ray-tracing. * Cosmetic. * Fix on the rect area light range. * In the editor, dragging manipulators around now resets accumulation. * Added material dirtiness tracking. * Does not apply intensity clamping to camera rays. * Reste PT iteration when saving a shader graph. * Added dirtiness tracking for acceleration structure and lights. * Added support for bg color. * Minor change to progress bar display. * Minor change to iteration counter, so that it never goes over the max. * Updated path tracing test. * Added finer estimates of lights during global pdf computation. * Refined light estimates during light list creation. * Updated PT test after changes to light sampling. * Minor change on samples count dirtiness handling. * Cosmetic, plus include guards. * Separated the path intersection structure from the ray tracing one. * Cosmetic, plus taking SSS weight into account to reduce diffuse. * Added SSS support for path tracing, and made some minor changes to the ray-traced version. * Minor code refactor. * ... * ... * Post-merge cleansing. * Fixed minor issues in CreateMaterialData(). * Fixed issue with test framework and resolution change. * Avoid error msg on null instance in PathTracing.cs. * Pathtracer new automated scenes (#6053) * Add global GI automated test scene * Adding transparency test scene * Update max samples of transparency scene to 32 * Added area light test scene / Updating reference image * Transparency scene settings + ref image * Scene added to build (Editor build settings) * Update tranparency image ref * Updating scene to 1 spp and ref image Also moving the asset to common assets folder * Re-added support for unlit shader graph. Co-authored-by: remi-chapelain <57442369+remi-chapelain@users.noreply.github.com> * Update RTSSS Screenshots (#6177) * Fix DX12 and DXR Player build and Updating the test screenshots for DXR player tests (#6130) * Fix DX12 and DXR Player build Updating the test screenshots for DXR player tests * fix shader graph case Co-authored-by: sebastienlagarde * Update CHANGELOG.md * Fix shader compilation issue with Vulkan and Raytracing (#6181) * update path tracing and 1219 test * Fix hdasset migration code not being called after a package upgrade (#6179) * Fix the HDRP asset migration code not being called after a package upgrade * Updated changelog Co-authored-by: sebastienlagarde * Fix custom pass out of bounds (#6176) * Fix draw renderers custom pass out of bound exception * Updated changelog Co-authored-by: sebastienlagarde * Fix PBR master node (#6182) * Fix PBR shader render states * Updated changelog * Fix some typos in the debug menu (#6097) * fix some typos * Revert typo fix that break public API * Changelog * Add regenerated shader includes Co-authored-by: sebastienlagarde * Fixed ray traced point and spot lights shadows not rejecting history when semi-transparent or colored. (#6108) * Fixed ray traced point and spot lights shadows not rejecting history when semi-transparent or colored. * Removing unwanted skip closest hit Co-authored-by: sebastienlagarde * Diffuse Shadow Denoiser Improvement. (#5851) * - Added a new mode that improves the filtering of ray traced shadows (directional, point and spot) based on the distance to the occluder. Added new test scenes to test the denoiser improvement * Update changelog * Fix an issue with the shadow denoiser grabiing data outside of the screen * changing light parameter to internal * Fixed a warning due to StaticLightingSky when reloading domain in some cases. (#6193) * Fixed the MaxLightCount being display when the light volume debug menu is on ColorAndEdge. (#6211) * Fixed the MaxLightCount being display when the light volume debug menu is on ColorAndEdge. * Update com.unity.render-pipelines.high-definition/CHANGELOG.md Co-Authored-By: Motiejus Viltrakis <36502659+iM0ve@users.noreply.github.com> Co-authored-by: sebastienlagarde Co-authored-by: Motiejus Viltrakis <36502659+iM0ve@users.noreply.github.com> * Update documentation to mention more explicitely the lack of support of vertex animation (#6207) * Update documentation to mention more explicitely the lack of support of vertex animation * Update Ray-Tracing-Getting-Started.md Co-authored-by: sebastienlagarde * Make subsection in decal debug menu to specify "affect transparents" (#6200) * Make subsection in decal debug menu * changelog Co-authored-by: sebastienlagarde * Added coverage for Enabled GPU Instanced material (#6183) For light layers automated test * Support cookie on light backing for Disc Area Light (#6138) * Added support for light cookies in the baking backends. * Updated light conversion script to reflect the latest changes made to the API. * Added support for directional light cookie sizes. * Added support for cookies on rectangular area lights. * Enable Area::Disc Light on backing with cookie * Update ChangeLog * Update CHANGELOG.md Co-authored-by: uygar Co-authored-by: sebastienlagarde * Hdrp /lookdev/fix crash on adding volume as viewed game object (#6129) * Update Volume's Layer when moving them to LookDev's stage * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Add smoothness remark (#6226) * Removed unexpected file * Removed legacy VR code from HDRP (#5923) * Removed legacy VR code * do not set CullingOptions.Stereo with xrsdk * re-add and tag previous function signature as obsolete Co-authored-by: sebastienlagarde * Improve light clipping and culling #2 (#4711) * Improve area light culling * Simplify * Clip box lights at the attenuation range * Save 1x ALU * Add missing feature flags * Chanelog Co-authored-by: EvgeniiG <7ee2cc898cca1b5fc49df740c2081dfc681e0a28> Co-authored-by: Sebastien Lagarde * Hdrp/fix/decal material ui errors (#6225) * Fixed error in the console when switching shader to decal in the material UI * Updated changelog Co-authored-by: sebastienlagarde * Fix z-fighting in sceneview when scene lighting is off (#6213) * Do not override the depth state of transparent materials in RenderDebugView * Changelog * Changelog - add case number Co-authored-by: sebastienlagarde * Mention default post processing in default volumes. (#6232) * Fix cubemap inspector so that thumbnail for cubemap work (#6231) * Fix for missing thumbnail on cubemaps * Changelog * Better default angles Co-authored-by: sebastienlagarde * fix ray tracing with VR single-pass (#6242) * - Fix an exception in ray tracing that happens if two LOD levels are using the same mesh renderer. (#6198) Co-authored-by: sebastienlagarde * update location of reference screenshots after merge * Added debug exposure to light hierarchy debug. (#6215) Co-authored-by: sebastienlagarde * - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. (#6251) Co-authored-by: sebastienlagarde * Hdrp/pt9 (#6184) * Added support for anisotropy. * Tidied the code up, plus moved to correlated G term for aniso GGX. * Added anisotropic refractive sampling. * Disable path tracing for the shading graph preview camera. * Added support for alpha culling. * Fixed issue with transmission rays. * Updated Changelog. * Added support for punctual and directional light cookies. * Updated Changelog. * Added support for area light cookies. * Fixed bug with area cookies atlas not being properly generated when rebuilding library. * Made sure maxDepth > minDepth always, and added support for AO from mask. * Added support for transparent shadows. * Updated Changelog. * Toggling path tracing on/off does not reset iteration anymore. * Reverted change on enable, was causing minor issues. * Made sure we don't have transparent behaviour when shader is set to opaque. * Minor changes. * Tweaks on transparency behaviour. * Updated changelog. * Added path-tracing specific payload. * Added support for iridescence. * Updated Changelog. * Added multiple scattering compensation for specular. * Added Path tracing test. * PT test part 2. * Updated Changelog. * Added proper area light range attenuation. * Fixed issue with alpha clipping in ray-tracing. * Cosmetic. * Fix on the rect area light range. * In the editor, dragging manipulators around now resets accumulation. * Added material dirtiness tracking. * Does not apply intensity clamping to camera rays. * Reste PT iteration when saving a shader graph. * Added dirtiness tracking for acceleration structure and lights. * Added support for bg color. * Minor change to progress bar display. * Minor change to iteration counter, so that it never goes over the max. * Updated path tracing test. * Added finer estimates of lights during global pdf computation. * Refined light estimates during light list creation. * Updated PT test after changes to light sampling. * Minor change on samples count dirtiness handling. * Cosmetic, plus include guards. * Separated the path intersection structure from the ray tracing one. * Cosmetic, plus taking SSS weight into account to reduce diffuse. * Added SSS support for path tracing, and made some minor changes to the ray-traced version. * Minor code refactor. * ... * ... * Post-merge cleansing. * Fixed minor issues in CreateMaterialData(). * Fixed issue with test framework and resolution change. * Avoid error msg on null instance in PathTracing.cs. * Pathtracer new automated scenes (#6053) * Add global GI automated test scene * Adding transparency test scene * Update max samples of transparency scene to 32 * Added area light test scene / Updating reference image * Transparency scene settings + ref image * Scene added to build (Editor build settings) * Update tranparency image ref * Updating scene to 1 spp and ref image Also moving the asset to common assets folder * Fog support WIP... * Added support for fog attenuation. * Cosmetic. * Set a maxSampleCount to 1 for tests only in play mode. * Updated Changelog. * Cosmetic. * Take min and max depth into account for fog color. * Make sure we are inside the light cluster when buidling light list. * Simplified signature of RenderPathTracing() func, replaced RaytracingFrameIndex with RaytracingSampleIndex. * Taking max fog distance into account. * Fog max dist part2. * Added a new test scene for the fog * move reference screenshots Co-authored-by: remi-chapelain <57442369+remi-chapelain@users.noreply.github.com> Co-authored-by: Remi Chapelain Co-authored-by: Sebastien Lagarde * Hdrp/volume debug (#6058) * New widget DebugUI.Table * Opened some Volume related API * New volume debug panel * Fixed a bug when debugging editor cameras * Fixed table border color. Updated documentation * Handles inactive and removed components * Don't show deprecated volume components. Sort by name * Revert unwanted modification * Handle disabled volumes * Hides volumes that don't affect the final value * Code documentation * Add range check * Fix player build * Fix volume influence detection * Refresh display when components changes * Fix error on player build * Reduce popping * Use editor camera as anchor point * Select all layers for the scene camera * Un-open profileRef API * Remove ref to profileRef * Proper component name, show text for non supported parameters * Fix profile duplication when using volume debug menu * Updated unsupported parameters message. Show a name as fallback if it exists Co-authored-by: sebastienlagarde * Fixing HDRP_DXR_TEST not having local package at right location (#6107) * Clearer naming of tile and cluster categories for environment lights (#6227) * Rename Environment to Probes * changelog Co-authored-by: sebastienlagarde * Fixed an issue with refraction model and ray traced recursive rendering (case 1198578). (#6267) Co-authored-by: sebastienlagarde * fix for Fogbugz 1214609 - HDRP Wizard addively increases the Light Intesity instead of setting it (#6266) * Fixed an issu… * Use multi_compile for Shadow mask variants of deferred (#6322) * shadow mask * Changelog Co-authored-by: sebastienlagarde * Moves constant buffers to being global for ray tracing (#6300) * - Changed a few resources used by ray tracing shaders to be global resources (using register space1) for improved CPU performance. * issue in path * review corrections * Fix decal debug menu register (#6352) * Removing the usage of the render queues to identify what is rendered using recursive rendering (#5858) * - Remove the raytracing rendering queue system to make recursive raytraced material work when raytracing is disabled * Update dxr test mats * Update HDRP Tests materials * manually save Font Material SG to apply code change to m_CustomRenderQueue * Bump material version for vfx HDRP project Co-authored-by: Fabien Houlmann * StackLIt: Fix a SG Targets regression - Make sure the scene selection pass also uses the editor_sync_compilation pragma [skip ci] (#6354) * Execute all custom pass volumes (#6355) * Excute all custom pass volumes instead of the first one * Updated changelog * Updated documentation * Fix priority * Fixed typos * Hdrp/fix material baked emission (#5392) * fix backed emission inspector for material * Update CHANGELOG.md * Clean code * update PBR graph (for HDRP) and HDRP Shader graph baked emission Co-authored-by: sebastienlagarde * Fix case in PBR sky where a camera below ground might invalidate result of a camera above (#6272) * Incorporate the above/below ground in the sky hash and make planar reflection use parent camera position * changelog * add comment Co-authored-by: sebastienlagarde * Fix custom pass gc alloc (#6371) * Fixed GC alloc issue in custom pass GetActiveVolumes() * Updated changelog * Update xml doc Co-authored-by: sebastienlagarde * - Added support for fog in Recursive rendering, ray traced reflections and ray traced indirect diffuse. (#6324) Co-authored-by: sebastienlagarde * replaced blue material spheres with SG_Lit, added reference images (#6369) * Added an alpha blend option for recursive rendering (#6286) * Added an alpha blend option for recursive rendering * Adding a test scene to test non refractive transparent objects in recursive rendering Co-authored-by: sebastienlagarde * Fixed an issue where the wrong instance of the debug setting was used in some places. (#6368) * Update 8101_Opaque to use SG material with Parallax Occlusion Mapping Node (#6389) * Updated 8101_Opaque scene and added reference images * Updated camera to fit the test * Added support for stack lit for ray tracing effects. (#6312) * - Added support for stack lit for ray tracing effects. * Forgot to push the prefab * specular lobe fix * Fix geometricAA issue in shader graphs for lit and stacklit * Fix merge issues and fix screenshot due to other PR * - Added support for hair for ray tracing effects (#6327) * Avoid negative input to sqrt() (#6397) - The calculation of `k` is not numerically robust when done in FP16 and might generate a negative value. - This can be observed as rendering artifacts on Mali drivers newer than Bifrost/Valhall R21. - This commit fixes this by by clamping `k` to [0, inf] before the `sqrt()`. - On Mali-G77 the clamp compiles down to a free output modifier on the previous instruction, so there's no performance impact. * Major changes to Temporal Anti Aliasing (#6348) * First commit with some stuff, lots of things to do, clean and change, but want a savepoint * Tiny bit of cleanup * tiny refactor to allow faster experimentation * Small refactor for ease of use * leftover from prev commit * Sharpening (and some garbage to remove) * Now need to optimize a lot... * Before cleanup, but sort of locked otherwise * CTYPE conversion, to be tested yet. * Add alpha support and make sure we run Bilinear if sharpening of history is off * Pre emptively patchup ray tracing denoisers * More patchup * a bunch of random stuff since I need the branch remote * Anti ringing option and some UI (need further checks on perceptual space) * fix cross sampling * Fix sharpening in perceptual space being off * Merge home branch * small tweaks * Leftover * Missing CTYPE * re-enable ycocg * Remove old TAA stuff * Squashed commit of the following: commit 0498f2dd6eb83efd9861b732c51f7c40acc0043c Merge: c54437014ee acebb9a8ca5 Author: sebastienlagarde Date: Mon Mar 23 12:05:28 2020 +0100 Merge branch 'master' into HDRP/staging commit acebb9a8ca5ca0be472b49ade74fa02cac29ee4e Author: UPM-CI <> Date: Mon Mar 23 10:42:25 2020 +0000 Auto bumped package versions: com.unity.render-pipelines.core: 9.0.0-preview.3 com.unity.render-pipelines.high-definition-config: 9.0.0-preview.4 com.unity.render-pipelines.high-definition: 9.0.0-preview.3 com.unity.render-pipelines.lightweight: 9.0.0-preview.4 com.unity.render-pipelines.universal: 9.0.0-preview.4 com.unity.shadergraph: 9.0.0-preview.3 com.unity.visualeffectgraph: 9.0.0-preview.3 commit 02d1177b769037392a7be444c1c192c763038e20 Author: Antoine Lelievre Date: Mon Mar 23 11:36:57 2020 +0100 Fix texture curve breaking change (#6323) * Fix API breaking change in TextureCurve * Updated changelog * Update CHANGELOG.md Co-authored-by: sebastienlagarde commit c54437014ee95c42ec4c320cfc4883052c17701e Merge: 0e1815814ce ba9b6321f9d Author: sebastienlagarde Date: Sat Mar 21 19:33:49 2020 +0100 Merge branch 'master' into HDRP/staging commit ba9b6321f9d3c6740748d7743143f6b968d5f5e6 Author: sebastienlagarde Date: Fri Mar 20 16:53:28 2020 +0100 Update HDAdditionalLightData.cs (#6309) commit 8a332873526444e4fb944f3eb0022c4ab431eb85 Author: Zachary Diller Date: Fri Mar 20 15:44:45 2020 -0700 Override ShaderGUI per ShaderGraph [skip ci] (#6192) * first push with the field and generation changes, pre hd & urp master node changes * added changes to URP and HDRP Master Nodes * and changelog for shadergui override per sg * minor cleaning * Changelog fix * documentation changes * code review & qa bug fixes * Updated PBR-Master-Node.md * Updated Unlit-Master-Node.md * Edited PBR-Master-Node.md * Edited Unlit-Master-Node.md * Added indentation * Added indentation * Removed final sentence "ShaderGUIs inside the UnityEditor namespace might omit UnityEditor." * Removed final sentence "ShaderGUIs inside the UnityEditor namespace might omit UnityEditor." * Fixed formatting. * HDRP Documentation Changes * master merge fix Co-authored-by: Sharlene Tan <43795986+sharlenet@users.noreply.github.com> commit bb27f146b5c8f675575feb2a38b57ef51f50c4a1 Author: Adrien de Tocqueville Date: Fri Mar 20 18:34:30 2020 +0100 Added AlphaToMask render state (#6292) commit e5de5977a1ba7e0794364be240e27407d2aed1c6 Author: Jans Margevics <50581102+JMargevics@users.noreply.github.com> Date: Fri Mar 20 16:27:17 2020 +0100 Shell script for generating tarballs on OSX (#6305) * Shell script that generates tarballs on OSX * Fix incorrect package name commit 60d42b2978e0f82260010ad24b437f4fc8934dea Author: Elvar Örn Unnþórsson Date: Fri Mar 20 12:15:50 2020 +0100 Fixing GLES2 & PP issue (#6257) # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md commit 453d33144a135b366ae3e02531b0fd30fd118ba6 Author: Sophia <16596228+sophiaaar@users.noreply.github.com> Date: Fri Mar 20 11:56:39 2020 +0100 Update PULL_REQUEST_TEMPLATE.md (#6303) * Update PULL_REQUEST_TEMPLATE.md commit d2684ff856057e9299aac1d550f6552ea5fc0e29 Author: UPM-CI <> Date: Fri Mar 20 09:59:08 2020 +0000 Auto bumped package versions: com.unity.render-pipelines.core: 9.0.0-preview.2 com.unity.render-pipelines.high-definition-config: 9.0.0-preview.2 com.unity.render-pipelines.high-definition: 9.0.0-preview.2 com.unity.render-pipelines.lightweight: 9.0.0-preview.2 com.unity.render-pipelines.universal: 9.0.0-preview.2 com.unity.shadergraph: 9.0.0-preview.2 com.unity.visualeffectgraph: 9.0.0-preview.2 commit 157dcd3fb58e6b8a99c4b7422235baa896349ec7 Author: Andre McGrail Date: Fri Mar 20 10:24:25 2020 +0100 [Bugfix]1069375 metallic gamma tag (#6194) * Removed Gamma tag on metallic value * Updated changelog, fixed spelling in previous changelog entry Co-authored-by: Felipe Lira commit 9ad5221932cfb7e5b94f6c72c1922d3f559e006b Author: Felipe Lira Date: Fri Mar 20 10:23:39 2020 +0100 Use 2-component edge texture for SMAA on Mali (#6066) (#6196) The SMAA edge texture only requires 2 components, but using 4 may be faster on some vendors (SMAA authors mention it is faster on Nvidia). 2 components is faster on Mali, so make sure 2 components is used when running on a Mali device but keep 4 components for other vendors. Measurements were done in the URP default template scene with SMAA on medium settings and all other post-processing effects turned off on a Mali G-76. Mali Core Internal Bus Write Beats: Tile buffer internal -12.6% (+-2.3%) Mali Core Tiles (CRC): Killed tiles: +16.1% (+-2.3%) Mali External Bus Accesses: Write transaction: -10.9% (+-2.3%) Mali External Bus Beats: Write beat: -10.8% (+-2.3%) Mali External Bus Outstanding Writes: 0-25%: -14.8% (+-2.1%) Mali L2 Cache Lookups: Write lookup -10.2% (+-3.2%) Co-authored-by: AlbinBernhardssonARM <60749571+AlbinBernhardssonARM@users.noreply.github.com> commit b970bd9625250305a1ee5af65cadf3f7ead89b89 Author: unity-cchu <47998819+unity-cchu@users.noreply.github.com> Date: Fri Mar 20 17:22:34 2020 +0800 2d/shader color fix (#6016) * Fixed problem with sprite shape where color doesn't work properly * Updated changelog Co-authored-by: Felipe Lira commit 9b9ec3d54807e495cee50c2ad04c93203b3a3302 Author: Sai Narayan Natarajan Date: Thu Mar 19 19:26:48 2020 -0700 Fix for bug 1227659 : NullReferenceException when saving a shader graph in a URP project with the HDRP package also present (#6280) * Fix for shader graph nodes not pasting at the cursor location * Revert "Fix for shader graph nodes not pasting at the cursor location" This reverts commit b18f4b1c8606286c757a27039b209884f9d20138. * Fix for bug 1227659 Fixes this bug: https://fogbugz.unity3d.com/f/cases/1227659/ Co-authored-by: Sai Narayan commit badd32410920ae8a2ad01c94b41ecb6dc808a1a1 Author: Sharlene Tan <43795986+sharlenet@users.noreply.github.com> Date: Thu Mar 19 15:06:44 2020 -0700 Added vertex position, vertex normal, and vertex tangent to master nodes docs (#6281) commit 0e1815814ce8204cfa42ae3050ba655fe769c550 Merge: ac6809ec032 2b018dfe8a9 Author: Sebastien Lagarde Date: Thu Mar 19 18:19:45 2020 +0100 Merge branch 'master' into HDRP/staging commit 2b018dfe8a9f5f304e4b95d6279dda60f632c9dc Author: sebastienlagarde Date: Thu Mar 19 18:19:02 2020 +0100 Merge Hdrp/staging (#6293) * Custom pass cleanup (#5507) * Fix custom pass cleanup issue with multiple volumes * Updated changelog * Delay discard of fragments during decal projection (#5283) * Delay discard of fragments during decal projection Metal Shading Language declares that fragment discard invalidates derivatives for the rest of the quad, so we need to reorder when we discard during decal projection, or we get artifacts along the edges of the projection (any partial quads get bad partial derivatives regardless of whether they are computed implicitly or explicitly). * Better re-arrangement of decal code * Update TerrainLitPasses.hlsl * Update TerrainLitPasses.hlsl * Update TerrainLitPasses.hlsl * Update ShaderPassDecal.hlsl Co-authored-by: sebastienlagarde * Fixing unnecessary memory allocations in the ray tracing cluster build and Updating the screen shots for the ray tracing tests (#5465) * Fixing unnecessary memory allocations in the ray tracing cluster build Updating the screen shots for the ray tracing tests * Update test scene and screenshots * - Discarding the ray tracing history for AO, reflection, diffuse shadows and GI when the viewport size changes. - Update and disable some tests that still need to be updated * Add a counter for ray tracing frame index and update screenshots * Fixing the Area Shadows Denoiser Test Co-authored-by: sebastienlagarde * Change the default volume used by the ray tracing tests to make them work again (#5510) * Change the default volume used for the ray tracing tests, fixes the tests back. * Fix access to the ray tracing frame index in ray tracing ambient occlusion (doesn't change behavior) * Missing term in the ray tracing frame index access (#5511) * Fix colum headers (#5517) * Fix colum headers * Update CHANGELOG.md * Rename post formats (#5505) * Renamed the post processing format to the new convention * Updated changelog Co-authored-by: sebastienlagarde * Fixed the first frame flash with auto exposure (#5491) * Fixed flashes with low and high exposure scenes when Automatic Exposure is in use * Moved postfx history reset to per-camera reset Co-authored-by: sebastienlagarde * Update DefaultSettingsVolumeProfile.asset * Hdrp/small enhencements for DXR (#5493) * Add Warning for DXR and AsyncExecution in FrameSettings * move restarting at end of all fix in wizard for DXR * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Hdrp/update default scenes (#5485) * Replace default scenes with scene prepared for scene-template * Update of DefaultSettingsProfile * Update DXR scene * Add ScreenSpaceShadow to Camera's default FrameSettings * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Refactoring pre-existing materials to share code between rasterization and ray tracing (#5441) * Refactoring pre-existing materials to share code between rasterization and ray tracing Update the test scene * update changelog * Changing the color of an unlit in the reflection test scene * review corrections * Fixing unlit shader graph * Fix specular AA related issue * Update the reflection test * Fix an issue with debug display for ray tracing shaders Always use ray tracing frame index 0 for ray tracing tests Update tests screenshots Update ray traced reflection test scene Co-authored-by: sebastienlagarde * Hdrp/staging thin (#5509) * Adding a REFRACTION_THIN model. * Fixed thin distance. * ... and fixed it. * Updated changelog, removed unused REFRACTION attrs from Fabric template. * Added a REFRACTION_THIN_DISTANCE macro. * Finished support for thin refraction. * Fixed LitTesselation (was missing thin refraction model). * fix issue when merging Refactoring of DoAlphaTest * Fixed an issue where passing a null ProfilingSampler would cause a null ref exception. (#5555) * Fixing the area shadow denoised test (#5544) * Fix leak in Sky when matcap view (#5556) * skip pre render sky in matcap view * changelog Co-authored-by: sebastienlagarde * Fix compilation issues of ApplyExposure on platforms that don't support VR (#5575) * Fix * changelog * Remove Preview from physically based sky * HDRP asset migration (#5580) * Initialize the HDRP asset version to the latest one so new assets are not migrated * Updated changelog * Hdrp/remove wind resources (#5578) * Remove wind resources Remove wind resources no longer used and containing big files * Update changelog * revert: Hdrp/update default scenes (#5485) * Fix issue with missing texture in test * Disable POM test in 1708 SG_OnSG as it is unstable * Add missing texture in runtime test * update caption for geometric normal debug in forward * add missing texture to runtime test * Create Textures.meta * fix SG on decal SG * Fixed an issue where ambient occlusion and screen space reflections editors would generate null ref exceptions when HDRP was not set as the current pipeline. (#5577) * Fixed a null reference exception in the probe UI when no HDRP asset is present. (#5582) * Fixed a null reference exception in the probe UI when no HDRP asset is present. * Indentation Co-authored-by: sebastienlagarde * Fix custom pass outline (#5590) * Fixed custom pass outline resolution screen resolution dependent * Updated changelog Co-authored-by: sebastienlagarde * Fixed a null reference exception in the HDRI Sky editor when no HDRP asset is present. (#5596) Co-authored-by: sebastienlagarde * Fix decal orientation when created from script. (#5592) * Fixed all migration classes to default to latest version so that Decals created by script to get migrated. Fixed decal created through context menu so that they get the proper rotation convention. * Update changelog * Moved the GetEnumLastValue to TypeInfo class * Updated super old test scenes to the proper latest version for decals Co-authored-by: sebastienlagarde * Refactor of HDCamera (accesibility mostly) [Skip CI] (#5548) * Refactor of HDCamera - Made internal/private APIs that should not have been public - Fixed naming convention for private members - Moved everything by accessibility for clarity (public, internal, then private) * Added Doc and returned some API public. * Fix visibility of Density Volumes in reflections [Skip CI] (#5589) * Oblique projection frustum fix, first try * HDCamera frustum now recalculates near and far plane to avoid issues with oblique projection matrices. * Update changelog * Added comments * Indentation * Fixed camera relative position of frustum * Indentation * Fixed a null reference exception in Path Tracing, Recursive Rendering and raytraced Global Illumination editors when no HDRP asset is present. (#5597) Co-authored-by: sebastienlagarde * Fix ray tracing tests and add a test scene for lights and cookies in ray tracing (#5604) * expose StartSinglePass() and StopSinglePass() as public interface for XRPass (#5605) * Add missing custom pass API documentation (#5530) * Add missing custom pass API documentation * Fix doc spells and grammar * Stencil Refactor and Material migration fixes (#5581) * Remove leftover code * commit to switch machine * Remove hard coded stencil values in shaders * clear stencil * tmp commit, start of splitting decal in dbuffer and normal patchup * Make decal patching up run after GBuffer * Remove hardcoded value for SSS split lighting * Tmp commit to switch branch * Finalize build coarse stencil (with debug leftover and render graph NOT handled) * The AA bits (the easy one :-) ) * split in two enums * Distortion vectors bit sorted * SSR bit * Motion vector bit * decals bit * Lighting bits * Use HTile for SSR * HTile SSS -> Incomplete, verify and test. * SSS fixes, but still not working (probably not HTile related, but main stencil) * Make decal patch normal work and remove stencil bit * some leftover fixes * was commited by mistake * Update materials * Revert "Update materials" This reverts commit 4a0de82ef51750b77546020d77ad6b5d773e60af. * Fix issues with MSAA and with migration * Forgot this out * update materials and maps * default materials * don't have SSR on unlit * Fix some leftovers * Renaming * Revert "update materials and maps" This reverts commit 103f1cb71d8fffa49b0c2ef57f1b41b36d0a3dbf. * Revert "default materials" This reverts commit 978740acd825562717a01437dcc0c74fc4cfefb0. * Fix migration * white line * Fix migration * Add render queue overide to the material placer. Also add PackageInfo.cs to HDRP, so the graphic tests can call it's internal methods and objects. * Default material post migration * com.unity.testing.hdrp post reimport * Updated materials from test * Disable tests that are to be updated or not needed anymore * Fix VFX issues (To be fixed better by @PaulDemeulenaere ) * Lit hardcoded default was off * Update VFX Test materials ( @PaulDemeulenaere for awareness ) * Fix issue with stencil in TAA * Revert lighting data * revert light map data * Revert other lighting asset * Cleanup post processor. * Update DXR test material * Update commnets * Early (need testing) new migration workflow * Revert "Early (need testing) new migration workflow" This reverts commit 2db025002d66165dd00e90f5f5d3c944ed53f361. * Update post processor * Add manual option to migrate * Add dialog box Co-authored-by: RemyUnity <32760367+RemyUnity@users.noreply.github.com> * Push updated hdrp version in test project (#5617) * Push m_LastMaterialVersion update * Dont open dialog on yamato * Update test projects with recent stencil refector PR (#5618) * Update runtime test project * Create HDRPProjectSettings.asset * update DXR project * Revert "update caption for geometric normal debug in forward" This reverts commit 150d68279b891529be272b37f374c36b879646f4. * Run reimport during update (to avoid unwanted extra dialog during dialog box) (#5620) * Make user stencil bits public (#5616) * Expose bits to user * Update documentation * Update HDStencilUsage.cs Co-authored-by: sebastienlagarde * Implement history rejection based on object velocity (#5532) * Implement history rejection based on object velocity * Update changelog * Fix an issue with ambient occlusion denoising being broken after adding the history rejection feature Adding the GPU Light type for history validation and rejection Co-authored-by: sebastienlagarde * Fixed initial state of material created through the context menu. (#5603) * Fixed an issue where materials newly created from the contextual menu would have an invalid state, causing various problems until it was edited. * Forgot DecalUI (for non shader graph decals) Co-authored-by: sebastienlagarde * Update HDLightUI.Skin.cs * Cookie and planar atlas (#5518) * Added support for cookie atlas * Begin to move planar reflection into atlas * Added texture atlas for planar reflection probe plus a limit to on screen planar probes * Removed debug log * Fixed planar probe atlas scale issue and useless mipmap generation of the atlas * Refactor Texture2D atlas * Move ScaleBias for planar probes to a separate list * Fix cookie mode for directional lights * Added error log for non square cookie textures in the atlas * Fix merge * Fixed cookie atlas * Trying to fix area light cookies * Fixed area light cookie * Disable mipmap for non area light cookies * Added cookie atlas format control + fixed size warnings in HDRP cookie ui * Add resolution in Capture Settings reflection probe drawer * Removed warnings * Added the point light cookie texture array in the debug menu * Fix cookies in ray tracing + celestial body texture * Update dynamic light cookie screenshot * Update Animated cookie test + fix reflection probe texture format * Fix area light cookie * Update HDRP asset cookie and planar atlas sizes * Increase cookie atlas size for area light test * Simplify code * Fix cookie mip clamp * Fixed compilation and CG alloc * Added atlas layouting when there is no more space * Fix directional light cookie * Updated reference image of cookie area lights * Fix hardcoded format and cookie layout * Remove useless mip update * Fix area light cookie x flip * Added the debug exposure option for debug planar reflection atlas * reverted the fix for area light cookie x flip * Tried to simplify the code of the atlas * Update reference image * Added an error when max planar reflection probe on screen is reached * Fixed space parenthesis * Fixed mipmap not updated properly and area light cookie convolution temp texture format * Fixed atlas reset mips * Update tooltip and fixed cookie insertion order when there is no more space in the atlas * Enable exposure on cookie atlas debug * Fix debug overlap * Update reference image * Added migration code for the cookie atlas size and fixed point light cookie debug exposure * Added planar atlas size upgrade code * Updated planar reflection atlas message * Fixed resolution dependent cookie mip maps * Updated changelog * Fixed cookies for ray tracing * Fix cookie in the ray tracing light loop requested without being reserved * Clamp UV when doing the area light convolution * Update reference images * Remove debug symbols * Fixed area light convolution UV limit * Fixed half pixel clamp and updated reference images * Fixed planar reflection mip map edge bleeding and update reference images * Updated more image reference * Updated DXR cookie test scene * Fix default material transparent created with ZWrite enabled (#5621) * Fixed transparent material craeted with ZWrite enabled * Updated changelog Co-authored-by: sebastienlagarde * Hdrp/fix decal gizmo mouseover (#5626) * Remove controlID on projection direction of DecalProjector that conflict with other handles * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Hdrp/smallfixes lookdev (#5619) * Fix zoom being stuck around 0 * fix crash forbiding view manipulation while using directly hdri without passing by an environment * Fix hitch in FPS displacement mode * Fix when user destroy the EnvironmentLibrary being used. * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Mask was never set for some debug pixel deferred shaders [Skip CI] (#5627) * Mask was never set * changelog * Added comments Co-authored-by: sebastienlagarde * Fixed an issue where creating decals at runtime could cause a null reference exception. (#5594) Co-authored-by: sebastienlagarde * Make APIs internal when they should be - 1 - [Skip CI] (#5531) * First pass of making APIs internal when they should be. * Indentation * Compilation fixes + review feedback. * Make APIs internal when they should be - 2 - [Skip CI] (#5533) * First pass of making APIs internal when they should be. * Indentation * WIP * Missing file * More * Revert some changes based on review feedback * Compilation fix * Compilation fixes + review feedback. * Updated HDUtils accessibility * More editor internals. * Better (not hardcoded) stencil handling in VFX (#5624) * Stencil update for vfx * Fix issues * fix missing templates * Avoid displaying material upgrader dialog on new project (#5631) * Don't run dialog on new project creation * skip only on first creation * Check file existence before showing dialog * typo * Push test materials after ZWrite PR (#5632) * Update HDRP_Test project * Update DXR test assets * Update run time tests * Discard invalid pixels when doing deferred lighting in compute (for camera stacking) (#5339) * Discard invalid pixels when doing deferred lighting in compute (as required for camera stacking) Small comment modification Update changelog * Use stencil buffer (instead of normals) to discard pixels in deferred compute * Remove not required if statement when binding the stencil * Small fixes to API visibility. (#5637) * Fixed some more public APIs to internal. * Made hasCustomRender public again. * Moved the tier defining from the asset to the concerned volume components. (#5519) * Alpha post-processing bugfixes and improvements (#5512) * Bug fix for post processing alpha with chrommatic aberation + minor fixes * Avoid double blending in DOF * Unit tests for alpha post-processing (TAA/DoF) Vulkan test images Vulkan meta files * Fix runtime tests (#5639) * Update runtime test screenshots * Update planar resolution * Add test (#5641) * fix material and project settings for VFX (#5642) * Revert change to GBuffer (normalbuffer usage) as it broke the raytracing code * Fix various issues with time and animated materials (#5480) * Fix various issues with time and animated materials * Changelog * Add getters * Only update time once per frame * Fix animation in reflection * Fix null ref exception * Re-applied code after impossible merge. * Comment change * Remove commented code. Co-authored-by: JulienIgnace-Unity Co-authored-by: sebastienlagarde * fix graphic test (#5651) * renaming test 1901 -> 1451 and 1709 -> 1710 * Update EditorBuildSettings.asset * Update 1710_Decals_Normal_Patch.png * update screenshots * update scene backgroud * Update manifest.json * Update decal patch screenshots * update 4052_TAA * Changing the tier system for a preset mode system and removing unnecessary options (#5646) * Changing from a tier management to a "mode" management for reflection and GI and removing the ability to enable/disable deferred and ray bining (they are now implied by performance mode) * Update the scene scenes * Update changelog * Fixing an instability with the light shadows in ray tracing * Update to light explorer (#5615) - Fixed SkyType display when no Visual Environment is present - Changed fog display to reflect the updated fog system - Changed Global to "Mode" as it is in Volume UI now. Co-authored-by: sebastienlagarde * Update 1710_Decals_Normal_Patch.png * disable TAA test for XR * Hdrp/add documentation tool (#5655) * Add the documentation tool to HDRP test project * Fixed window serialization * Update the documentation for the diffusion profile (#5654) * Update the documentation for the diffusion profile * Update Diffusion-Profile.md Co-authored-by: sebastienlagarde * Add missing hdlight api (useVolumetrics) (#5652) * Add missing API to the HDAdditionalLightData * Updated changelog * Global Settings API doc. (#5649) * Fog Volume Component API doc. (#5645) * Debug Display API doc. (#5643) * Color picker API doc. * FullScreen Debug API doc. * Decal debug API doc * False Color debug API doc * Lighting Debug API doc * Material Debug API doc. * DebugDisplaySettings API doc. * Restored contact shadow fade debug. * API documentation for sky related classes. (#5640) * API documentation for sky related classes. * Document the PBR sky * Hdrp/small wizard fixes for dxr (#5633) * Add ScreenSpaceShadow to Camera's default FrameSettings * Forbid to atmpt creating default scene if the hdrpAsset is not right (we depend on its resources) * Update CHANGELOG.md * Add OS and Hardware check in wizard for DXR * Update CHANGELOG.md * Fixe typos * Add missing check on Shadows * Update Documentation Co-authored-by: sebastienlagarde * Documentation (#5613) Co-authored-by: sebastienlagarde * Fix custom pass disable stencil (#5545) * Disable the strencil in custom passes when overwriting the depth and not writing into it * Updated changelog * Rephrase doc Co-authored-by: sebastienlagarde * Add option to exclude camera motion contribution from motion blur (#5656) * Remove camera component from motion blur if desired * changelog * Documentation update Co-authored-by: sebastienlagarde * Implement Semi-transparent Shadows for Point and Spot lights (#5490) * Make the shadow behavior for transparent and transmissive objects more intuitive. * Update changelog * Implementing semi transparent ray traced shadows for point and spot light Adding a test scene for both cases Moving contact shadow ray tracing code to a seperate file Changing the direction of contact shadow rays to be coherent with the other shadows * update changelog * Update the test scenes Co-authored-by: sebastienlagarde * fix shader warning in termporal AA * Support semi-transparent shadows for unlit shader and unlit shader graph (#5663) * Not doing ray tracing when the stencil bit is off for ssr (#5665) adding a test case for it * Restored serialization of deprecated parameters to fix migration. (#5666) * Shadow Atlas is no longer allocated for area lights when they are disabled in the shader config file. (#5662) Co-authored-by: sebastienlagarde * Updated HDRP documentation (#5664) * Updated HDRP asset doc * Update the upgrade guide for cookies and planars * Added warning in the material sorting priority doc for depth write * Added a section about surface option properties for ShaderGraphs * Fix link name * Alpha output documentation (#5658) * Update documentation for HDRI-Sky-Backplate (AO) (#5670) * Avoid MRT Clear on PS4 [Skip CI] (#5675) * Avoid MRT Clear on PS4 * changelog * Update HDRenderPipeline.cs * Update HDRenderPipeline.cs Co-authored-by: sebastienlagarde * Change name of option (#5681) * More code share between inspector materials (#5635) * Share stencil code for inspector materials (Akin to what happens in shadergraph) * changelog * Add comment and fix issue * Better handling of setting state (if not available, don't write it) * Update BaseLitGUI.cs Co-authored-by: sebastienlagarde * Expose alpha cutoff material for ShaderGraphs (#5667) * Expose alpha clip to material UI for ShaderGraphs * Updated changelog * Replace #if by #ifdef * Fix debug menu bitfield (#5683) * Fixed runtime debug menu bitfield controls * Updated changelog * Hdrp/update default scenes (#5634) * Replace default scenes with scene prepared for scene-template * Update of DefaultSettingsProfile * Update DXR scene * fix missing profile in default scene dxr * Update CHANGELOG.md * Fix missing HDRI Sky references in DXR new scene * Fixed VFX Tests Default volume profile * Changed Default Volume settings to an empty one. * Missing volume asset files + update manifest and meta Co-authored-by: JulienIgnace-Unity Co-authored-by: sebastienlagarde * - Fixed the radius value used for ray traced directional light. (#5682) - Fixed compilation issues with the layered lit in ray tracing shaders. - Changed the way the length parameter is used for ray traced contact shadows. - Added contact shadow test scenes Co-authored-by: sebastienlagarde * fixed XR autotests viewport size rounding (#5684) Co-authored-by: sebastienlagarde * Material samples bis (#5686) * Add ball * update Material samples #5638 * Update CHANGELOG.md * Remove unused version property from Material * Updating the documentation for ray tracing (#5680) * Updating the documentation for ray tracing * review corrections * Fix mip slider reflectionprobe (#5689) * Remove the slider knob when the reflection probe preview has no mipmap * Updated changelog * edit VR documentation (#5685) Co-authored-by: sebastienlagarde * Better directional PCSS blur handling (#5688) * Use correct penumbra calculation for directional. * Update visual test * Need cleaning uo * Cleaning * screenshot update * Small cleanup * typo leftover * changelog Co-authored-by: sebastienlagarde * Update 001-HDTemplate.png * Adding the initial implementation of sub-surface scattering (#5625) * Initial implementation of ray traced sub surface scattering Added a test scene for ray traced sub surface scaterring * Update changelog * Updating the tests * Update 8103_PrePostPass.unity * Remove unnecessary skip of material upgrade dialog box. (#5692) * Remove unnecessary skip of material upgrade dialog box. * Update changelog Co-authored-by: sebastienlagarde * Fix warning after metal fixup (#5704) * Various API doc update. (#5705) * Various doc + FrameSettings WIP * Finished frame settings API doc and added various other missing doc. Also made internal wrongly public API in HDRP * Fix density volume blend distance (#5698) * Fixed adjusting positive axis of Blend Distance slides the negative axis * Updated changelog * edit VR doc (#5699) * Hdrp/wizard update vr installation (#5706) * Add installatation checker in UsedPackageRetriever * Add PackageInstaller * Add better control on the displayed HelpBox * Update VR fixes * fix typo * Move Install Config Package Button above with HDRP Package info * Update CHANGELOG.md * Update documentation Co-authored-by: sebastienlagarde * Removing unused alpha threshold depth prepass and post pass for fabric shader graph (#5711) Co-authored-by: sebastienlagarde * Fix default volume profiles location (#5710) * Ray traced reflection smoothness fade and fallback fixes. (#5700) * Fix fall back for ray traced reflections when denoising is enabled Make Smoothness Fade start work with ray traced reflections Fix the blend of reflections based on the weight Add the contact shadow test scenes back * Change the name of the weight function and add it to all shading models Co-authored-by: sebastienlagarde * Fix iridescence color space (#5691) * Fix iridescence color space * Fixed compilation and updated test screenshots * fix test Co-authored-by: JulienIgnace-Unity * Fix Terrain Detail Mesh (stop to spam) [Require C++ PR] (#5690) * disable support of Terrain Detail Fix for error spam issue in HDRP: https://fogbugz.unity3d.com/f/cases/1211848/ * Update CHANGELOG.md * Update HDRenderPipeline.cs * Update HDRenderPipeline.cs * [Waiting for C++] Disable probes in renderers (#5648) * Disable probes section in the Renderer editors * Updated changelog Co-authored-by: sebastienlagarde * Merge Hdrp/fix/case 1210058 to master (#5612) * Fix for 1210058 - NaNs at certain view angles Issue is caused by NaNs/INFs when computing basis on extremely thin (subpixel-width) geometry. Putting some safeguards fixes the issue * Update CHANGELOG.md to reflect 1210058 fix. * Updated fix for issue #1210058 Overwrite the UVs to fix the derivatives. * Updated fix for issue #1210058 Make sure the UVs are zero if unused to fix the derivatives. * Undo last.change -- UV fix addresses NaNs Zeroing the unused UV1 channel on the material seems to do the trick. * Changelog adjustments to be moved Current version puts everything in HDRP, so there is no change in core. * Update CHANGELOG.md Reflect fix for NaNs * Fixed UV1 for lightmaps and detail maps. * update comment * Update NormalSurfaceGradient.hlsl Co-authored-by: JulienIgnace-Unity Co-authored-by: sebastienlagarde * Minor code cleanup * Added script documentation for SSR, SSAO (ray tracing), GI, Light Cluter, RayTracingSettings, Ray Counters, ray traced SSS andRecursive Rendering. (#5732) * Added script documentation for SSR, SSAO (ray tracing), GI, Light Cluster, RayTracingSettings, Ray Counters, ray traced SSS andRecursive Rendering. * udpate changelog * Implementation of ScreenSpaceReflections for Transparent materials (#4968) Co-authored-by: sebastienlagarde * Fix HDRP duplicated frame settings (#5850) * - Added a fallback for ray traced area light shadows in case the material is forward or the lit mode is forward. (#5749) - Fixed a bug related to ray traced area light shadow history. Co-authored-by: sebastienlagarde * Fix cookie index usage (#5871) * Hdrp/merge staging (#5943) * fix case 1205791 custom mesh issue (#5551) * fic case 1205791 custom mesh issue * Updated changelog * Added a call to Dirty() (#5420) * Added a call to Dirty() * Updated changelog Co-authored-by: Marc Templin * Fix shadergraph analytics. (#5912) * Fix analytics. * Added changelog * Fix for case 1200161 Save as subgraph issue (#5503) * Fix for case 1200161 * Edited CHANGELOG.md * Added comment to the code Co-authored-by: Sharlene Tan <43795986+sharlenet@users.noreply.github.com> Co-authored-by: Marc Templin * fix for unreported keyword bug (#5863) * Fixed fogbugz case 1197958 (#5671) * * Fixed fogbugz case 1197958. * * Updated CHANGELOG.md. * * Added spacing. * Added #if ENABLE_VR && ENABLE_VR_MODULE guard to XR code. * Added Logic to Inject render pass to base renderer (#5901) * Moved render pass injection code from Forward Renderer to ScriptableRenderer to be able to use for all renderers. * added changelog * Disabling the GetDefaultRenderer() test for now until it is redone. (#5924) * [Yamato] [skip ci] Setting up master to run on 2020.1 (#5936) * added 2020.1 and fast to editors * added 2020.1/staging and fast to the rest of the files * [CI] Bors setup (#5841) * Create bors.toml * Update bors.toml * Update bors.toml * Update upm-ci-projects.yml * Create testcommit * Update bors.toml * adding trying trigger * add staging trigger * Delete testcommit * use squash merge * updating job that bors will run * [skip ci] update job that bors will run * Fixed MAD and RCP definitions in OpenGL. (#5922) Co-authored-by: Martin Thorzen <35328557+martint-unity@users.noreply.github.com> Co-authored-by: Marc Templin Co-authored-by: Sharlene Tan <43795986+sharlenet@users.noreply.github.com> Co-authored-by: Zachary Diller Co-authored-by: thomas-zeng <49886741+thomas-zeng@users.noreply.github.com> Co-authored-by: Felipe Lira Co-authored-by: Elvar Örn Unnþórsson Co-authored-by: Liis Kivistik Co-authored-by: Sophia <16596228+sophiaaar@users.noreply.github.com> * Fix whitespace * Misc fixes for the sky (#5974) * Static lighting sky now takes the default volume into account. * Fixed a leak in the PBR sky renderer. * Added a tooltip to the Ambient Mode parameter in the Visual Environment volume component. * Update changelog * Fixed null ref * Fixed an issue where having ambient mode set to dynamic might prevent the sky from being included in baking. * Forces an update of static sky when changing it in the Environment panel. * Fixed a problem with static sky when multiple skies are rendered at the same time. * Revert probes renderer PR (#5990) * Re-enable the probes section of renderers as it was not supposed to be disabled * Updated changelog * Fix a leak in the sky system. (#5967) * Fixed a cubemap leak when rendering previews for the first time. Also changed the debug name of the cubemap used for static lighting. * Update changelog. * Fixed an assert getting fired for the wrong reason. * Added a new light layer debug mode (#5942) * Moved lighting debug settings in containers * Light layers debug mode * Categories for Lighting Debug Panel Documentation * Light layers debug mode documentation * DebugUI.BitField now uses correct display names * Added unit test scene * Added changelog * Revert "Added changelog" This reverts commit a148fc2f97ef5288123f8f16485ba35f57b80f5e. * Updated CHANGELOG * Disable light layer debug mode after testing * reset all debug display settings * Renamed Shadow Layers option * Editable layer color. Defaults to color blind friendly colors * Fix when enabling an exclusive setting * Updated screenshots with new colors * Simplified variable API * Renamed class * Fix division by 0. Updated doc Co-authored-by: Adrien * Hdrp/ssr toggle (#5996) * Added an "enable" checkbox to the SSR volume component. * Update changelog * Fix build when not in editor (#6024) * Fixed SSR in scene 1710 (#6028) * Fix merge error * Removed MSAA Buffers allocation when lit shader mode is set to "deferred only" (#6012) * Removed MSAA Buffers allocation when lit shader mode is set to "deferred only". * Removed MSAA SSS Buffer allocation when deferred only. * Invalid cast for realtime reflection probes (case 1220504) (#6026) * Invalid cast for realtime reflection probes (case 1220504) * Updated changelog Co-authored-by: sebastienlagarde * Aov Buffers tests (#6023) * Deactivate Preview Camera for HDCameraEditor to prevent it from rende… (#6022) * Deactivate Preview Camera for HDCameraEditor to prevent it from rendering in the render loop (case 1105163) * Updated changelog Co-authored-by: sebastienlagarde * Disable reflection probes section (#5994) * Disable reflection probes in the renderer components * Updated changelog * Remove version guard for terrainDetailUnsupported Co-authored-by: sebastienlagarde * Integrate first skeleton of post process in render graph. (#5856) * Fixed execution error without raytracing * Prepare Prepass refacto * Another round of preparation * Renamed XRPassScope to XRSinglePassScope * RenderAfterPostProcess is now static * Add AfterPostProcess to RenderGraph (WIP) * AfterPostProcess implementation * Fixed wrong RTHandle allocation * Fixed light layers texture binding during deferred lighting pass * Implemented Post Process Final Pass with RenderGraph * Post merge fixes * Fixed some issues with missing buffers in SSS and deferred lighting compute shaders. * Fixed alpha in post processes * Fix DXR Tests (#6073) * Made ssr enable parameter true by default. (#6076) * Add comment (#6056) * Hdrp /tests/shuriken light module (#6021) * Add shurikent light module test * Fixed Simulate * Fix texts and image ratio Co-authored-by: sebastienlagarde * Hdrp/pt7 (#5831) * Added support for anisotropy. * Tidied the code up, plus moved to correlated G term for aniso GGX. * Added anisotropic refractive sampling. * Disable path tracing for the shading graph preview camera. * Added support for alpha culling. * Fixed issue with transmission rays. * Updated Changelog. * Added support for punctual and directional light cookies. * Updated Changelog. * Added support for area light cookies. * Fixed bug with area cookies atlas not being properly generated when rebuilding library. * Made sure maxDepth > minDepth always, and added support for AO from mask. * Added support for transparent shadows. * Updated Changelog. * Toggling path tracing on/off does not reset iteration anymore. * Reverted change on enable, was causing minor issues. * Made sure we don't have transparent behaviour when shader is set to opaque. * Minor changes. * Tweaks on transparency behaviour. * Updated changelog. * Added path-tracing specific payload. * Added support for iridescence. * Updated Changelog. * Added multiple scattering compensation for specular. * Added Path tracing test. * PT test part 2. * Updated Changelog. * Added proper area light range attenuation. * Fixed issue with alpha clipping in ray-tracing. * Cosmetic. * Fix on the rect area light range. * In the editor, dragging manipulators around now resets accumulation. * Added material dirtiness tracking. * Does not apply intensity clamping to camera rays. * Reste PT iteration when saving a shader graph. * Added dirtiness tracking for acceleration structure and lights. * Added support for bg color. * Minor change to progress bar display. * Minor change to iteration counter, so that it never goes over the max. * Updated path tracing test. * Hdrp/rendergraph cleanup (#6083) * Fixed execution error without raytracing * Prepare Prepass refacto * Another round of preparation * Renamed XRPassScope to XRSinglePassScope * RenderAfterPostProcess is now static * Add AfterPostProcess to RenderGraph (WIP) * AfterPostProcess implementation * Fixed wrong RTHandle allocation * Fixed light layers texture binding during deferred lighting pass * Implemented Post Process Final Pass with RenderGraph * Post merge fixes * Fixed some issues with missing buffers in SSS and deferred lighting compute shaders. * Fixed alpha in post processes * Removed RenderGraphResource and RenderGraphMutableResource in favor of more explicit RendererListHandle and TextureHandle * Fixed decal normal patch pass * Fixed stencil resolve render pass * Fixed RenderDBuffer render pass function capturing variables. * Fixed wrong variable capture and restored ClearLightList to the render graph implementation of BuildGPULightList * Various fixes of things that diverged compared to regular path. * Unified renderer list and texture invalid handle error. * Revert wrong change * post merge fix * Removed useless comment. * Missing doc * Hdrp /fix light prefab infinite reload on inspector gui (#6054) * fix infinite reload loop for light prefab * Update CHANGELOG.md * Fixed an issue where fog sky color mode could sample NaNs in the sky cubemap (#6027) * Fixed an issue where fog sky color mode could sample NaNs in the sky cubemap. * Update changelog. # Conflicts: # com.unity.render-pipelines.high-definition/CHANGELOG.md * Fixed sampling of the sky texture in a more general way (not just fog) updated tests screenshots as well. * Missing screenshot * Fixed the issue properly by generating 7 mips of convolution. * Reverted screenshots * Reverted useless change. * Fix culling group was not disposed error in the build (#5880) * Fix culling group was not disposed error in build * Fix culling was not disposed error in build * Updated changelog Co-authored-by: sebastienlagarde * Fix Material Samples : Revert correct GUIDs (#5875) * Revert correct GUID Change the GUID of the prefab to the correct one referenced in the scene * Fix fern material GUID * Hdrp/light multiplier (#6077) * Allow the light dimmer to get values higher than one * Changelog Co-authored-by: sebastienlagarde * Update documentation typo (#5860) * Add warning and workaround instructions if XR single-pass is enabled after the first frame with XR SDK (#5853) * added warning and workaround instructions if XR single-pass is enabled after the first frame with XR SDK * edit VR doc * Updated CHANGELOG.md * Updated VR-Overview.md Co-authored-by: sebastienlagarde Co-authored-by: Sharlene Tan <43795986+sharlenet@users.noreply.github.com> * Remove info box on Visual Environment and replaced it with info on documentation (#6099) * Remove info box and update documentation * changelog Co-authored-by: sebastienlagarde * Update 9801_ShurikenLightModule.png * Add missing exposure and mipmap sliders to the planar reflection probe preview (#5847) * Added planar reflection probe preview mip and exposure sliders * Updated changelog * Disable mip map as we don't have them anymore * Re-edited changelog * Use SRP macros in shader Co-authored-by: sebastienlagarde * Fix upgrade cookie planar size (#6104) * Fixed the size of the planar reflection / cookie atlas after an upgrade of the HDRP asset * Updated changelog * Fixing merge issue for SSR transparent * Fix universal and yamato after merge. * fixuniversal after merge * renormalize files * Update 9801_ShurikenLightModule.unity * Make isEditorCameraPreview and sky public (#6147) * Update HDAdditionalCameraData.cs * Update SkySettings.cs * Update 9801_ShurikenLightModule.unity * Update HDAdditionalCameraData.cs * Update 9801_ShurikenLightModule.unity * Fixing ray tracing tests (#6158) * Fixed transparent SSR for shader graph. (#6163) * - Fixed transparent SSR for shader graph. * changelog * Added old graphics tests and modifications (#6143) * Update scenes * update blendstates * added OSX reference images * win reference images * fix lit light difference * Update blendstates-c-lit-unlit * disable check memory alloc due to ref probe issues * update ref images * rename test 1709 to 1711 * rename test 1709 to 1711 - bis Co-authored-by: sebastienlagarde * Fix issue with blend mode and with keyword (#6164) * Fixed an issue with emissive light meshes not being in the RAS (#6174) * Hdrp/pt8 (#6090) * Added support for anisotropy. * Tidied the code up, plus moved to correlated G term for aniso GGX. * Added anisotropic refractive sampling. * Disable path tracing for the shading graph preview camera. * Added support for alpha culling. * Fixed issue with transmission rays. * Updated Changelog. * Added support for punctual and directional light cookies. * Updated Changelog. * Added support for area light cookies. * Fixed bug with area cookies atlas not being properly generated when rebuilding library. * Made sure maxDepth > minDepth always, and added support for AO from mask. * Added support for transparent shadows. * Updated Changelog. * Toggling path tracing on/off does not reset iteration anymore. * Reverted change on enable, was causing minor issues. * Made sure we don't have transparent behaviour when shader is set to opaque. * Minor changes. * Tweaks on transparency behaviour. * Updated changelog. * Added path-tracing specific payload. * Added support for iridescence. * Updated Changelog. * Added multiple scattering compensation for specular. * Added Path tracing test. * PT test part 2. * Updated Changelog. * Added proper area light range attenuation. * Fixed issue with alpha clipping in ray-tracing. * Cosmetic. * Fix on the rect area light range. * In the editor, dragging manipulators around now resets accumulation. * Added material dirtiness tracking. * Does not apply intensity clamping to camera rays. * Reste PT iteration when saving a shader graph. * Added dirtiness tracking for acceleration structure and lights. * Added support for bg color. * Minor change to progress bar display. * Minor change to iteration counter, so that it never goes over the max. * Updated path tracing test. * Added finer estimates of lights during global pdf computation. * Refined light estimates during light list creation. * Updated PT test after changes to light sampling. * Minor change on samples count dirtiness handling. * Cosmetic, plus include guards. * Separated the path intersection structure from the ray tracing one. * Cosmetic, plus taking SSS weight into account to reduce diffuse. * Added SSS support for path tracing, and made some minor changes to the ray-traced version. * Minor code refactor. * ... * ... * Post-merge cleansing. * Fixed minor issues in CreateMaterialData(). * Fixed issue with test framework and resolution change. * Avoid error msg on null instance in PathTracing.cs. * Pathtracer new automated scenes (#6053) * Add global GI automated test scene * Adding transparency test scene * Update max samples of transparency scene to 32 * Added area light test scene / Updating reference image * Transparency scene settings + ref image * Scene added to build (Editor build settings) * Update tranparency image ref * Updating scene to 1 spp and ref image Also moving the asset to common assets folder * Re-added support for unlit shader graph. Co-authored-by: remi-chapelain <57442369+remi-chapelain@users.noreply.github.com> * Update RTSSS Screenshots (#6177) * Fix DX12 and DXR Player build and Updating the test screenshots for DXR player tests (#6130) * Fix DX12 and DXR Player build Updating the test screenshots for DXR player tests * fix shader graph case Co-authored-by: sebastienlagarde * Update CHANGELOG.md * Fix shader compilation issue with Vulkan and Raytracing (#6181) * update path tracing and 1219 test * Fix hdasset migration code not being called after a package upgrade (#6179) * Fix the HDRP asset migration code not being called after a package upgrade * Updated changelog Co-authored-by: sebastienlagarde * Fix custom pass out of bounds (#6176) * Fix draw renderers custom pass out of bound exception * Updated changelog Co-authored-by: sebastienlagarde * Fix PBR master node (#6182) * Fix PBR shader render states * Updated changelog * Fix some typos in the debug menu (#6097) * fix some typos * Revert typo fix that break public API * Changelog * Add regenerated shader includes Co-authored-by: sebastienlagarde * Fixed ray traced point and spot lights shadows not rejecting history when semi-transparent or colored. (#6108) * Fixed ray traced point and spot lights shadows not rejecting history when semi-transparent or colored. * Removing unwanted skip closest hit Co-authored-by: sebastienlagarde * Diffuse Shadow Denoiser Improvement. (#5851) * - Added a new mode that improves the filtering of ray traced shadows (directional, point and spot) based on the distance to the occluder. Added new test scenes to test the denoiser improvement * Update changelog * Fix an issue with the shadow denoiser grabiing data outside of the screen * changing light parameter to internal * Fixed a warning due to StaticLightingSky when reloading domain in some cases. (#6193) * Fixed the MaxLightCount being display when the light volume debug menu is on ColorAndEdge. (#6211) * Fixed the MaxLightCount being display when the light volume debug menu is on ColorAndEdge. * Update com.unity.render-pipelines.high-definition/CHANGELOG.md Co-Authored-By: Motiejus Viltrakis <36502659+iM0ve@users.noreply.github.com> Co-authored-by: sebastienlagarde Co-authored-by: Motiejus Viltrakis <36502659+iM0ve@users.noreply.github.com> * Update documentation to mention more explicitely the lack of support of vertex animation (#6207) * Update documentation to mention more explicitely the lack of support of vertex animation * Update Ray-Tracing-Getting-Started.md Co-authored-by: sebastienlagarde * Make subsection in decal debug menu to specify "affect transparents" (#6200) * Make subsection in decal debug menu * changelog Co-authored-by: sebastienlagarde * Added coverage for Enabled GPU Instanced material (#6183) For light layers automated test * Support cookie on light backing for Disc Area Light (#6138) * Added support for light cookies in the baking backends. * Updated light conversion script to reflect the latest changes made to the API. * Added support for directional light cookie sizes. * Added support for cookies on rectangular area lights. * Enable Area::Disc Light on backing with cookie * Update ChangeLog * Update CHANGELOG.md Co-authored-by: uygar Co-authored-by: sebastienlagarde * Hdrp /lookdev/fix crash on adding volume as viewed game object (#6129) * Update Volume's Layer when moving them to LookDev's stage * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Add smoothness remark (#6226) * Removed unexpected file * Removed legacy VR code from HDRP (#5923) * Removed legacy VR code * do not set CullingOptions.Stereo with xrsdk * re-add and tag previous function signature as obsolete Co-authored-by: sebastienlagarde * Improve light clipping and culling #2 (#4711) * Improve area light culling * Simplify * Clip box lights at the attenuation range * Save 1x ALU * Add missing feature flags * Chanelog Co-authored-by: EvgeniiG <7ee2cc898cca1b5fc49df740c2081dfc681e0a28> Co-authored-by: Sebastien Lagarde * Hdrp/fix/decal material ui errors (#6225) * Fixed error in the console when switching shader to decal in the material UI * Updated changelog Co-authored-by: sebastienlagarde * Fix z-fighting in sceneview when scene lighting is off (#6213) * Do not override the depth state of transparent materials in RenderDebugView * Changelog * Changelog - add case number Co-authored-by: sebastienlagarde * Mention default post processing in default volumes. (#6232) * Fix cubemap inspector so that thumbnail for cubemap work (#6231) * Fix for missing thumbnail on cubemaps * Changelog * Better default angles Co-authored-by: sebastienlagarde * fix ray tracing with VR single-pass (#6242) * - Fix an exception in ray tracing that happens if two LOD levels are using the same mesh renderer. (#6198) Co-authored-by: sebastienlagarde * update location of reference screenshots after merge * Added debug exposure to light hierarchy debug. (#6215) Co-authored-by: sebastienlagarde * - Rejecting history for ray traced reflections based on a threshold evaluated on the neighborhood of the sampled history. (#6251) Co-authored-by: sebastienlagarde * Hdrp/pt9 (#6184) * Added support for anisotropy. * Tidied the code up, plus moved to correlated G term for aniso GGX. * Added anisotropic refractive sampling. * Disable path tracing for the shading graph preview camera. * Added support for alpha culling. * Fixed issue with transmission rays. * Updated Changelog. * Added support for punctual and directional light cookies. * Updated Changelog. * Added support for area light cookies. * Fixed bug with area cookies atlas not being properly generated when rebuilding library. * Made sure maxDepth > minDepth always, and added support for AO from mask. * Added support for transparent shadows. * Updated Changelog. * Toggling path tracing on/off does not reset iteration anymore. * Reverted change on enable, was causing minor issues. * Made sure we don't have transparent behaviour when shader is set to opaque. * Minor changes. * Tweaks on transparency behaviour. * Updated changelog. * Added path-tracing specific payload. * Added support for iridescence. * Updated Changelog. * Added multiple scattering compensation for specular. * Added Path tracing test. * PT test part 2. * Updated Changelog. * Added proper area light range attenuation. * Fixed issue with alpha clipping in ray-tracing. * Cosmetic. * Fix on the rect area light range. * In the editor, dragging manipulators around now resets accumulation. * Added material dirtiness tracking. * Does not apply intensity clamping to camera rays. * Reste PT iteration when saving a shader graph. * Added dirtiness tracking for acceleration structure and lights. * Added support for bg color. * Minor change to progress bar display. * Minor change to iteration counter, so that it never goes over the max. * Updated path tracing test. * Added finer estimates of lights during global pdf computation. * Refined light estimates during light list creation. * Updated PT test after changes to light sampling. * Minor change on samples count dirtiness handling. * Cosmetic, plus include guards. * Separated the path intersection structure from the ray tracing one. * Cosmetic, plus taking SSS weight into account to reduce diffuse. * Added SSS support for path tracing, and made some minor changes to the ray-traced version. * Minor code refactor. * ... * ... * Post-merge cleansing. * Fixed minor issues in CreateMaterialData(). * Fixed issue with test framework and resolution change. * Avoid error msg on null instance in PathTracing.cs. * Pathtracer new automated scenes (#6053) * Add global GI automated test scene * Adding transparency test scene * Update max samples of transparency scene to 32 * Added area light test scene / Updating reference image * Transparency scene settings + ref image * Scene added to build (Editor build settings) * Update tranparency image ref * Updating scene to 1 spp and ref image Also moving the asset to common assets folder * Fog support WIP... * Added support for fog attenuation. * Cosmetic. * Set a maxSampleCount to 1 for test… * - Fixed an issue related to the envlightdatasrt not being bound in recursive rendering. (#6408) * Refreshed the GUIDs for additional post processing data to avoid conflicts with PPv2 (#6394) * First pass of light loop optimizations (still single threaded) (#6367) * Saving 10% off the PrepareLightForGPU * 18% decrease in cost with this * Around 12% cost shaving off GetLightData * Around 6.5% win here * Faster View matrix flip * Missing *=-1 * About 7% win in preprocess light data * Another small batch * Small cleanup for first optimization pass * Tiny bit more cleanup * Address review points * Add comment * changelog * Shadow cascade tooltip fix (when using the metric mode) (#6448) * fix tooltip and public API about shadow cascades * minor modifications in the text * Add default tooltips * Add assert in case we support more cascades in the future * Minor text edit * Changlog * Updated tooltip text * update TAA screenshots * Disable POM test and update ref images (#6445) * Focus on Decal uses the extends of the projectors (#6449) * Added Alpha To Mask for HDRP and ShaderGraph (#6297) * Added AlphaToMask render state * AlphaToMask * AlphaToMask test * Updated changelog * Updated LayeredLit and AxF test * Added reference images * Fix depth and motion vector passes for Unlit * AlphaToMask doc. Unified doc and fixed links for Alpha Clipping * Updated reference screenshots * Update CHANGELOG.md * Fix motion vector settings for test scenes * Block AlphaToMask state in deferred or not MSAA. Updated test screenshots * Fix MRT blend state Co-authored-by: sebastienlagarde * Move scene view camera settings to camera settings window (#6390) * Move the HDRP scene view settings to the Editor camera settings widget * Changelog + tooltips * update upgrade guide * fix spelling Co-authored-by: sebastienlagarde * Fixed how the area light influence volume is computed to match rasterization. (#6454) * - Fixed how the area light influence volume is computed to match rasterization. * Fix issue in the axis order * Update DebugDisplay.cs (#6467) * Fix shadow tesselation culling (#6477) * Fix custom pass culling params * Fixed shadow tessellation culling * revert custom pass code * Adding 5 automated test scenes (#6483) * Sharing more code for light data building (RT) and building a more optimal atlas (#6370) * - Sharing GetLightData code between rasterization and ray tracing to avoid duplication and lack of features - Inject all lights at the same time (rasterization and ray tracing) into the cookie atlas to avoid waste of space. - Added a test scene to make sure it works properly * correcting debug mistake * Forgot to add the screenshot and to enable the test in the editor build settings * - Fixed usage of light size data that are not available at runtime. (#6489) * Hdrp /lookdev ui fixes (#6491) * Fix no environment text wraping * Add missing toolbar tooltips * Fix camera button-dropdown layout * Fix uss loss at domain reload * Update CHANGELOG.md * Fix custom pass depth copy (#6484) * Fixed the depth buffer copy made before custom pass after opaque and normal injection point * Updated changelog Co-authored-by: sebastienlagarde * Changed the diffusion profile warning on the material to an info and changed the message to be more precise. (#6479) * Fix issue with baked reflection probes constantly marked as dirty with auto-bake on (#6473) * Use different hash to prevent the perennial dirtying of baked probes. * Changelog Co-authored-by: sebastienlagarde * Hdrp /fix drag area width at left of light intensity (#6471) * Fix drag area width at left of light's intensity * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Hdrp /fix reset of HDAdditionalLightData (#6453) * fix type resolving issue when reseting HDAdditionalLightdata * Update CHANGELOG.md Co-authored-by: sebastienlagarde * Add option to disable XR rendering on the camera settings (#6372) Co-authored-by: sebastienlagarde * fix unused leftover (#6497) * Split HDRP Test scene 1900 in two scene (#6498) * Fix custom pass test reference images (#6512) * Updated ref image for PT fog test (5005). (#6513) * Review corrections for previous PR (#6494) * Fixed an usage of a a compute buffer not bound (1229964) (#6476) Co-authored-by: sebastienlagarde * Fixed scene selection pass not working proporly for meshes rendered with recursive rendering. (#6520) Fixing an issue with sub-surface scattering and updating screenshots * fix typo (#6500) * Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. (#6493) * Fixed an issue where changing the default volume profile from another inspector would not update the default volume editor. * Update changelog. * Additional fix for regular inspector * Fix issues in the post process system with RenderTexture being invalid in some cases. Causing rendering problems. (#6480) * Fix issues in the post process system with RenderTexture being invalid in some cases. Causing rendering problems. * Update changelog * Removed wrongly serialized fields in StaticLightingSky (#6441) * Removed unnecessarily serialized members in StaticLightingSky component. * Update changelog * Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). (#6504) * Fixed a weird behavior in the scalable settings drawing when the space becomes tiny (1212045). * Small fix to avoid overlapping Co-authored-by: Remi Chapelain Co-authored-by: JulienIgnace-Unity * Fix a compilation issue to to a backport that did not go well. (#9) * Fixed a regression in the ray traced indirect diffuse due to the new probe system. (#31) * Clamp probes compression factor to 0 (#19) * Clamp to positive * Changelog Co-authored-by: sebastienlagarde * path validation when creating new volume profile (#36) * Validate whole path when creating new profile * Changelog Co-authored-by: pavlos.mavridis * Alpha to coverage frame setting (#33) * Added FrameSettingsField.AlphaToMask * Changelog + Documentation * Changed field index * Axf - Add specaa, add baked ao, fix reflection hierarchy for carpaint. (#41) * AxF: Add support for specular AA from geometric curvature. * AxF: Add internal support for baked ambient and specular occlusion (no baked AO input map currently). Fix AO factor to adapt better to carpaint.model. * AxF: Fix a typo that caused a bug for SVBRDF materials using precise Fresnel variants to always use full reflectance (1) for delta lights. * AxF: Fix ignored reflection hierarchy + proxy intersection for carpaint. Add comments about problems if two directions are differents. Also add an option (disabled for now) to have BRDFColor with base angle of dominant direction. Rename some variables to make clearer direction on top for bottom lobe. * AxF: Use get scalar roughness function to factor out code. * AxF: Add internal support for baked ambient and specular occlusion (no baked AO input map currently). Fix AO factor to adapt better to carpaint.model. * Add changelog entries. Co-authored-by: sebastienlagarde * Implement constant buffers for HDRP global variables. (#52) * Fixed execution error without raytracing * Prepare Prepass refacto * Another round of preparation * Renamed XRPassScope to XRSinglePassScope * RenderAfterPostProcess is now static * Add AfterPostProcess to RenderGraph (WIP) * AfterPostProcess implementation * Fixed wrong RTHandle allocation * Fixed light layers texture binding during deferred lighting pass * Implemented Post Process Final Pass with RenderGraph * Post merge fixes * Fixed some issues with missing buffers in SSS and deferred lighting compute shaders. * Fixed alpha in post processes * Removed RenderGraphResource and RenderGraphMutableResource in favor of more explicit RendererListHandle and TextureHandle * Fixed decal normal patch pass * Fixed stencil resolve render pass * Fixed RenderDBuffer render pass function capturing variables. * Fixed wrong variable capture and restored ClearLightList to the render graph implementation of BuildGPULightList * Various fixes of things that diverged compared to regular path. * Unified renderer list and texture invalid handle error. * Revert wrong change * Added constant buffer hlsl generation * Changed UnityGlobal constant buffers to ShaderVariablesGlobals and generate it from C# * post merge fix * Removed useless comment. * Missing doc * Started moving cmd.SetGlobalXXX to update the global CB (WIP) * Implemented Volumetrics global CB and various fixes. * Implemented shadow global CB update. * Finished up Global Constant Buffer setup * Fix null ref * Fixed global constant buffer alignment issues. * Fixed shadows and SSS * Small ConstantBuffer API refacto * Small fix * Volumetric Constant Buffer implementation + Fix * Fix ambient occlusion * Removed redundant SetGlobalXXX * Light list build global CB implementation * Fixed path tracing frame index constant * Fixed ao constant w/ raytracing * Better path tracing fix. * Refactored CB API to comply with Render Graph specificities * Update test screenshot * Fixed constant buffer generation to use macros. * Fixed color/depth pyramid debug * Cleanup * Small fix * Post merge fix * Added global constant buffer hlsl generation. * Post merge fix * Post merge fix * Post merge fix 2 * Double inclusion fix. * Fixed CB visibility * Indentation fix * Removed temporary comments. * Moved some constants around. * Post merge fix + Port ProbeVolume global variables to constant buffers. * Fixed deallocation of constant buffers * Properly release Volumetric constant buffers. * Another update to CB API * Updated documentation. * Add Performance framework package and HDRP performance tests (#45) * Added performance test project * Added new test scene system and memory p[rofiling * Added shader analysis package * Create symlink folder in library directory * Update editor window * Update shader analysis selection * Added CLI utility to execute shader analysis reports * Added example for the cli * Removed problematic HDRP graphic test packages * Add xml file to avoid IL2CPP stripping issues with test runner on the performance test(#5903) * Update memory profiling test sample count * Update shader graph support * Updated project settings * Empty commit for Performance reports * Empty commit for Performance reports * Empty commit for Performance reports * Empty commit for Performance reports * Empty commit for Performance reports * Empty commit for Performance reports * Use background job API and improved progress reporting * Empty commit for Performance reports * Updated ui * Empty commit for Performance reports * Empty commit for Performance reports * Added filter on shader pass and variants * Added option to only generate shader variants * Empty commit for Performance reports * Increase garlic heap size * Begin to add build profiling * Added more build info * Working version of the shader compilation time reporting * wip * Removed useless cli * Added util functions to name test and sample groups * Renamed all markers and finished the build profiling * Update test framework package * Updated shader analysis tests * Updated API * Updated API and log command for compiler * Updated api * Use unknown metric instead of time one as workaround * Enable the CPU profiling API * Fix when deleting an analyzed shader * Load reference on enable * Added shader analysis package * Fixed PS4 test name * Fixed memory unit * Added more test scenes * Force performance tests to run on PS4 base * Fixed sample units and use the same SampleGroup for multiple frames in counter test * Begin to create the graphic perf test * Finished the first version of performance graphic test package * Fixed build tests * Increase static analysis timeout * More timeout * Removed Lit shader static analysis * Fix counters tests * Added performance settings window in project settings * Re-add Forward build test scene * Fixed shader analysis filter * PR fixes * Begin to write the doc * Finished V1 of the performance package doc * Added grafana image and doc description * Updated doc * Maybe fix yamayo tests * Update documentation for static analysis * Added note on core asmdef * Removed debug * Fixed total memory * Added tesselation counters test * Tessellation shadow test * Added per scene settings * Added naming convention doc * Fixed build issue on yamato * Compilation fix to revert * Begin to write the new doc page * Completed performance doc * Fixed build test * Added Lit in static analysis * Removed deferred static analysis Co-authored-by: Frédéric Vauchelles Co-authored-by: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Co-authored-by: FrancescoC-Unity * Hdrp/fix/custom pass msaa rendering info (#42) * Add an info box to warn about depth test artifacts when rendering object twice in custom passes with MSAA * Updated changelog Co-authored-by: sebastienlagarde * Custom Pass AOV API (#50) * Very basic AOV support for custom pass * Updated AOV API for custom passes * Changelog * Update AOV API * API improvements * API documentation * API doc, factorize all push texture calls in RenderCustomPass * added default values and constructor for CustomPassAOVBuffers * fix merge conflicts * Fix GC alloc during rendering: use a for loop instead of findIndex+lambda Co-authored-by: sebastienlagarde * Implement Constant Buffers for HDRP (part 2) (#87) * Fixed execution error without raytracing * Prepare Prepass refacto * Another round of preparation * Renamed XRPassScope to XRSinglePassScope * RenderAfterPostProcess is now static * Add AfterPostProcess to RenderGraph (WIP) * AfterPostProcess implementation * Fixed wrong RTHandle allocation * Fixed light layers texture binding during deferred lighting pass * Implemented Post Process Final Pass with RenderGraph * Post merge fixes * Fixed some issues with missing buffers in SSS and deferred lighting compute shaders. * Fixed alpha in post processes * Removed RenderGraphResource and RenderGraphMutableResource in favor of more explicit RendererListHandle and TextureHandle * Fixed decal normal patch pass * Fixed stencil resolve render pass * Fixed RenderDBuffer render pass function capturing variables. * Fixed wrong variable capture and restored ClearLightList to the render graph implementation of BuildGPULightList * Various fixes of things that diverged compared to regular path. * Unified renderer list and texture invalid handle error. * Revert wrong change * Added constant buffer hlsl generation * Changed UnityGlobal constant buffers to ShaderVariablesGlobals and generate it from C# * post merge fix * Removed useless comment. * Missing doc * Started moving cmd.SetGlobalXXX to update the global CB (WIP) * Implemented Volumetrics global CB and various fixes. * Implemented shadow global CB update. * Finished up Global Constant Buffer setup * Fix null ref * Fixed global constant buffer alignment issues. * Fixed shadows and SSS * Small ConstantBuffer API refacto * Small fix * Volumetric Constant Buffer implementation + Fix * Fix ambient occlusion * Removed redundant SetGlobalXXX * Light list build global CB implementation * Fixed path tracing frame index constant * Fixed ao constant w/ raytracing * Better path tracing fix. * Refactored CB API to comply with Render Graph specificities * Update test screenshot * Fixed constant buffer generation to use macros. * Implemented XR global constant buffer. * Removed useless global constant * Fixed XR global constant name * Converted SSR to constant buffer. * Converted AO to constant buffers. * Fixed warning * Removed some useless SetGlobalXXX in Light Cookie Manager * Converted debug display to use constant buffer. * Fixed color/depth pyramid debug * Cleanup * Implemented constant buffer for PBR sky global variables. * Warning fix * Small fix * Cleanup of global setup happening before rendering (render graph path or not). * Post merge fix * Added global constant buffer hlsl generation. * Post merge fix * Post merge fix * Post merge fix * Post merge fix 2 * Double inclusion fix. * Fixed CB visibility * Fixed compilation after the merge * Indentation fix * Removed temporary comments. * Moved some constants around. * Post merge fix + Port ProbeVolume global variables to constant buffers. * Fixed deallocation of constant buffers * Properly release Volumetric constant buffers. * Another update to CB API * Updated documentation. * Missing generated file * Fixed various issues with light probe volumes. * Fixed light list build parameters and a nullref exception when probe volumes aren't enable and there are volumes in the scene. * Final fix for probe volumes * Fixed a warning in shader compilation * Changes from review feedback * Compilation fix. * Minor adjustments to TAA anti flicker (#97) * small adjust to taa antiflicker * Changelog * Add support for lighting decomposition debug mode (+ AOV) (#99) * Add lighting decomposition debug mode * fix compil issue with probe volumes * Fix usage of debug exposure in debug mode * Add Test 3001 + fix reflection when sky only * remode _DebugExposure after merge * remode _DebugExposure after merge * fix merge issue * add exposure compensation to Fixed exposure mode * Update ColorUtils.cs * Fix MSAA resolve when there is no motion vectors (#1) * Fix MSAA resolve when there is no motion vectors * Update CHANGELOG.md * Cleaned up code * use multi_compile * Added _ Co-authored-by: sebastienlagarde * fix switch shader compilation (#111) * DXR Automated tests shader graph optimizations (#116) * Split 902 scene into 5 scenes + SG optimizations * Deleting old image for splited scene * Fix various leaks in HDRP. (#113) * Fixed a number of leak in HDRP * Update changelog Co-authored-by: sebastienlagarde * Fix compile error with XR SubsystemManager (#107) Co-authored-by: sebastienlagarde * Update SceneViewDrawMode.cs (#118) * Follow references when deleting unloading unused assets on shader graph save (case 1230996) (#114) * Follow references when unloading unneeded assets * changelog Co-authored-by: sebastienlagarde * Fix culling of reflection probes that change position (#121) * Fix culling of reflection probes that change position * Avoid null reference * Avoid null reference - try 2 Co-authored-by: sebastienlagarde * Fix null reference when processing light probe (#131) * Hdrp/runtimetests/ps4 fix (#129) * Redo branch. Upgrade to 2020.1.0b5, reduce texture res, new HDRP asset. * Switch to HDRI, increase Garlic heap size to 4gb, turn on "Stop NaNs" on camera, decrease render target res. * Fix issues causing planar probes to be broken with multiple cameras in the scene (#4) * Set appropriate render datas before rendering cameras * changelog * update doc * comment update Co-authored-by: sebastienlagarde * fix black screen in XR when HDRP package is present but not used (#137) * Fixed an issue with the specularFGD term being used when the material has a clear coat (lit shader). (#18) * Fixed an issue with the specularFGD term being used when the material has a clear coat (lit shader). * update ssr screenshot Co-authored-by: sebastienlagarde * Added support for rasterized area light shadows in StackLit + slight refactor (#39) * Added support for rasterized area light shadows in StackLit. Also refactor code to avoid early return (compiler bug) and fix lux meter debug mode when anisotropy for area lights is enabled. * Doc: remove note about area light shadows for stacklit. [skipci] Co-authored-by: sebastienlagarde * Update the scripting API for FrameSettings, FrameSettingsOverrideMask and IBitArray (#110) * Fix for white flash happening when changing lighting condition (like teleport) (#140) * fix * Update PostProcessSystem.cs * Update CHANGELOG.md * Add some clamp to fp16 for case where we don't have a NaN killer pass like planar reflection * Update CHANGELOG.md * adress PR feedback * Fix default volume profile collapse (#138) * Only re-create the volume profile editor when the asset is changed * Updated changelog Co-authored-by: sebastienlagarde * Bind missing buffer (#159) Bind buffer to make sure that something is bound Co-authored-by: sebastienlagarde * AxF fix: Use CALCULATE_TEXTURE2D_LOD macro for future cross platform compatibility (Metal) (#162) * Fixed shader warning on Xbox for ResolveStencilBuffer.compute (#163) * fix warning * changelog Co-authored-by: sebastienlagarde * Texture-weighted automatic exposure (#165) * Exposure weighted by texture * miss one in the renaming * Doc update * changelog * doc update * fix issue when disabling override * Update 3003_LightingMode.unity * Optimizing light loop part 2 (#2) * Saving 10% off the PrepareLightForGPU * 18% decrease in cost with this * Around 12% cost shaving off GetLightData * Around 6.5% win here * Faster View matrix flip * Missing *=-1 * About 7% win in preprocess light data * Another small batch * Small cleanup for first optimization pass * Tiny bit more cleanup * Make UpdateShadowRequests 12% cheaper * Address review points * A bit less than 20% win in ExtractPointLightData * Add comment * changelog * 25% reduction of ExtractPointLightData * 18% win in UpdateShadowRequest * Another around 11% win for UpdateShadowRequest * Move matrix multiply utils to core * less lighttype computation * Ooops * fixup changelog * Proper merge * Missing leftovers . * I'll manage to submit it all one day... Co-authored-by: sebastienlagarde * Added support for POM for emissive map (#51) * Add option to use Base UV Mapping for emission * Graphic test and doc * Changelog * Screenshots Co-authored-by: sebastienlagarde * HDRP Compositor Tool (#57) * HDRP compositor tool, first code drop documentation typo, move everything in compositor namespace documentation typo bugfix: dynamically add/remove properties when shadergraph changes UI bugfix: properly compute height of UI elements Missing tooltips, button to remove the compositor toggle layers now works when player is paused add chroma keying in the compositor test Changelog, workflow bugfix Use Unity's built'in icons AOV bugfixes AOV tooltip was wrong bugfix: disabling the compositor now disables all compositor cameras Proper monitoring of shadergraph changes Updated test image + minor changes Use better names for internal cameras Bugfix: selecting the same res for a layer Bugfix: deleting in-use texture layers from shadergraph now works Bugfix: setting AOV to none now works properly Use the term SubLayer in the UI Improve AOV tooltip Camera properties in layers are properly refreshed UI: Move checkbox for overrides on the left side of the label Remove default compositor camera when also deleting the compositor Bugfixes: no orphans (delete all children when removing a layer), saving the layer list now works again Hdrp/docs/compositor (#6013) * Added docs review * Changed fodler for images Bugfixe: deleting layers Bugfix: reordering layers Bugfix: creating a new compositor fails Remove redundant check Fix wrong tooltip Bugfix when deleting camera stack layers Bugfix: handle window resize Bugfix: sub-layers without parent when re-ordering, preview remains visible for disabled layers Bugfix: more robust re-ordering (also moves children) Bugfix: mark scene dirty when adding a compositor Bugfix: display warning when alpha is configured properly Change video layer icon Bugfix: adding a layer filter does not reset the UI state Bugfix: do not show composition properties that are marked with hide-in-inspector Better / more clean layer injection implementation minor code clean up Clear color mode should only be editable on the first layer of a stack Bugfix: setup of custom render was not always called Bugfix: make sure additional camera data always exist in the layer/compositor camera Change test id to 9800 Fix typos mark scene dirty when removing or disabling the compositor Default composition shadergraph and profile are now cloned Serialized objects are now properly updated minor code change: range checks bugfix: error message appears at beginning remove layer list from the asset file add default camera layer when creating the compositor replace getter function with c-sharp property update asset in unit test * move compositor unit test images * remove leftover code * review feedback #1 * review feedback 2 * review feedback - custom clear shader * fix variable names that don't affect serialization * fix serialized variable names * bugfix: image layers and camera stacking * use enum utility functions * Use multicompile in motion blur + bug fix * Make some variables private * Update Compositor-User-Guide.md * Review feedback * fix muticompile for motion blur without alpha * Update to new constant buffer / shadergraph api * Player test image for the compositor * Properly fill camera entries for global constant buffer * Fix after rebase / function rename * Make bg red for better debugging qnd cqtch unity exception * Disable compositor test until we fix it on yamato Co-authored-by: Lewis Jordan Co-authored-by: sebastienlagarde * PBR shader gbuffer ztest (#43) * Fixed PBR shader rendering in deferred * Updated changelog * Enable Light Baking Cookies by default + Warning (#79) * Enable * Fix typo * Importance Sampling Pipeline (#84) * Multiple Importance Sampling for HDRI Sky (Ray Generation) * backup * Multiple helpers * Add RTHandleDeleter (delay in K frame the Release of a RTHandle) * Fix GPU Operation when texture are too small * Helper to manager Mariginal Texture in general (Tex2D, Tex2DArray, CubeMap, CubemapArray), ... * Helper manager to generate one marginal per slice mip (one per frame) * backup * Add SampleCubemapProjectionNode (Project cubemap to Geometry) * delete useless files * update * Cube To LatLong for CubeArray * Functional generation * Integration on ray tracer step * Store HDRI Integral * . * Integrate HDRI Sky * Update Importance Sampling * Update Algorithm with Hemisphere Path * Backup * Update merge * Update Merge 001 * Update Merge 002 * Update Merge 003 * Update Merge 004 * Update Merge 005 * Update Merge 006 * Update Merge 007 * Cleanup * Update Integration of HDRISky Upper Hemisphere * Remove useless dump images on disk * Fix change log issue * backup * Backup * Pre-Clean * Pre-Clean * Clean Up - remove file * Remove Debug Code * Update * Update ChangeLog * Clean Up * update * Clean up * Remove useless texture * Fix CGAlloc + Default Litetime of a RTHandle on the "RTHandleDeleter" * CleanUp * remove useless comment * Add variable (Atmospherical) + Rename/Comment * Move parameter to CS, Clean & move to private RTHandleDeleter * Revert "Importance Sampling Pipeline (#84)" This reverts commit 835d6a45c15ec7cbebde2aa385134a780c363e11. * Reducing the number of variants for ray tracing when building a player (#94) * - Replaced the DIFFUSE_LIGHTING_ONLY multicompile by a uniform. - Removed the dynamic lightmap multicompile. - Remove the LOD cross fade multi compile for ray tracing. - Added a ray tracing mode option in the HDRP asset that allows to override and shader stripping. * fix merge * Update LayeredLit.shader * Update LayeredLit.shader Co-authored-by: sebastienlagarde * Update 3003_LightingMode.unity * Fix compil issue with Enable BakeCookie * Enable Light Baking Cookies by default + Warning - part 3 #79 * Avoid building the mip chain a second time for SSR for transparent objects. (#93) * - Avoid building the mip chain a second time for SSR for transparent objects. * Update ScreenSpaceReflections.compute * fix merge issue Co-authored-by: sebastienlagarde * Scalable volumetrics [skip ci] (#34) * Adaptive sampling works * Compute the PDF * URL * Fix stuff up (except for profile preview) * Attempt to fix previews * Fix transmission * Support quality levels * Clean shader * Remove 2 kernels * PURGE * Automatically adjust the number of samples at runtime * Changelog * Spaaaaace * Add comment * Spaaaaaace * Rename * Update ref img 1215, 1216, 1217 * Revert "Update ref img 1215, 1216, 1217" This reverts commit 9aeb1fee054bc0e8a24b76525eb4af5dc2316088. * Robust filter radius * Solve the NaN problem * Save 1x VGPR * Update SSS defaults * Add migration steps * Volume resolution WIP * Shorter names FTW * Comment * Dynamic slice count works * Dynamic res works * Changelog * Stretch the limits * Fix bug (order matters) * Comments * Remove volumetric quality presets * Changelog * Reorder * Solve the mystery of RTs going NULL * More robust bad history detection * Update test scenes for High Quality * More bug fixes * More accurate comment * Do not reinvent the wheel * Fix broken test 1351 * Attempt to migrate HQ SSS settings * Remove all branches * Optimize a bit * 7x WF * Fix the rounding error * Fix the rounding error * Remove garbage allocation * Fix typos * Copy the SSS value * Revert HDRP asset changes * Fix default UI value * Pass the right asset * Update ref img 1215 * update reference screenshots * Update CHANGELOG.md * Update CHANGELOG.md * Switch to RTHandles * Rename textures used by the fog filtering pass * Fix reprojection * Fix shader warning + typo+ * fix another shader warning Co-authored-by: EvgeniiG <7ee2cc898cca1b5fc49df740c2081dfc681e0a28> Co-authored-by: Sebastien Lagarde * Fixed runtime test for Yamato (#177) * Revert "Hdrp/runtimetests/ps4 fix (#129)" This reverts commit 6fa52ab66c77d12088114577573fb45edfb2baba. * Update runtime test to use way less memory to be able to run on console * Fixed screenshots and test * Fix HDRP Wizard windows not compatible with "preview" package version (#178) * Fix async compute throwing errors because of global constant buffers. (#130) * Replaced commands incompatible with async compute in light list build process. * Update changelog Co-authored-by: sebastienlagarde * Diffusion Profile and Material references in HDRP materials are now correctly exported to unity packages. (#136) * Added external references inside a material to diffusion profiles and materials in order to handle Material export to a package correctly. * Update changelog * Removed useless test * Updated changelog message to add more info * Refactoring to share the code for light list building better between probe volumes and lights. (#156) * Refactoring to share the code for light list building better between probe volumes and lights. * Remove commented code * Fixed constant buffer update * Fixed kernel used for cluster generation * Fixed cluster kernel for oblique projection * Restored a resize test for XR * Removed unexpected Shuriken folder in Test Project * Add range attenuation to box-shaped spotlights [Skip CI] (#101) * Added range attenuation to box-shaped spotlights * Update tests * Update CHANGELOG.md * Remove file duplication * Added box range attenuation test * Clarify documentation * Update screenshots Co-authored-by: sebastienlagarde * Hdrp/decal transparent mip selection 1222437 (#96) * Improve MIP selection for decals to transparent * Add change logs * Communize Helper (ComputeTextureLOD{Bias?}(...) * Update * Rename * Comment * fix white space and 0.f Co-authored-by: Sebastien Lagarde * Fix cookie atlas alloc for cone spot lights (#187) * Fix unneeded cookie texture allocation for cone stop lights * Updated changelog * Fix cone spot light cookie * update template (#189) * Hdrp/combine material samples with shader samples [Skip CI] (#117) * Fix MaterialBalls having same guid issue material samples and shader samples had the same prefabs with the same guids causing an issue when the guids are reassigned * Merge material samples and shader samples Merge shader samples into material samples * Update scene visuals update frame prefab with new visual style update scene to suit visual style * Fix spelling and grammatical errors alterates -> alters - this one isn't technically an error but alterates isn't used in common English oder -> order accross -> across * Create fabric scene create scene and rendering settings * Add fabric ball prefab with fabric mesh Add fabric ball prefab with fabric mesh * Add threadmaps to project Add threadmaps to project * Add materials to project Add materials to project Linen Nylon Satin Velvet Wool * Add scenes for hair and fabric and create prefabs for lighting and hair display Add scenes for hair and fabric Create prefabs for lighting and hair display Fix Decal prefab * Update scene and fix errors with materials that don't use threadmaps Update scene and fix errors with materials that don't use threadmaps * Update fabric materials and textures Update fabric materials and textures * Clean up project and add additional materials Add ShotSilk material Modify materials Rename textures Cleanup changes Add information to fabric scene * Update and organize scenes Update and organize scenes * Update Fabric scene , fix spelling errors and change to american spelling Update Fabric scene , fix spelling errors and change to american spelling * Update information in fabric scene * Update scene lighting Update scene lighting * Align lighting and rendering across scenes, remove old sample scene Create prefabs for common elements Change sky gradient Remove unused settings Remove old sample scene * Update textures and meshes Update denim color to tga file format to conform with other files Update cloth mesh to have better normals Update scene after changes to prefab * Update cloth mesh Update cloth mesh * Update scene text and cloth mesh Update scene text and cloth mesh * Update Changelog Update Changelog * Fix bug with material ball and parallax occlusion mapping due to mesh tangents Fix bug with material ball and parallax occlusion mapping due to mesh tangents * Remove shader samples from package json and update material samples description Remove shader samples from package json and update material samples description * Update sample content documentation * Update scene text * Move files in mesh folder to appropriate folders and remove additional material ball prefab * Add micro shadows * Update 1301_StackLitSG.png * Change guid reference in MaterialSamples scene Co-authored-by: Sean Puller Co-authored-by: Sebastien Lagarde * DisplayInfo attribute. (#172) * Added DisplayInfo attribute for generic display info. * Implemented volume parameter sorting for default inspector. * Update changelog * Named parameters for tuples in Volume Component Editor Co-authored-by: sebastienlagarde * Compute Buffer management for render graph (#194) * Added import and usage of Compute Buffer API to render graph. * Missing clear of Compute buffer write/read lists. * Another missing clear. * Light loop compute buffers WIP # Conflicts: # com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs # com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs * Reverted Render Graph debug registering by default. * Post merge fixes * RenderPass debugger visualization and fixed null profiling sampler * Missing using directive. * Post merge fix * Use new light list build ouptut for deferred lighting pass * Use new light list build ouptut for contact shadow pass * Use new light list build ouptut for volumetric passes * Simplify the tooltip (#188) * Added MovedFrom attribute (#182) * Contact shadow min distance + fix scalarization code (#150) * Min distance * editor update * Update doc * Changelog * fix some ui issues * Update docs according to UI changes Co-authored-by: sebastienlagarde * TAA docs update (#132) * update docs * pr review * Added indentation as dashed * Hdrp/deferred shadow quality multi compile (#5) * shadow mask * Changelog * Have shadow quality as multi_compile * make old API obsolete * Update comment * Comment on pre processor * Update docs * Change shader versions of deferred Co-authored-by: sebastienlagarde * Hdrp/path traced dof (#164) * Path traced DoF implementation * Move focus distance from volume to physical camera * Small fixes * Small fixes in math * Small fixes in math 2 * Compile error * Make new functions private * Cosmetic changes * Move viewport matrix function to utils * Keep focus distance in the volume * Do not enable in scene view camera * Changelog * Review feedback * Use scale and bias instead of matrix mul for the viewport transform * Bugfix: post process DoF should still be executed for non-physical mode * Typo * avoid null reference when physical params is null * remove redundant check * Update HDRenderPipelineAsset.asset (#210) * Fixed volume debug menu in playmode (#149) * Refresh widgets in play mode. Added doc. Reduced refresh rate * Changelog * Added some code doc * Fix refresh rate and scroll over hidden volumes in play mode Co-authored-by: sebastienlagarde * Added a new test scene for physical camera DoF in Pathtracer (#211) * Fixed issue when toggling anything in HDRP asset that will produce an error (case 1238155) (#215) * fix bug 1238155 * Update CHANGELOG.md * Update HDRenderPipeline.cs * Update HDRenderPipelineAsset.cs * Fix warning in PCSS code when using Vulkan (#229) * Fix warning * changelog * Fix decal register + obsolete cookie API (#195) * Update HDRenderPipeline.cs * Update HDRenderPipeline.cs * Fix decal shader * Fixed HDRP cookie * Update HDLightUI.cs * correctly fix decal * Update CHANGELOG.md * Update ColorAdjustments.cs * Update ShaderVariablesDecal.hlsl * fix compil on 2020.1 * Update HDRP_Test_Def.asset * add test for 3RT decal * update decal test * Do shadow code cleanup + Fix Yamato after PR #5 Multi compile shadow (#244) * Do code cleanup + bugfix shadow * Update Upgrading-from-2020.1-to-2020.2.md * Update LightLoopDef.hlsl * Fixed issues with path traced SSS and accumulation. (#257) * Add missing documentation for AOV API params (#254) * Hdrp/public static sky (#253) * Made the static lighting sky public so that users can change it by script for baking purpose. * Update changelog * Update HDAdditionalLightData.Migration.cs (#269) * Add missing docs attributes (#271) * Fixed an error about procedural sky being logged by mistake. (#273) * Fixed an error about procedural sky being logged by mistake. * Update changelog * Fix quality settings UI and shadow mask UI (#122) * Update HDRenderPipeline.cs * Update HDRenderPipeline.cs * Update CHANGELOG.md * Update HDRenderPipeline.cs * fix typo * fix typo 2 * Updated raytracing async compute warning. (#274) * Made more explicit the warning about raytracing and asynchronous compute. Also fixed the condition in which it appears. * Update changelog Co-authored-by: sebastienlagarde * Fixed a null ref exception in static sky when the default volume profile is invalid. (#278) * Fixed a null ref exception in static sky when the default volume profile is invalid. * Update changelog Co-authored-by: sebastienlagarde * Added SubScenes cache to be compatible with HDRP/staging (#287) * Update 2002_Light_DynamicMix.unity (#292) * Update HDCubemapInspector.cs (#296) * increase tolerance for test 5008 in VR due to recent changes (#311) * Upate screenshot for HDRP DXR Test (#312) * Add MSAA to new default camera * Ticked template HDRenderPipeline asset to MSAA within Forward to enabled in HDRP default setting so that when Forward Only is enabled and Msaa sampling amount is selected it would default to MSAA Within Forward enabled in frame settings * Update changelog Co-authored-by: sebastienlagarde Co-authored-by: anisunity <42026998+anisunity@users.noreply.github.com> Co-authored-by: Emmanuel Turquin Co-authored-by: remi-chapelain <57442369+remi-chapelain@users.noreply.github.com> Co-authored-by: Antoine Lelievre Co-authored-by: FrancescoC-unity <43168857+FrancescoC-unity@users.noreply.github.com> Co-authored-by: JulienIgnace-Unity Co-authored-by: Motiejus Viltrakis <36502659+iM0ve@users.noreply.github.com> Co-authored-by: skhiat <55133890+skhiat@users.noreply.github.com> Co-authored-by: uygar Co-authored-by: Remi Slysz <40034005+RSlysz@users.noreply.github.com> Co-authored-by: Fabien Houlmann <44069206+fabien-unity@users.noreply.github.com> Co-authored-by: Evgenii Golubev Co-authored-by: Pavlos Mavridis Co-authored-by: Emmanuel Turquin Co-authored-by: Remi Chapelain Co-authored-by: Adrien de Tocqueville Co-authored-by: fredericv-unity3d <55485372+fredericv-unity3d@users.noreply.github.com> Co-authored-by: Fabien Houlmann Co-authored-by: slunity <37302815+slunity@users.noreply.github.com> Co-authored-by: ChristianF-ARM <45175346+ChristianF-ARM@users.noreply.github.com> Co-authored-by: Thomas Co-authored-by: Frédéric Vauchelles Co-authored-by: FrancescoC-Unity Co-authored-by: Jans Margevics <50581102+JMargevics@users.noreply.github.com> Co-authored-by: victor-unity <50244023+victor-unity@users.noreply.github.com> Co-authored-by: Lewis Jordan Co-authored-by: Sean Puller <43151199+SeanPuller@users.noreply.github.com> Co-authored-by: Sean Puller --- .../CHANGELOG.md | 1 + .../RenderPipeline/Settings/FrameSettings.cs | 1 + .../Settings/HDRenderPipelineAsset.asset | 53 ++++++++++++++----- 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 1dc6efee344..eaac5078538 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -743,6 +743,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Ignoring the disable SSR flags for recursive rendering. - Removed logic in the UI to disable parameters for contact shadows and fog volume components as it was going against the concept of the volume system. - Fixed the sub surface mask not being taken into account when computing ray traced sub surface scattering. +- MSAA Within Forward Frame Setting is now enabled by default on Cameras when new Render Pipeline Asset is created ## [7.1.1] - 2019-09-05 diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs index 1a6d9f69243..dea46d77d30 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs @@ -433,6 +433,7 @@ partial struct FrameSettings (uint)FrameSettingsField.RayTracing, (uint)FrameSettingsField.AlphaToMask, (uint)FrameSettingsField.ProbeVolume, + (uint)FrameSettingsField.MSAA }), lodBias = 1, sssQualityMode = SssQualityMode.FromQualitySettings, diff --git a/com.unity.template-hd/Assets/Settings/HDRenderPipelineAsset.asset b/com.unity.template-hd/Assets/Settings/HDRenderPipelineAsset.asset index c69fe0f3ba7..d317e4963cc 100644 --- a/com.unity.template-hd/Assets/Settings/HDRenderPipelineAsset.asset +++ b/com.unity.template-hd/Assets/Settings/HDRenderPipelineAsset.asset @@ -12,7 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0cf1dab834d4ec34195b920ea7bbf9ec, type: 3} m_Name: HDRenderPipelineAsset m_EditorClassIdentifier: - m_Version: 11 + m_Version: 15 m_ObsoleteFrameSettings: overrides: 0 enableShadow: 0 @@ -153,21 +153,25 @@ MonoBehaviour: m_RenderPipelineRayTracingResources: {fileID: 0} m_DefaultVolumeProfile: {fileID: 11400000, guid: 582adbd84082fdb4faf7cd4beb1ccd14, type: 2} - m_DefaultLookDevProfile: {fileID: 0} + m_DefaultLookDevProfile: {fileID: 11400000, guid: 254c4fe87beb7be4fa72e1681edbed02, + type: 2} m_RenderingPathDefaultCameraFrameSettings: bitDatas: - data1: 70297877217117 - data2: 4539628424926265344 + data1: 140668768878429 + data2: 4539628425463136256 lodBias: 1 lodBiasMode: 0 lodBiasQualityLevel: 0 maximumLODLevel: 0 maximumLODLevelMode: 0 maximumLODLevelQualityLevel: 0 + sssQualityMode: 0 + sssQualityLevel: 0 + sssCustomSampleBudget: 20 materialQuality: 0 m_RenderingPathDefaultBakedOrCustomReflectionFrameSettings: bitDatas: - data1: 69373911135005 + data1: 139742655312669 data2: 4539628424389459968 lodBias: 1 lodBiasMode: 0 @@ -175,10 +179,13 @@ MonoBehaviour: maximumLODLevel: 0 maximumLODLevelMode: 0 maximumLODLevelQualityLevel: 0 + sssQualityMode: 0 + sssQualityLevel: 0 + sssCustomSampleBudget: 20 materialQuality: 0 m_RenderingPathDefaultRealtimeReflectionFrameSettings: bitDatas: - data1: 69622750778125 + data1: 139991494955789 data2: 4539628424389459968 lodBias: 1 lodBiasMode: 0 @@ -186,15 +193,21 @@ MonoBehaviour: maximumLODLevel: 0 maximumLODLevelMode: 0 maximumLODLevelQualityLevel: 0 + sssQualityMode: 0 + sssQualityLevel: 0 + sssCustomSampleBudget: 20 materialQuality: 0 m_RenderPipelineSettings: supportShadowMask: 1 supportSSR: 0 + supportSSRTransparent: 0 supportSSAO: 1 supportSubsurfaceScattering: 1 - increaseSssSampleCount: 0 + sssSampleBudget: + m_Values: 140000002800000050000000 + m_SchemaId: + m_Id: With3Levels supportVolumetrics: 1 - increaseResolutionOfVolumetrics: 0 supportLightLayers: 0 lightLayerName0: Light Layer default lightLayerName1: Light Layer 1 @@ -218,15 +231,23 @@ MonoBehaviour: supportRuntimeDebugDisplay: 1 supportDitheringCrossFade: 1 supportTerrainHole: 0 + supportProbeVolume: 0 supportRayTracing: 0 - supportedRaytracingTier: 2 + supportedRayTracingMode: 3 + probeVolumeSettings: + atlasWidth: 128 + atlasHeight: 128 + atlasDepth: 512 + atlasOctahedralDepthWidth: 2048 + atlasOctahedralDepthHeight: 2048 lightLoopSettings: - cookieSize: 128 - cookieTexArraySize: 16 + cookieAtlasSize: 512 + cookieFormat: 74 pointCookieSize: 128 cubeCookieTexArraySize: 16 - planarReflectionProbeCacheSize: 2 - planarReflectionTextureSize: 1024 + cookieAtlasLastValidMip: 0 + cookieTexArraySize: 16 + planarReflectionAtlasSize: 4096 reflectionProbeCacheSize: 64 reflectionCubemapSize: 256 reflectionCacheCompressed: 0 @@ -241,6 +262,7 @@ MonoBehaviour: maxAreaLightsOnScreen: 64 maxEnvLightsOnScreen: 64 maxDecalsOnScreen: 512 + maxPlanarReflectionOnScreen: 16 hdShadowInitParams: maxShadowRequests: 128 directionalShadowsDepthBits: 16 @@ -269,7 +291,8 @@ MonoBehaviour: maxPunctualShadowMapResolution: 2048 maxAreaShadowMapResolution: 2048 supportScreenSpaceShadows: 0 - maxScreenSpaceShadows: 2 + maxScreenSpaceShadowSlots: 4 + screenSpaceShadowBufferFormat: 48 decalSettings: drawDistance: 1000 atlasWidth: 4096 @@ -278,6 +301,7 @@ MonoBehaviour: postProcessSettings: m_LutSize: 32 lutFormat: 48 + bufferFormat: 74 dynamicResolutionSettings: enabled: 0 maxPercentage: 100 @@ -293,6 +317,7 @@ MonoBehaviour: xrSettings: singlePass: 1 occlusionMesh: 1 + cameraJitter: 0 postProcessQualitySettings: NearBlurSampleCount: 030000000500000008000000 NearBlurMaxRadius: From 20fd59389dc1b4002a108be34c0d5719549705c1 Mon Sep 17 00:00:00 2001 From: aleks01010101 <31240064+aleks01010101@users.noreply.github.com> Date: Fri, 22 May 2020 16:41:26 +0200 Subject: [PATCH 02/11] Enable caching preprocessor in HD template. (#578) --- com.unity.template-hd/ProjectSettings/EditorSettings.asset | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/com.unity.template-hd/ProjectSettings/EditorSettings.asset b/com.unity.template-hd/ProjectSettings/EditorSettings.asset index 125f2ccef56..652e2f799ff 100644 --- a/com.unity.template-hd/ProjectSettings/EditorSettings.asset +++ b/com.unity.template-hd/ProjectSettings/EditorSettings.asset @@ -19,8 +19,9 @@ EditorSettings: m_ProjectGenerationRootNamespace: m_EnableTextureStreamingInEditMode: 1 m_EnableTextureStreamingInPlayMode: 1 + m_EnableRoslynAnalyzers: 0 m_AsyncShaderCompilation: 1 - m_CachingShaderPreprocessor: 0 + m_CachingShaderPreprocessor: 1 m_EnterPlayModeOptionsEnabled: 0 m_EnterPlayModeOptions: 3 m_UseLegacyProbeSampleCount: 0 From f2066279882ce1878bac301d340050a70d3ffa88 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Fri, 22 May 2020 15:43:52 +0100 Subject: [PATCH 03/11] Added terrain lit doc (#573) * Add terrain lit doc * Update HDRP-Features.md * Update HDRP-Features.md --- .../Documentation~/HDRP-Features.md | 3 +- .../Images/TerrainLitShader1.png | 3 ++ .../Documentation~/TableOfContents.md | 1 + .../Documentation~/Terrain-Lit-Shader.md | 46 +++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 com.unity.render-pipelines.high-definition/Documentation~/Images/TerrainLitShader1.png create mode 100644 com.unity.render-pipelines.high-definition/Documentation~/Terrain-Lit-Shader.md diff --git a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Features.md b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Features.md index 73f8f3bbe18..e3c1be83a66 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Features.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/HDRP-Features.md @@ -40,7 +40,6 @@ Use Volumes to localize environmental Scene settings and post-processing effects HDRP Shaders allow you to use the following features: - [Opaque/transparent surfaces](Surface-Type.md). - - Different blend modes for transparent surfaces. - Transparent surfaces that work with fog. - Refraction and distortion for transparent surfaces. @@ -116,7 +115,7 @@ The Decal Shader allows you to place decals on surfaces in your Scene. To apply ![](Images/HDRPFeatures-TerrainShader.png) -The Terrain Lit Shader is compatible with the built-in terrain system and supports up to eight layers in a single draw call. This Shader uses the same lighting model as the Lit Shader. +The Terrain Lit Shader is compatible with the built-in terrain system and supports up to eight layers in a single draw call. This Shader uses the same lighting model as the Lit Shader. For more information, including the full list of Shader properties, see the [Terrain Lit Shader documentation](Terrain-Lit-Shader.md). diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Images/TerrainLitShader1.png b/com.unity.render-pipelines.high-definition/Documentation~/Images/TerrainLitShader1.png new file mode 100644 index 00000000000..930b14bca24 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Images/TerrainLitShader1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33e6168455c6873019999e3206267be8e3f7a93d6ef9e9d9c94c0c13949f2fbf +size 45539 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md b/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md index 3507974c933..3dc362227fe 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md @@ -64,6 +64,7 @@ * [Layered Lit Shader](Layered-Lit-Shader) * [Lit Tessellation Shader](Lit-Tessellation-Shader) * [Lit Shader](Lit-Shader) + * [Terrain Lit Shader](Terrain-Lit-Shader.md) * [Unlit Shader](Unlit-Shader) * Shader Graph Master Nodes * [Customizing Materials Using Master Nodes](Customizing-HDRP-materials-with-Shader-Graph) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Terrain-Lit-Shader.md b/com.unity.render-pipelines.high-definition/Documentation~/Terrain-Lit-Shader.md new file mode 100644 index 00000000000..a2e5d3ac8db --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Documentation~/Terrain-Lit-Shader.md @@ -0,0 +1,46 @@ +# **Terrain Lit Shader** + +The High Definition Render Pipeline (HDRP) uses the Terrain Lit Shader for Unity Terrain. This Shader is a simpler version of the [Lit Shader](Lit-Shader.md). A Terrain can use a Terrain Lit Material with up to eight [Terrain Layers](https://docs.unity3d.com/Manual/class-TerrainLayer.html). + +![](Images/HDRPFeatures-TerrainShader.png) + +## Creating a Terrain Lit Material + +To create a new Terrain Lit Shader Material: + +1. Go to your Project window and right-click in the **Assets** folder +2. Select **Create > Material**. This adds a new Material to your Unity Project’s Asset folder. +3. Click on the Material to view it in the Inspector. +4. Click on the **Shader** drop-down and select **HDRP > TerrainLit**. + +## Using a Terrain Lit Material + +To use a Terrain Lit Material, you must assign it to a Terrain: + +1. View the Terrain in the Inspector and click on the cog button to go to the **Terrain Settings** section. +2. Either drag and drop or use the radio button to assign your Terrain Lit Material to the **Material** property. + +![](Images/TerrainLitShader1.png) + +## Material properties + +### Surface Options + +| **Property** | **Description** | +| ------------------ | ------------------------------------------------------------ | +| **Receive Decals** | Enable this checkbox to allow HDRP to draw decals on this Material’s surface. | + +### Terrain + +| **Property** | **Description** | +| ----------------------------- | ------------------------------------------------------------ | +| **Enable Height-based Blend** | Specifies whether HDRP should only render the Terrain Layer with the greatest height value for a particular pixel. When enabled, HDRP takes the height values from the blue channel of the **Mask Map** Texture. When disabled, HDRP blends the Terrain Layers based on the weights painted in the control map Textures. | +| **- Height Transition** | Controls how much HDRP blends the terrain if multiple Terrain Layers are approximately the same height. | +| **Enable Per-pixel Normal** | Specifies whether HDRP should sample the normal map Texture on a per-pixel level. When enabled, Unity preserves more geometry details for distant terrain parts. Unity generates a geometry normal map at runtime from the heightmap, rather than the Mesh geometry. This means you can have high-resolution Mesh normals, even if your Mesh is low resolution. It only works if you enable **Draw Instanced** on the terrain. | +| **Specular Occlusion Mode** | Sets the mode that HDRP uses to calculate specular occlusion.
• **Off**: Disables specular occlusion.
• **From Ambient Occlusion**: Calculates specular occlusion from the ambient occlusion map and the Camera's view direction. | + +### Advanced Options + +| **Property** | **Description** | +| ------------------------- | ------------------------------------------------------------ | +| **Enable GPU Instancing** | Enable this checkbox to tell HDRP to render meshes with the same geometry and Material/Shader in one batch when possible. This makes rendering faster. HDRP can not render Meshes in one batch if they have different Materials, or if the hardware does not support GPU instancing. | \ No newline at end of file From d5327018cd3fe242493291487aab80769c849435 Mon Sep 17 00:00:00 2001 From: JordanL8 Date: Fri, 22 May 2020 16:48:56 +0100 Subject: [PATCH 04/11] Added note on decal emission on transparent surfaces (#567) * Update Decal-Projector.md * Update Decal-Projector.md * Update Decal-Projector.md --- .../Documentation~/Decal-Projector.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Decal-Projector.md b/com.unity.render-pipelines.high-definition/Documentation~/Decal-Projector.md index 37ad65a2972..088a8523a98 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Decal-Projector.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Decal-Projector.md @@ -45,4 +45,5 @@ Using the Inspector allows you to change all of the Decal Projector properties, ## Limitations - If you project a decal onto a transparent surface, HDRP ignores the decal's Texture tiling. +- When you project a decal onto a surface, the emissive component of the decal affects the surface regardless of whether you enable **Receive Decal** on the surface's Material or not. - In **Project Settings > Graphics**, if **Instancing Variants** is set to **Strip All**, Unity strips the Decal Shader this component references when you build your Project. This happens even if you include the Shader in the **Always Included Shaders** list. If Unity strips the Shader during the build process, the decal does not appear in your built Application. From c8a93e17e6891c325beeebb1a5d0c5eb2ba1eba9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aras=20Pranckevi=C4=8Dius?= Date: Fri, 22 May 2020 15:53:16 -0700 Subject: [PATCH 05/11] Enable "Shaded Wireframe" scene view mode in HDRP & URP (#356) * Enable "Shaded Wireframe" scene view mode in HDRP & URP Will need graphics/srp/textured-wire codebase branch to work * Use new DrawWireOverlay API point to render wireframe This way it's not coupled to Gizmos rendering or not Co-authored-by: Sebastien Lagarde --- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 15 +++++++++++++++ .../Runtime/RenderPipeline/SceneViewDrawMode.cs | 3 +-- .../Runtime/SceneViewDrawMode.cs | 3 +-- .../Runtime/ScriptableRenderer.cs | 9 +++++++++ 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index f9e29a6c68e..bbfd0bf5710 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -2790,6 +2790,9 @@ void Callback(CommandBuffer c, HDCamera cam) // We need to make sure the viewport is correctly set for the editor rendering. It might have been changed by debug overlay rendering just before. cmd.SetViewport(hdCamera.finalViewport); + if (camera.cameraType == CameraType.SceneView) + RenderWireOverlay(cmd, camera, renderContext); + // Render overlay Gizmos if (showGizmos) RenderGizmos(cmd, camera, renderContext, GizmoSubset.PostImageEffects); @@ -3110,6 +3113,18 @@ void RenderGizmos(CommandBuffer cmd, Camera camera, ScriptableRenderContext rend #endif } +#if UNITY_EDITOR + void RenderWireOverlay(CommandBuffer cmd, Camera camera, ScriptableRenderContext renderContext) + { + using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RenderWireFrame))) + { + renderContext.ExecuteCommandBuffer(cmd); + cmd.Clear(); + renderContext.DrawWireOverlay(camera); + } + } +#endif + static RendererListDesc CreateOpaqueRendererListDesc( CullingResults cull, Camera camera, diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs index 0ba33475185..2a53fd38784 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs @@ -11,8 +11,7 @@ class SceneViewDrawMode static private bool RejectDrawMode(SceneView.CameraMode cameraMode) { - if (cameraMode.drawMode == DrawCameraMode.TexturedWire || - cameraMode.drawMode == DrawCameraMode.ShadowCascades || + if (cameraMode.drawMode == DrawCameraMode.ShadowCascades || cameraMode.drawMode == DrawCameraMode.RenderPaths || cameraMode.drawMode == DrawCameraMode.AlphaChannel || cameraMode.drawMode == DrawCameraMode.Overdraw || diff --git a/com.unity.render-pipelines.universal/Runtime/SceneViewDrawMode.cs b/com.unity.render-pipelines.universal/Runtime/SceneViewDrawMode.cs index d9b5cc2004f..9290c50c960 100644 --- a/com.unity.render-pipelines.universal/Runtime/SceneViewDrawMode.cs +++ b/com.unity.render-pipelines.universal/Runtime/SceneViewDrawMode.cs @@ -10,8 +10,7 @@ internal static class SceneViewDrawMode static bool RejectDrawMode(SceneView.CameraMode cameraMode) { - if (cameraMode.drawMode == DrawCameraMode.TexturedWire || - cameraMode.drawMode == DrawCameraMode.ShadowCascades || + if (cameraMode.drawMode == DrawCameraMode.ShadowCascades || cameraMode.drawMode == DrawCameraMode.RenderPaths || cameraMode.drawMode == DrawCameraMode.AlphaChannel || cameraMode.drawMode == DrawCameraMode.Overdraw || diff --git a/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs b/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs index 8d1234f08a5..7f9aea8c171 100644 --- a/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs +++ b/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs @@ -432,6 +432,7 @@ public void Execute(ScriptableRenderContext context, ref RenderingData rendering EndXRRendering(context, renderingData, eyeIndex); } + DrawWireOverlay(context, camera); DrawGizmos(context, camera, GizmoSubset.PostImageEffects); InternalFinishRendering(context, cameraData.resolveFinalTarget); @@ -835,6 +836,14 @@ void DrawGizmos(ScriptableRenderContext context, Camera camera, GizmoSubset gizm #endif } + [Conditional("UNITY_EDITOR")] + void DrawWireOverlay(ScriptableRenderContext context, Camera camera) + { +#if UNITY_EDITOR + context.DrawWireOverlay(camera); +#endif + } + // Fill in render pass indices for each block. End index is startIndex + 1. void FillBlockRanges(NativeArray blockEventLimits, NativeArray blockRanges) { From a99394f52dc9e7833069113503d94a49ef0b8c96 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Sat, 23 May 2020 15:42:48 +0200 Subject: [PATCH 06/11] [9.x.x] Merge Hdrp/staging [Skip CI] (#582) --- .../Direct3D11/None/4052_TAA.png | 4 +- .../Direct3D12/None/4052_TAA.png | 4 +- .../WindowsEditor/Vulkan/None/4052_TAA.png | 4 +- .../ParticleRibbonLitVolumeProfile.asset | 17 +- .../Direct3D11/None/ParticleRibbonLit.png | 4 +- .../VisualEffectGraph/Packages/manifest.json | 1 - .../Runtime/Debugging/ProfilingScope.cs | 80 +-- .../Runtime/RenderGraph/RenderGraph.cs | 627 +++++++++++++----- .../Runtime/RenderGraph/RenderGraphBuilder.cs | 67 +- .../Runtime/RenderGraph/RenderGraphLogger.cs | 4 +- .../Runtime/RenderGraph/RenderGraphPass.cs | 155 +++++ .../RenderGraph/RenderGraphPass.cs.meta | 11 + .../RenderGraphResourceRegistry.cs | 146 ++-- .../CHANGELOG.md | 8 + .../Documentation~/Shadows-in-HDRP.md | 45 +- .../Upgrading-from-2019.3-to-2020.1.md | 6 +- .../Upgrading-from-2020.1-to-2020.2.md | 3 + .../DefaultScene/HDWizard.Configuration.cs | 18 +- .../Editor/DefaultScene/HDWizard.Window.cs | 2 +- .../Editor/Lighting/HDLightUI.cs | 4 - .../Editor/PostProcessing/ExposureEditor.cs | 29 +- .../RenderPipeline/HDRenderPipelineUI.Skin.cs | 1 + .../RenderPipeline/HDRenderPipelineUI.cs | 18 + .../SerializedHDShadowInitParameters.cs | 6 + .../DefaultSettingsVolumeProfile.asset | 15 +- .../Runtime/Debug/DebugDisplay.cs | 65 +- .../Runtime/Debug/DebugDisplay.hlsl | 12 +- .../Runtime/Debug/DebugExposure.shader | 552 +++++++++++++++ .../Runtime/Debug/DebugExposure.shader.meta | 10 + .../Runtime/Debug/LightingDebug.cs | 26 + .../Runtime/Debug/LightingDebug.cs.hlsl | 14 +- .../Light/HDAdditionalLightData.Types.cs | 10 + .../Lighting/Light/HDAdditionalLightData.cs | 205 ++++-- .../Runtime/Lighting/LightLoop/HDShadow.hlsl | 31 +- .../Runtime/Lighting/LightLoop/LightLoop.cs | 23 +- .../AmbientOcclusion.RenderGraph.cs | 6 +- .../ScreenSpaceLighting/AmbientOcclusion.cs | 4 +- .../Lighting/Shadow/HDCachedShadowAtlas.cs | 524 +++++++++++++++ .../Shadow/HDCachedShadowAtlas.cs.meta | 11 + .../Lighting/Shadow/HDCachedShadowManager.cs | 306 +++++++++ .../Shadow/HDCachedShadowManager.cs.meta | 11 + .../Lighting/Shadow/HDDynamicShadowAtlas.cs | 174 +++++ .../Shadow/HDDynamicShadowAtlas.cs.meta | 11 + .../Lighting/Shadow/HDShadowAlgorithms.hlsl | 25 +- .../Runtime/Lighting/Shadow/HDShadowAtlas.cs | 350 +--------- .../Lighting/Shadow/HDShadowContext.hlsl | 2 + .../Shadow/HDShadowManager.RenderGraph.cs | 8 + .../Lighting/Shadow/HDShadowManager.cs | 287 ++++---- .../Lighting/Shadow/HDShadowManager.cs.hlsl | 2 +- .../Lighting/Shadow/HDShadowSampling.hlsl | 5 +- .../VolumetricLighting/VolumetricLighting.cs | 4 +- .../PostProcessing/Components/Exposure.cs | 23 +- .../PostProcessing/Components/Tonemapping.cs | 1 + .../Components/Tonemapping.cs.hlsl | 17 + .../Components/Tonemapping.cs.hlsl.meta | 10 + .../PostProcessSystem.RenderGraph.cs | 6 +- .../PostProcessing/PostProcessSystem.cs | 161 ++++- .../PostProcessing/Shaders/Exposure.compute | 118 +--- .../Shaders/ExposureCommon.hlsl | 108 +++ .../Shaders/ExposureCommon.hlsl.meta | 10 + .../Shaders/HistogramExposure.compute | 183 +++++ .../Shaders/HistogramExposure.compute.meta | 9 + .../Shaders/HistogramExposureCommon.hlsl | 39 ++ .../Shaders/HistogramExposureCommon.hlsl.meta | 10 + .../Shaders/TemporalAntiAliasing.shader | 12 +- .../Shaders/TemporalAntialiasing.hlsl | 21 +- .../Runtime/RenderPipeline/Camera/HDCamera.cs | 4 +- .../RenderPipeline/HDRenderPipeline.Debug.cs | 22 +- .../HDRenderPipeline.LightLoop.cs | 8 +- .../HDRenderPipeline.Prepass.cs | 9 +- .../HDRenderPipeline.RenderGraph.cs | 44 +- .../HDRenderPipeline.SubsurfaceScattering.cs | 4 +- .../RenderPipeline/HDRenderPipeline.cs | 165 ++++- .../RenderPipeline/HDStringConstants.cs | 10 + .../RenderPipeline/RenderPipelineResources.cs | 4 + .../RenderPipeline/Settings/FrameSettings.cs | 4 +- .../HDRenderPipelineResources.asset | 11 +- .../ShaderLibrary/ShaderVariablesGlobal.cs | 2 + .../ShaderVariablesGlobal.cs.hlsl | 2 + 79 files changed, 3813 insertions(+), 1161 deletions(-) create mode 100644 com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphPass.cs create mode 100644 com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphPass.cs.meta create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Debug/DebugExposure.shader create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Debug/DebugExposure.shader.meta create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs.meta create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowManager.cs create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowManager.cs.meta create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDDynamicShadowAtlas.cs create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDDynamicShadowAtlas.cs.meta create mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs.hlsl create mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs.hlsl.meta create mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ExposureCommon.hlsl create mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ExposureCommon.hlsl.meta create mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute create mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute.meta create mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposureCommon.hlsl create mode 100644 com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposureCommon.hlsl.meta diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png index 4534ab5eb74..7059218d5cd 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/4052_TAA.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1d43ff69730e73cf5f93d14ce3a093740ee5839a8a152c89dee4e9c1c06fafe7 -size 194711 +oid sha256:a01c7037e175b53757f0817eab662a6e4ed7b8b8cac307ee8d3d06f7addd9949 +size 194892 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/4052_TAA.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/4052_TAA.png index 4dbe4daad35..29e9292b101 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/4052_TAA.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/4052_TAA.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c812051d824a98920aff0d715b1f64e2065948e4d2e0d164cb3f29183ec276c1 -size 195032 +oid sha256:71ccd1b22457703a01b693b7cfbf942789655a93819eeb777280c0d677e94797 +size 193823 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png index 5ad4ba31e42..f10c04ad7cd 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:da78f222b1a08ccc6d7fea0a4ccba9f647b7ef7ee8e3f9d3680c5ffa8b0071bd -size 219643 +oid sha256:e5e47d48cc5c372d5b864784ba6647f5d1fbe2f4aac72c7f4d2055ba509a1b0a +size 306 diff --git a/TestProjects/VisualEffectGraph/Assets/AllTests/VFXTests/GraphicsTests/ParticleRibbonLit/ParticleRibbonLitVolumeProfile.asset b/TestProjects/VisualEffectGraph/Assets/AllTests/VFXTests/GraphicsTests/ParticleRibbonLit/ParticleRibbonLitVolumeProfile.asset index e4a87301421..f7c31296f6d 100644 --- a/TestProjects/VisualEffectGraph/Assets/AllTests/VFXTests/GraphicsTests/ParticleRibbonLit/ParticleRibbonLitVolumeProfile.asset +++ b/TestProjects/VisualEffectGraph/Assets/AllTests/VFXTests/GraphicsTests/ParticleRibbonLit/ParticleRibbonLitVolumeProfile.asset @@ -30,7 +30,7 @@ MonoBehaviour: m_AdvancedMode: 0 mode: m_OverrideState: 1 - m_Value: 1 + m_Value: 0 meteringMode: m_OverrideState: 0 m_Value: 2 @@ -38,8 +38,8 @@ MonoBehaviour: m_OverrideState: 0 m_Value: 1 fixedExposure: - m_OverrideState: 0 - m_Value: 0 + m_OverrideState: 1 + m_Value: 7 compensation: m_OverrideState: 0 m_Value: 0 @@ -86,3 +86,14 @@ MonoBehaviour: m_OverrideState: 0 m_Value: 1 min: 0.001 + weightTextureMask: + m_OverrideState: 0 + m_Value: {fileID: 0} + histogramPercentages: + m_OverrideState: 0 + m_Value: {x: 40, y: 90} + min: 0 + max: 100 + histogramUseCurveRemapping: + m_OverrideState: 0 + m_Value: 0 diff --git a/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png b/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png index b6f278818f9..c859c3b6974 100644 --- a/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png +++ b/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a18582acac1cebbc30c724cc7b00a811b6ebdeab3b93f63fdf6624f6b5e12ce5 -size 190375 +oid sha256:ae4f30fa1034f864944232a6e8367ff4d951841116eb60270ab2f1864b0dd52e +size 189993 diff --git a/TestProjects/VisualEffectGraph/Packages/manifest.json b/TestProjects/VisualEffectGraph/Packages/manifest.json index e5de5c4b889..8ba7ace601c 100644 --- a/TestProjects/VisualEffectGraph/Packages/manifest.json +++ b/TestProjects/VisualEffectGraph/Packages/manifest.json @@ -15,7 +15,6 @@ "com.unity.timeline": "1.2.9", "com.unity.ugui": "1.0.0", "com.unity.visualeffectgraph": "file:../../../com.unity.visualeffectgraph", - "com.unity.xr.legacyinputhelpers": "2.1.2", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", diff --git a/com.unity.render-pipelines.core/Runtime/Debugging/ProfilingScope.cs b/com.unity.render-pipelines.core/Runtime/Debugging/ProfilingScope.cs index e0e17821416..1a7176e509e 100644 --- a/com.unity.render-pipelines.core/Runtime/Debugging/ProfilingScope.cs +++ b/com.unity.render-pipelines.core/Runtime/Debugging/ProfilingScope.cs @@ -98,6 +98,42 @@ public ProfilingSampler(string name) #endif } + /// + /// Begin the profiling block. + /// + /// Command buffer used by the profiling block. + public void Begin(CommandBuffer cmd) + { + if (cmd != null) +#if UNITY_USE_RECORDER + if (sampler != null) + cmd.BeginSample(sampler); + else + cmd.BeginSample(name); +#else + cmd.BeginSample(name); +#endif + inlineSampler?.Begin(); + } + + /// + /// End the profiling block. + /// + /// Command buffer used by the profiling block. + public void End(CommandBuffer cmd) + { + if (cmd != null) +#if UNITY_USE_RECORDER + if (sampler != null) + cmd.EndSample(sampler); + else + cmd.EndSample(name); +#else + m_Cmd.EndSample(name); +#endif + inlineSampler?.End(); + } + internal bool IsValid() { return (sampler != null && inlineSampler != null); } internal CustomSampler sampler { get; private set; } @@ -187,11 +223,9 @@ public bool enableRecording /// public struct ProfilingScope : IDisposable { - string m_Name; - CommandBuffer m_Cmd; - bool m_Disposed; - CustomSampler m_Sampler; - CustomSampler m_InlineSampler; + CommandBuffer m_Cmd; + bool m_Disposed; + ProfilingSampler m_Sampler; /// /// Profiling Scope constructor @@ -202,29 +236,8 @@ public ProfilingScope(CommandBuffer cmd, ProfilingSampler sampler) { m_Cmd = cmd; m_Disposed = false; - if (sampler != null) - { - m_Name = sampler.name; // Don't use CustomSampler.name because it causes garbage - m_Sampler = sampler.sampler; - m_InlineSampler = sampler.inlineSampler; - } - else - { - m_Name = "NullProfilingSampler"; // Don't use CustomSampler.name because it causes garbage - m_Sampler = null; - m_InlineSampler = null; - } - - if (cmd != null) -#if UNITY_USE_RECORDER - if (m_Sampler != null) - cmd.BeginSample(m_Sampler); - else - cmd.BeginSample(m_Name); -#else - cmd.BeginSample(m_Name); -#endif - m_InlineSampler?.Begin(); + m_Sampler = sampler; + m_Sampler?.Begin(m_Cmd); } /// @@ -246,16 +259,7 @@ void Dispose(bool disposing) // this but will generate garbage on every frame (and this struct is used quite a lot). if (disposing) { - if (m_Cmd != null) -#if UNITY_USE_RECORDER - if (m_Sampler != null) - m_Cmd.EndSample(m_Sampler); - else - m_Cmd.EndSample(m_Name); -#else - m_Cmd.EndSample(m_Name); -#endif - m_InlineSampler?.End(); + m_Sampler?.End(m_Cmd); } m_Disposed = true; diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs index 700251d73a0..8cd7f991fbc 100644 --- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs @@ -1,8 +1,6 @@ using System; -using System.Diagnostics; using System.Collections.Generic; using UnityEngine.Rendering; -using UnityEngine.Profiling; namespace UnityEngine.Experimental.Rendering.RenderGraphModule { @@ -95,110 +93,81 @@ public class RenderGraph ///Maximum number of MRTs supported by Render Graph. public static readonly int kMaxMRTCount = 8; - [DebuggerDisplay("RenderPass ({name})")] - internal abstract class RenderPass - { - internal RenderFunc GetExecuteDelegate() - where PassData : class, new() => ((RenderPass)this).renderFunc; - - internal abstract void Execute(RenderGraphContext renderGraphContext); - internal abstract void Release(RenderGraphContext renderGraphContext); - internal abstract bool HasRenderFunc(); - - internal string name; - internal int index; - internal ProfilingSampler customSampler; - internal List textureReadList = new List(); - internal List textureWriteList = new List(); - internal List bufferReadList = new List(); - internal List bufferWriteList = new List(); - internal List usedRendererListList = new List(); - internal bool enableAsyncCompute; - internal TextureHandle depthBuffer { get { return m_DepthBuffer; } } - internal TextureHandle[] colorBuffers { get { return m_ColorBuffers; } } - internal int colorBufferMaxIndex { get { return m_MaxColorBufferIndex; } } - - protected TextureHandle[] m_ColorBuffers = new TextureHandle[kMaxMRTCount]; - protected TextureHandle m_DepthBuffer; - protected int m_MaxColorBufferIndex = -1; - - internal void Clear() - { - name = ""; - index = -1; - customSampler = null; - textureReadList.Clear(); - textureWriteList.Clear(); - bufferReadList.Clear(); - bufferWriteList.Clear(); - usedRendererListList.Clear(); - enableAsyncCompute = false; - - // Invalidate everything - m_MaxColorBufferIndex = -1; - m_DepthBuffer = new TextureHandle(); - for (int i = 0; i < RenderGraph.kMaxMRTCount; ++i) - { - m_ColorBuffers[i] = new TextureHandle(); - } - } - - internal void SetColorBuffer(TextureHandle resource, int index) - { - Debug.Assert(index < RenderGraph.kMaxMRTCount && index >= 0); - m_MaxColorBufferIndex = Math.Max(m_MaxColorBufferIndex, index); - m_ColorBuffers[index] = resource; - textureWriteList.Add(resource); - } + internal struct CompiledResourceInfo + { + public List producers; + public bool resourceCreated; + public int lastReadPassIndex; + public int firstWritePassIndex; + public int refCount; - internal void SetDepthBuffer(TextureHandle resource, DepthAccess flags) + public void Reset() { - m_DepthBuffer = resource; - if ((flags | DepthAccess.Read) != 0) - textureReadList.Add(resource); - if ((flags | DepthAccess.Write) != 0) - textureWriteList.Add(resource); - + if (producers == null) + producers = new List(); + + producers.Clear(); + resourceCreated = false; + lastReadPassIndex = -1; + firstWritePassIndex = int.MaxValue; + refCount = 0; } } - internal sealed class RenderPass : RenderPass - where PassData : class, new() + internal struct CompiledPassInfo { - internal PassData data; - internal RenderFunc renderFunc; - - internal override void Execute(RenderGraphContext renderGraphContext) + public RenderGraphPass pass; + public List textureCreateList; + public List textureReleaseList; + public int refCount; + public bool pruned; + public bool hasSideEffect; + public int syncToPassIndex; // Index of the pass that needs to be waited for. + public int syncFromPassIndex; // Smaller pass index that waits for this pass. + public bool needGraphicsFence; + public GraphicsFence fence; + + public bool enableAsyncCompute { get { return pass.enableAsyncCompute; } } + + public void Reset(RenderGraphPass pass) { - GetExecuteDelegate()(data, renderGraphContext); - } + this.pass = pass; - internal override void Release(RenderGraphContext renderGraphContext) - { - Clear(); - renderGraphContext.renderGraphPool.Release(data); - data = null; - renderFunc = null; - renderGraphContext.renderGraphPool.Release(this); - } + if (textureCreateList == null) + { + textureCreateList = new List(); + textureReleaseList = new List(); + } - internal override bool HasRenderFunc() - { - return renderFunc != null; + textureCreateList.Clear(); + textureReleaseList.Clear(); + refCount = 0; + pruned = false; + hasSideEffect = false; + syncToPassIndex = -1; + syncFromPassIndex = -1; + needGraphicsFence = false; } } - RenderGraphResourceRegistry m_Resources; - RenderGraphObjectPool m_RenderGraphPool = new RenderGraphObjectPool(); - List m_RenderPasses = new List(); - List m_RendererLists = new List(); - RenderGraphDebugParams m_DebugParameters = new RenderGraphDebugParams(); - RenderGraphLogger m_Logger = new RenderGraphLogger(); - RenderGraphDefaultResources m_DefaultResources = new RenderGraphDefaultResources(); + RenderGraphResourceRegistry m_Resources; + RenderGraphObjectPool m_RenderGraphPool = new RenderGraphObjectPool(); + List m_RenderPasses = new List(); + List m_RendererLists = new List(); + RenderGraphDebugParams m_DebugParameters = new RenderGraphDebugParams(); + RenderGraphLogger m_Logger = new RenderGraphLogger(); + RenderGraphDefaultResources m_DefaultResources = new RenderGraphDefaultResources(); + Dictionary m_DefaultProfilingSamplers = new Dictionary(); + + // Compiled Render Graph info. + DynamicArray m_CompiledTextureInfos = new DynamicArray(); + DynamicArray m_CompiledBufferInfos = new DynamicArray(); + DynamicArray m_CompiledPassInfos = new DynamicArray(); + Stack m_PruningStack = new Stack(); #region Public Interface - // TODO: Currently only needed by SSAO to sample correctly depth texture mips. Need to figure out a way to hide this behind a proper formalization. + // TODO RENDERGRAPH: Currently only needed by SSAO to sample correctly depth texture mips. Need to figure out a way to hide this behind a proper formalization. /// /// Gets the RTHandleProperties structure associated with the Render Graph's RTHandle System. /// @@ -347,12 +316,8 @@ public ComputeBufferHandle ImportComputeBuffer(ComputeBuffer computeBuffer) /// A new instance of a RenderGraphBuilder used to setup the new Render Pass. public RenderGraphBuilder AddRenderPass(string passName, out PassData passData, ProfilingSampler sampler = null) where PassData : class, new() { - var renderPass = m_RenderGraphPool.Get>(); - renderPass.Clear(); - renderPass.index = m_RenderPasses.Count; - renderPass.data = m_RenderGraphPool.Get(); - renderPass.name = passName; - renderPass.customSampler = sampler; + var renderPass = m_RenderGraphPool.Get>(); + renderPass.Initialize(m_RenderPasses.Count, m_RenderGraphPool.Get(), passName, sampler != null ? sampler : GetDefaultProfilingSampler(passName)); passData = renderPass.data; @@ -369,88 +334,363 @@ public ComputeBufferHandle ImportComputeBuffer(ComputeBuffer computeBuffer) /// Render Graph execution parameters. public void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, in RenderGraphExecuteParams parameters) { - m_Logger.Initialize(); + try + { + m_Logger.Initialize(); - // Update RTHandleSystem with size for this rendering pass. - m_Resources.SetRTHandleReferenceSize(parameters.renderingWidth, parameters.renderingHeight, parameters.msaaSamples); + // Update RTHandleSystem with size for this rendering pass. + m_Resources.SetRTHandleReferenceSize(parameters.renderingWidth, parameters.renderingHeight, parameters.msaaSamples); - LogFrameInformation(parameters.renderingWidth, parameters.renderingHeight); + LogFrameInformation(parameters.renderingWidth, parameters.renderingHeight); - // First pass, traversal and pruning - for (int passIndex = 0; passIndex < m_RenderPasses.Count; ++passIndex) + CompileRenderGraph(); + ExecuteRenderGraph(renderContext, cmd); + } + catch (Exception e) { - var pass = m_RenderPasses[passIndex]; + Debug.LogError("Render Graph Execution error"); + Debug.LogException(e); + } + finally + { + ClearCompiledGraph(); - // TODO: Pruning + if (m_DebugParameters.logFrameInformation || m_DebugParameters.logResources) + Debug.Log(m_Logger.GetLog()); - // Gather all renderer lists - m_RendererLists.AddRange(pass.usedRendererListList); + m_DebugParameters.logFrameInformation = false; + m_DebugParameters.logResources = false; } + } + #endregion - // Creates all renderer lists - m_Resources.CreateRendererLists(m_RendererLists); - LogRendererListsCreation(); + #region Internal Interface + private RenderGraph() + { - // Second pass, execution - RenderGraphContext rgContext = new RenderGraphContext(); - rgContext.cmd = cmd; - rgContext.renderContext = renderContext; - rgContext.renderGraphPool = m_RenderGraphPool; - rgContext.resources = m_Resources; - rgContext.defaultResources = m_DefaultResources; + } - try + void ClearCompiledGraph() + { + ClearRenderPasses(); + m_Resources.Clear(); + m_DefaultResources.Clear(); + m_RendererLists.Clear(); + m_CompiledBufferInfos.Clear(); + m_CompiledTextureInfos.Clear(); + m_CompiledPassInfos.Clear(); + } + + void InitializeCompilationData() + { + m_CompiledBufferInfos.Resize(m_Resources.GetComputeBufferResourceCount()); + for (int i = 0; i < m_CompiledBufferInfos.size; ++i) + m_CompiledBufferInfos[i].Reset(); + m_CompiledTextureInfos.Resize(m_Resources.GetTextureResourceCount()); + for (int i = 0; i < m_CompiledTextureInfos.size; ++i) + m_CompiledTextureInfos[i].Reset(); + m_CompiledPassInfos.Resize(m_RenderPasses.Count); + for (int i = 0; i < m_CompiledPassInfos.size; ++i) + m_CompiledPassInfos[i].Reset(m_RenderPasses[i]); + } + + void CountReferences() + { + for (int passIndex = 0; passIndex < m_CompiledPassInfos.size; ++passIndex) { - for (int passIndex = 0; passIndex < m_RenderPasses.Count; ++passIndex) + ref CompiledPassInfo passInfo = ref m_CompiledPassInfos[passIndex]; + + var textureRead = passInfo.pass.textureReadList; + foreach (TextureHandle texture in textureRead) + { + ref CompiledResourceInfo info = ref m_CompiledTextureInfos[texture]; + info.refCount++; + } + + var textureWrite = passInfo.pass.textureWriteList; + foreach (TextureHandle texture in textureWrite) + { + ref CompiledResourceInfo info = ref m_CompiledTextureInfos[texture]; + info.producers.Add(passIndex); + passInfo.refCount++; + + // Writing to an imported texture is considered as a side effect because we don't know what users will do with it outside of render graph. + if (m_Resources.IsTextureImported(texture)) + passInfo.hasSideEffect = true; + } + + // Can't share the code with a generic func as TextureHandle and ComputeBufferHandle are both struct and can't inherit from a common struct with a shared API (thanks C#) + var bufferRead = passInfo.pass.bufferReadList; + foreach (ComputeBufferHandle buffer in bufferRead) + { + ref CompiledResourceInfo info = ref m_CompiledBufferInfos[buffer]; + info.refCount++; + } + + var bufferWrite = passInfo.pass.bufferWriteList; + foreach (ComputeBufferHandle buffer in bufferWrite) + { + ref CompiledResourceInfo info = ref m_CompiledBufferInfos[buffer]; + passInfo.refCount++; + } + } + } + + void PruneUnusedPasses(DynamicArray resourceUsageList) + { + // First gather resources that are never read. + m_PruningStack.Clear(); + for (int i = 0; i < resourceUsageList.size; ++i) + { + if (resourceUsageList[i].refCount == 0) { - var pass = m_RenderPasses[passIndex]; + m_PruningStack.Push(i); + } + } - if (!pass.HasRenderFunc()) + while (m_PruningStack.Count != 0) + { + var unusedResource = resourceUsageList[m_PruningStack.Pop()]; + foreach (var producerIndex in unusedResource.producers) + { + ref var producerInfo = ref m_CompiledPassInfos[producerIndex]; + producerInfo.refCount--; + if (producerInfo.refCount == 0 && !producerInfo.hasSideEffect) { - throw new InvalidOperationException(string.Format("RenderPass {0} was not provided with an execute function.", pass.name)); + // Producer is not necessary anymore as it produces zero resources + // Prune it and decrement refCount of all the textures it reads. + producerInfo.pruned = true; + foreach (var textureIndex in producerInfo.pass.textureReadList) + { + ref CompiledResourceInfo resourceInfo = ref resourceUsageList[textureIndex]; + resourceInfo.refCount--; + // If a texture is not used anymore, add it to the stack to be processed in subsequent iteration. + if (resourceInfo.refCount == 0) + m_PruningStack.Push(textureIndex); + } } + } + } + } + + void PruneUnusedPasses() + { + PruneUnusedPasses(m_CompiledTextureInfos); + PruneUnusedPasses(m_CompiledBufferInfos); + LogPrunedPasses(); + } + + int GetLatestProducerIndex(int passIndex, in CompiledResourceInfo info) + { + // We want to know the highest pass index below the current pass that writes to the resource. + int result = -1; + foreach (var producer in info.producers) + { + // producers are by construction in increasing order. + if (producer < passIndex) + result = producer; + else + return result; + } + + return result; + } + + + void UpdatePassSynchronization(ref CompiledPassInfo currentPassInfo, ref CompiledPassInfo producerPassInfo, int currentPassIndex, int lastProducer, ref int intLastSyncIndex) + { + // Current pass needs to wait for pass index lastProducer + currentPassInfo.syncToPassIndex = lastProducer; + // Update latest pass waiting for the other pipe. + intLastSyncIndex = lastProducer; + + // Producer will need a graphics fence that this pass will wait on. + producerPassInfo.needGraphicsFence = true; + // We update the producer pass with the index of the smallest pass waiting for it. + // This will be used to "lock" resource from being reused until the pipe has been synchronized. + if (producerPassInfo.syncFromPassIndex == -1) + producerPassInfo.syncFromPassIndex = currentPassIndex; + } - using (new ProfilingScope(cmd, pass.customSampler)) + void UpdateResourceSynchronization(ref int lastGraphicsPipeSync, ref int lastComputePipeSync, int currentPassIndex, in CompiledResourceInfo resource) + { + int lastProducer = GetLatestProducerIndex(currentPassIndex, resource); + if (lastProducer != -1) + { + ref CompiledPassInfo currentPassInfo = ref m_CompiledPassInfos[currentPassIndex]; + + //If the passes are on different pipes, we need synchronization. + if (m_CompiledPassInfos[lastProducer].enableAsyncCompute != currentPassInfo.enableAsyncCompute) + { + // Pass is on compute pipe, need sync with graphics pipe. + if (currentPassInfo.enableAsyncCompute) { - LogRenderPassBegin(pass); - using (new RenderGraphLogIndent(m_Logger)) + if (lastProducer > lastGraphicsPipeSync) { - PreRenderPassExecute(passIndex, pass, rgContext); - pass.Execute(rgContext); - PostRenderPassExecute(passIndex, pass, rgContext); + UpdatePassSynchronization(ref currentPassInfo, ref m_CompiledPassInfos[lastProducer], currentPassIndex, lastProducer, ref lastGraphicsPipeSync); + } + } + else + { + if (lastProducer > lastComputePipeSync) + { + UpdatePassSynchronization(ref currentPassInfo, ref m_CompiledPassInfos[lastProducer], currentPassIndex, lastProducer, ref lastComputePipeSync); } } } } - catch(Exception e) + } + + void UpdateResourceAllocationAndSynchronization() + { + int lastGraphicsPipeSync = -1; + int lastComputePipeSync = -1; + + // First go through all passes. + // - Update the last pass read index for each resource. + // - Add texture to creation list for passes that first write to a texture. + // - Update synchronization points for all resources between compute and graphics pipes. + for (int passIndex = 0; passIndex < m_CompiledPassInfos.size; ++passIndex) { - Debug.LogError("Render Graph Execution error"); - Debug.LogException(e); + ref CompiledPassInfo passInfo = ref m_CompiledPassInfos[passIndex]; + + if (passInfo.pruned) + continue; + + foreach (TextureHandle texture in passInfo.pass.textureReadList) + { + ref CompiledResourceInfo resourceInfo = ref m_CompiledTextureInfos[texture]; + resourceInfo.lastReadPassIndex = Math.Max(resourceInfo.lastReadPassIndex, passIndex); + UpdateResourceSynchronization(ref lastGraphicsPipeSync, ref lastComputePipeSync, passIndex, resourceInfo); + } + + foreach (TextureHandle texture in passInfo.pass.textureWriteList) + { + ref CompiledResourceInfo resourceInfo = ref m_CompiledTextureInfos[texture]; + if (resourceInfo.firstWritePassIndex == int.MaxValue) + { + resourceInfo.firstWritePassIndex = Math.Min(resourceInfo.firstWritePassIndex, passIndex); + passInfo.textureCreateList.Add(texture); + } + passInfo.refCount++; + UpdateResourceSynchronization(ref lastGraphicsPipeSync, ref lastComputePipeSync, passIndex, resourceInfo); + } + + foreach (ComputeBufferHandle texture in passInfo.pass.bufferReadList) + { + UpdateResourceSynchronization(ref lastGraphicsPipeSync, ref lastComputePipeSync, passIndex, m_CompiledBufferInfos[texture]); + } + foreach (ComputeBufferHandle texture in passInfo.pass.bufferWriteList) + { + UpdateResourceSynchronization(ref lastGraphicsPipeSync, ref lastComputePipeSync, passIndex, m_CompiledBufferInfos[texture]); + } + + // Add transient resources that are only used during this pass. + foreach (TextureHandle texture in passInfo.pass.transientTextureList) + { + passInfo.textureCreateList.Add(texture); + + ref CompiledResourceInfo info = ref m_CompiledTextureInfos[texture]; + info.lastReadPassIndex = passIndex; + } + + // Gather all renderer lists + m_RendererLists.AddRange(passInfo.pass.usedRendererListList); } - finally + + // Now push textures to the release list of the pass that reads it last. + for (int i = 0; i < m_CompiledTextureInfos.size; ++i) { - ClearRenderPasses(); - m_Resources.Clear(); - m_DefaultResources.Clear(); - m_RendererLists.Clear(); + CompiledResourceInfo textureInfo = m_CompiledTextureInfos[i]; + if (textureInfo.lastReadPassIndex != -1) + { + // In case of async passes, we need to extend lifetime of resource to the first pass on the graphics pipeline that wait for async passes to be over. + // Otherwise, if we freed the resource right away during an async pass, another non async pass could reuse the resource even though the async pipe is not done. + if (m_CompiledPassInfos[textureInfo.lastReadPassIndex].enableAsyncCompute) + { + int currentPassIndex = textureInfo.lastReadPassIndex; + int firstWaitingPassIndex = m_CompiledPassInfos[currentPassIndex].syncFromPassIndex; + // Find the first async pass that is synchronized by the graphics pipeline (ie: passInfo.syncFromPassIndex != -1) + while (firstWaitingPassIndex == -1 && currentPassIndex < m_CompiledPassInfos.size) + { + currentPassIndex++; + if(m_CompiledPassInfos[currentPassIndex].enableAsyncCompute) + firstWaitingPassIndex = m_CompiledPassInfos[currentPassIndex].syncFromPassIndex; + } - if (m_DebugParameters.logFrameInformation || m_DebugParameters.logResources) - Debug.Log(m_Logger.GetLog()); + // Finally add the release command to the pass before the first pass that waits for the compute pipe. + ref CompiledPassInfo passInfo = ref m_CompiledPassInfos[Math.Max(0, firstWaitingPassIndex - 1)]; + passInfo.textureReleaseList.Add(new TextureHandle(i)); - m_DebugParameters.logFrameInformation = false; - m_DebugParameters.logResources = false; + // Fail safe in case render graph is badly formed. + if (currentPassIndex == m_CompiledPassInfos.size) + { + RenderGraphPass invalidPass = m_RenderPasses[textureInfo.lastReadPassIndex]; + throw new InvalidOperationException($"Asynchronous pass {invalidPass.name} was never synchronized on the graphics pipeline."); + } + } + else + { + ref CompiledPassInfo passInfo = ref m_CompiledPassInfos[textureInfo.lastReadPassIndex]; + passInfo.textureReleaseList.Add(new TextureHandle(i)); + } + } } + + // Creates all renderer lists + m_Resources.CreateRendererLists(m_RendererLists); } - #endregion - #region Internal Interface - private RenderGraph() + // Traverse the render graph: + // - Determines when resources are created/released + // - Determines async compute pass synchronization + // - Prune unused render passes. + void CompileRenderGraph() { + InitializeCompilationData(); + CountReferences(); + PruneUnusedPasses(); + UpdateResourceAllocationAndSynchronization(); + LogRendererListsCreation(); + } + + // Execute the compiled render graph + void ExecuteRenderGraph(ScriptableRenderContext renderContext, CommandBuffer cmd) + { + RenderGraphContext rgContext = new RenderGraphContext(); + rgContext.cmd = cmd; + rgContext.renderContext = renderContext; + rgContext.renderGraphPool = m_RenderGraphPool; + rgContext.resources = m_Resources; + rgContext.defaultResources = m_DefaultResources; + for (int passIndex = 0; passIndex < m_CompiledPassInfos.size; ++passIndex) + { + ref var passInfo = ref m_CompiledPassInfos[passIndex]; + if (passInfo.pruned) + continue; + + if (!passInfo.pass.HasRenderFunc()) + { + throw new InvalidOperationException(string.Format("RenderPass {0} was not provided with an execute function.", passInfo.pass.name)); + } + + using (new ProfilingScope(rgContext.cmd, passInfo.pass.customSampler)) + { + LogRenderPassBegin(passInfo); + using (new RenderGraphLogIndent(m_Logger)) + { + PreRenderPassExecute(passInfo, ref rgContext); + passInfo.pass.Execute(rgContext); + PostRenderPassExecute(cmd, ref passInfo, ref rgContext); + } + } + } } - void PreRenderPassSetRenderTargets(in RenderPass pass, RenderGraphContext rgContext) + void PreRenderPassSetRenderTargets(in CompiledPassInfo passInfo, RenderGraphContext rgContext) { + var pass = passInfo.pass; if (pass.depthBuffer.IsValid() || pass.colorBufferMaxIndex != -1) { var mrtArray = rgContext.renderGraphPool.GetTempArray(pass.colorBufferMaxIndex + 1); @@ -492,21 +732,61 @@ void PreRenderPassSetRenderTargets(in RenderPass pass, RenderGraphContext rgCont } } - void PreRenderPassExecute(int passIndex, in RenderPass pass, RenderGraphContext rgContext) + void PreRenderPassExecute(in CompiledPassInfo passInfo, ref RenderGraphContext rgContext) { - // TODO merge clear and setup here if possible - m_Resources.CreateAndClearTexturesForPass(rgContext, pass.index, pass.textureWriteList); - PreRenderPassSetRenderTargets(pass, rgContext); + // TODO RENDERGRAPH merge clear and setup here if possible + RenderGraphPass pass = passInfo.pass; + + // TODO RENDERGRAPH remove this when we do away with auto global texture setup + // (can't put it in the profiling scope otherwise it might be executed on compute queue which is not possible for global sets) m_Resources.PreRenderPassSetGlobalTextures(rgContext, pass.textureReadList); + + foreach (var texture in passInfo.textureCreateList) + m_Resources.CreateAndClearTexture(rgContext, texture); + + PreRenderPassSetRenderTargets(passInfo, rgContext); + + // Flush first the current command buffer on the render context. + rgContext.renderContext.ExecuteCommandBuffer(rgContext.cmd); + rgContext.cmd.Clear(); + + if (pass.enableAsyncCompute) + { + CommandBuffer asyncCmd = CommandBufferPool.Get(pass.name); + asyncCmd.SetExecutionFlags(CommandBufferExecutionFlags.AsyncCompute); + rgContext.cmd = asyncCmd; + } + + // Synchronize with graphics or compute pipe if needed. + if (passInfo.syncToPassIndex != -1) + { + rgContext.cmd.WaitOnAsyncGraphicsFence(m_CompiledPassInfos[passInfo.syncToPassIndex].fence); + } } - void PostRenderPassExecute(int passIndex, in RenderPass pass, RenderGraphContext rgContext) + void PostRenderPassExecute(CommandBuffer mainCmd, ref CompiledPassInfo passInfo, ref RenderGraphContext rgContext) { + RenderGraphPass pass = passInfo.pass; + + if (passInfo.needGraphicsFence) + passInfo.fence = rgContext.cmd.CreateAsyncGraphicsFence(); + + if (pass.enableAsyncCompute) + { + // The command buffer has been filled. We can kick the async task. + rgContext.renderContext.ExecuteCommandBufferAsync(rgContext.cmd, ComputeQueueType.Background); + CommandBufferPool.Release(rgContext.cmd); + rgContext.cmd = mainCmd; // Restore the main command buffer. + } + if (m_DebugParameters.unbindGlobalTextures) m_Resources.PostRenderPassUnbindGlobalTextures(rgContext, pass.textureReadList); m_RenderGraphPool.ReleaseAllTempAlloc(); - m_Resources.ReleaseTexturesForPass(rgContext, pass.index, pass.textureReadList, pass.textureWriteList); + + foreach (var texture in passInfo.textureReleaseList) + m_Resources.ReleaseTexture(rgContext, texture); + pass.Release(rgContext); } @@ -520,7 +800,7 @@ void LogFrameInformation(int renderingWidth, int renderingHeight) if (m_DebugParameters.logFrameInformation) { m_Logger.LogLine("==== Staring frame at resolution ({0}x{1}) ====", renderingWidth, renderingHeight); - m_Logger.LogLine("Number of passes declared: {0}", m_RenderPasses.Count); + m_Logger.LogLine("Number of passes declared: {0}\n", m_RenderPasses.Count); } } @@ -528,18 +808,57 @@ void LogRendererListsCreation() { if (m_DebugParameters.logFrameInformation) { - m_Logger.LogLine("Number of renderer lists created: {0}", m_RendererLists.Count); + m_Logger.LogLine("Number of renderer lists created: {0}\n", m_RendererLists.Count); + } + } + + void LogRenderPassBegin(in CompiledPassInfo passInfo) + { + if (m_DebugParameters.logFrameInformation) + { + RenderGraphPass pass = passInfo.pass; + + m_Logger.LogLine("[{0}][{1}] \"{2}\"", pass.index, pass.enableAsyncCompute ? "Compute" : "Graphics", pass.name); + using (new RenderGraphLogIndent(m_Logger)) + { + if (passInfo.syncToPassIndex != -1) + m_Logger.LogLine("Synchronize with [{0}]", passInfo.syncToPassIndex); + } } } - void LogRenderPassBegin(in RenderPass pass) + void LogPrunedPasses() { if (m_DebugParameters.logFrameInformation) { - m_Logger.LogLine("Executing pass \"{0}\" (index: {1})", pass.name, pass.index); + m_Logger.LogLine("Pass pruning report:"); + using (new RenderGraphLogIndent(m_Logger)) + { + for (int i = 0; i < m_CompiledPassInfos.size; ++i) + { + if (m_CompiledPassInfos[i].pruned) + { + var pass = m_RenderPasses[i]; + m_Logger.LogLine("[{0}] {1}", pass.index, pass.name); + } + } + m_Logger.LogLine("\n"); + } } } + ProfilingSampler GetDefaultProfilingSampler(string name) + { + int hash = name.GetHashCode(); + if (!m_DefaultProfilingSamplers.TryGetValue(hash, out var sampler)) + { + sampler = new ProfilingSampler(name); + m_DefaultProfilingSamplers.Add(hash, sampler); + } + + return sampler; + } + #endregion } } diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs index b100ba50abc..404565f4297 100644 --- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphBuilder.cs @@ -8,7 +8,7 @@ namespace UnityEngine.Experimental.Rendering.RenderGraphModule /// public struct RenderGraphBuilder : IDisposable { - RenderGraph.RenderPass m_RenderPass; + RenderGraphPass m_RenderPass; RenderGraphResourceRegistry m_Resources; bool m_Disposed; @@ -22,8 +22,9 @@ public struct RenderGraphBuilder : IDisposable /// An updated resource handle to the input resource. public TextureHandle UseColorBuffer(TextureHandle input, int index) { + CheckTransientTexture(input); + m_RenderPass.SetColorBuffer(input, index); - m_Resources.UpdateTextureFirstWrite(input, m_RenderPass.index); return input; } @@ -35,11 +36,9 @@ public TextureHandle UseColorBuffer(TextureHandle input, int index) /// An updated resource handle to the input resource. public TextureHandle UseDepthBuffer(TextureHandle input, DepthAccess flags) { + CheckTransientTexture(input); + m_RenderPass.SetDepthBuffer(input, flags); - if ((flags | DepthAccess.Read) != 0) - m_Resources.UpdateTextureLastRead(input, m_RenderPass.index); - if ((flags | DepthAccess.Write) != 0) - m_Resources.UpdateTextureFirstWrite(input, m_RenderPass.index); return input; } @@ -50,8 +49,9 @@ public TextureHandle UseDepthBuffer(TextureHandle input, DepthAccess flags) /// An updated resource handle to the input resource. public TextureHandle ReadTexture(TextureHandle input) { - m_RenderPass.textureReadList.Add(input); - m_Resources.UpdateTextureLastRead(input, m_RenderPass.index); + CheckTransientTexture(input); + + m_RenderPass.AddTextureRead(input); return input; } @@ -62,12 +62,39 @@ public TextureHandle ReadTexture(TextureHandle input) /// An updated resource handle to the input resource. public TextureHandle WriteTexture(TextureHandle input) { + CheckTransientTexture(input); + // TODO: Manage resource "version" for debugging purpose - m_RenderPass.textureWriteList.Add(input); - m_Resources.UpdateTextureFirstWrite(input, m_RenderPass.index); + m_RenderPass.AddTextureWrite(input); return input; } + /// + /// Create a new Render Graph Texture resource. + /// This texture will only be available for the current pass and will be assumed to be both written and read so users don't need to add explicit read/write declarations. + /// + /// Texture descriptor. + /// A new transient TextureHandle. + public TextureHandle CreateTransientTexture(in TextureDesc desc) + { + var result = m_Resources.CreateTexture(desc, 0, m_RenderPass.index); + m_RenderPass.AddTransientTexture(result); + return result; + } + + /// + /// Create a new Render Graph Texture resource using the descriptor from another texture. + /// + /// Texture from which the descriptor should be used. + /// A new transient TextureHandle. + public TextureHandle CreateTransientTexture(TextureHandle texture) + { + var desc = m_Resources.GetTextureResourceDesc(texture); + var result = m_Resources.CreateTexture(desc, 0, m_RenderPass.index); + m_RenderPass.AddTransientTexture(result); + return result; + } + /// /// Specify a Renderer List resource to use during the pass. /// @@ -75,7 +102,7 @@ public TextureHandle WriteTexture(TextureHandle input) /// An updated resource handle to the input resource. public RendererListHandle UseRendererList(RendererListHandle input) { - m_RenderPass.usedRendererListList.Add(input); + m_RenderPass.UseRendererList(input); return input; } @@ -86,7 +113,7 @@ public RendererListHandle UseRendererList(RendererListHandle input) /// An updated resource handle to the input resource. public ComputeBufferHandle ReadComputeBuffer(ComputeBufferHandle input) { - m_RenderPass.bufferReadList.Add(input); + m_RenderPass.AddBufferRead(input); return input; } @@ -97,7 +124,7 @@ public ComputeBufferHandle ReadComputeBuffer(ComputeBufferHandle input) /// An updated resource handle to the input resource. public ComputeBufferHandle WriteComputeBuffer(ComputeBufferHandle input) { - m_RenderPass.bufferWriteList.Add(input); + m_RenderPass.AddBufferWrite(input); return input; } @@ -109,7 +136,7 @@ public ComputeBufferHandle WriteComputeBuffer(ComputeBufferHandle input) /// Render function for the pass. public void SetRenderFunc(RenderFunc renderFunc) where PassData : class, new() { - ((RenderGraph.RenderPass)m_RenderPass).renderFunc = renderFunc; + ((RenderGraphPass)m_RenderPass).renderFunc = renderFunc; } /// @@ -118,7 +145,7 @@ public ComputeBufferHandle WriteComputeBuffer(ComputeBufferHandle input) /// Set to true to enable asynchronous compute. public void EnableAsyncCompute(bool value) { - m_RenderPass.enableAsyncCompute = value; + m_RenderPass.EnableAsyncCompute(value); } /// @@ -131,7 +158,7 @@ public void Dispose() #endregion #region Internal Interface - internal RenderGraphBuilder(RenderGraph.RenderPass renderPass, RenderGraphResourceRegistry resources) + internal RenderGraphBuilder(RenderGraphPass renderPass, RenderGraphResourceRegistry resources) { m_RenderPass = renderPass; m_Resources = resources; @@ -145,6 +172,14 @@ void Dispose(bool disposing) m_Disposed = true; } + + void CheckTransientTexture(TextureHandle input) + { + if (input.transientPassIndex != -1 && input.transientPassIndex != m_RenderPass.index) + { + throw new ArgumentException($"Trying to use a transient texture (pass index {input.transientPassIndex}) in a different pass (pass index {m_RenderPass.index}."); + } + } #endregion } } diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphLogger.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphLogger.cs index b41e1fcfe29..df946c91743 100644 --- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphLogger.cs +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphLogger.cs @@ -25,10 +25,12 @@ public void Dispose() void Dispose(bool disposing) { + Debug.Assert(m_Logger != null, "RenderGraphLogIndent: logger parameter should not be null."); + if (m_Disposed) return; - if (disposing) + if (disposing && m_Logger != null) { m_Logger.DecrementIndentation(m_Indentation); } diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphPass.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphPass.cs new file mode 100644 index 00000000000..7a3c5b5ca67 --- /dev/null +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphPass.cs @@ -0,0 +1,155 @@ +using System; +using System.Diagnostics; +using System.Collections.Generic; +using UnityEngine.Rendering; + +namespace UnityEngine.Experimental.Rendering.RenderGraphModule +{ + [DebuggerDisplay("RenderPass: {name} (Index:{index} Async:{enableAsyncCompute})")] + abstract class RenderGraphPass + { + public RenderFunc GetExecuteDelegate() + where PassData : class, new() => ((RenderGraphPass)this).renderFunc; + + public abstract void Execute(RenderGraphContext renderGraphContext); + public abstract void Release(RenderGraphContext renderGraphContext); + public abstract bool HasRenderFunc(); + + public string name { get; protected set; } + public int index { get; protected set; } + public ProfilingSampler customSampler { get; protected set; } + public bool enableAsyncCompute { get; protected set; } + + public TextureHandle depthBuffer { get; protected set; } + public TextureHandle[] colorBuffers { get; protected set; } = new TextureHandle[RenderGraph.kMaxMRTCount]; + public int colorBufferMaxIndex { get; protected set; } = -1; + public int refCount { get; protected set; } + + List m_TextureReadList = new List(); + List m_TextureWriteList = new List(); + List m_TransientTextureList = new List(); + List m_BufferReadList = new List(); + List m_BufferWriteList = new List(); + List m_UsedRendererListList = new List(); + + public IReadOnlyCollection textureReadList { get { return m_TextureReadList; } } + public IReadOnlyCollection textureWriteList { get { return m_TextureWriteList; } } + public IReadOnlyCollection transientTextureList { get { return m_TransientTextureList; } } + public IReadOnlyCollection bufferReadList { get { return m_BufferReadList; } } + public IReadOnlyCollection bufferWriteList { get { return m_BufferWriteList; } } + public IReadOnlyCollection usedRendererListList { get { return m_UsedRendererListList; } } + + public void Clear() + { + name = ""; + index = -1; + customSampler = null; + m_TextureReadList.Clear(); + m_TextureWriteList.Clear(); + m_BufferReadList.Clear(); + m_BufferWriteList.Clear(); + m_TransientTextureList.Clear(); + m_UsedRendererListList.Clear(); + enableAsyncCompute = false; + refCount = 0; + + // Invalidate everything + colorBufferMaxIndex = -1; + depthBuffer = new TextureHandle(); + for (int i = 0; i < RenderGraph.kMaxMRTCount; ++i) + { + colorBuffers[i] = new TextureHandle(); + } + } + + public void AddTextureWrite(TextureHandle texture) + { + m_TextureWriteList.Add(texture); + refCount++; + } + + public void AddTextureRead(TextureHandle texture) + { + m_TextureReadList.Add(texture); + } + + public void AddBufferWrite(ComputeBufferHandle buffer) + { + m_BufferWriteList.Add(buffer); + refCount++; + } + + public void AddTransientTexture(TextureHandle texture) + { + m_TransientTextureList.Add(texture); + } + + public void AddBufferRead(ComputeBufferHandle buffer) + { + m_BufferReadList.Add(buffer); + } + + public void UseRendererList(RendererListHandle rendererList) + { + m_UsedRendererListList.Add(rendererList); + } + + public void EnableAsyncCompute(bool value) + { + enableAsyncCompute = value; + } + + public void SetColorBuffer(TextureHandle resource, int index) + { + Debug.Assert(index < RenderGraph.kMaxMRTCount && index >= 0); + colorBufferMaxIndex = Math.Max(colorBufferMaxIndex, index); + colorBuffers[index] = resource; + AddTextureWrite(resource); + } + + public void SetDepthBuffer(TextureHandle resource, DepthAccess flags) + { + depthBuffer = resource; + if ((flags | DepthAccess.Read) != 0) + AddTextureRead(resource); + if ((flags | DepthAccess.Write) != 0) + AddTextureWrite(resource); + } + } + + [DebuggerDisplay("RenderPass: {name} (Index:{index} Async:{enableAsyncCompute})")] + internal sealed class RenderGraphPass : RenderGraphPass + where PassData : class, new() + { + internal PassData data; + internal RenderFunc renderFunc; + + public override void Execute(RenderGraphContext renderGraphContext) + { + GetExecuteDelegate()(data, renderGraphContext); + } + + public void Initialize(int passIndex, PassData passData, string passName, ProfilingSampler sampler) + { + Clear(); + index = passIndex; + data = passData; + name = passName; + customSampler = sampler; + } + + public override void Release(RenderGraphContext renderGraphContext) + { + Clear(); + renderGraphContext.renderGraphPool.Release(data); + data = null; + renderFunc = null; + renderGraphContext.renderGraphPool.Release(this); + } + + public override bool HasRenderFunc() + { + return renderFunc != null; + } + } +} diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphPass.cs.meta b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphPass.cs.meta new file mode 100644 index 00000000000..9f00928f05e --- /dev/null +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphPass.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 377a2b96156b1344eaf58df67e35de17 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs index 3b8a66efc34..c186e92c47f 100644 --- a/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs +++ b/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs @@ -18,7 +18,8 @@ public struct TextureHandle { bool m_IsValid; internal int handle { get; private set; } - internal TextureHandle(int handle) { this.handle = handle; m_IsValid = true; } + internal int transientPassIndex { get; private set; } + internal TextureHandle(int handle, int transientPassIndex = -1) { this.handle = handle; m_IsValid = true; this.transientPassIndex = transientPassIndex; } /// /// Conversion to int. /// @@ -30,6 +31,7 @@ public struct TextureHandle /// /// True if the handle is valid. public bool IsValid() => m_IsValid; + } /// @@ -292,8 +294,6 @@ internal struct TextureResource public bool imported; public RTHandle rt; public int cachedHash; - public int firstWritePassIndex; - public int lastReadPassIndex; public int shaderProperty; public bool wasReleased; @@ -321,8 +321,6 @@ void Reset() imported = false; rt = null; cachedHash = -1; - firstWritePassIndex = int.MaxValue; - lastReadPassIndex = -1; wasReleased = false; } } @@ -441,6 +439,11 @@ internal TextureHandle ImportTexture(RTHandle rt, int shaderProperty = 0) return new TextureHandle(newHandle); } + internal bool IsTextureImported(TextureHandle handle) + { + return handle.IsValid() ? GetTextureResource(handle).imported : false; + } + internal TextureHandle ImportBackbuffer(RenderTargetIdentifier rt) { if (m_CurrentBackbuffer != null) @@ -452,36 +455,17 @@ internal TextureHandle ImportBackbuffer(RenderTargetIdentifier rt) return new TextureHandle(newHandle); } - internal TextureHandle CreateTexture(in TextureDesc desc, int shaderProperty = 0) + internal TextureHandle CreateTexture(in TextureDesc desc, int shaderProperty = 0, int transientPassIndex = -1) { ValidateTextureDesc(desc); int newHandle = m_TextureResources.Add(new TextureResource(desc, shaderProperty)); - return new TextureHandle(newHandle); - } - - internal void UpdateTextureFirstWrite(TextureHandle tex, int passIndex) - { - ref var res = ref GetTextureResource(tex); - res.firstWritePassIndex = Math.Min(passIndex, res.firstWritePassIndex); - - //// We increment lastRead index here so that a resource used only for a single pass can be released at the end of said pass. - //// This will also keep the resource alive as long as it is written to. - //// Typical example is a depth buffer that may never be explicitly read from but is necessary all along - /// - // PROBLEM: Increasing last read on write operation will keep the target alive even if it's not used at all so it's not good. - // If we don't do it though, it means that client code cannot write "by default" into a target as it will try to write to an already released target. - // Example: - // DepthPrepass: Writes to Depth and Normal buffers (pass will create normal buffer) - // ObjectMotion: Writes to MotionVectors and Normal => Exception because NormalBuffer is already released as it not used. - // => Solution includes : Shader Combination (without MRT for example) / Dummy Targets - //res.lastReadPassIndex = Math.Max(passIndex, res.lastReadPassIndex); + return new TextureHandle(newHandle, transientPassIndex); } - internal void UpdateTextureLastRead(TextureHandle tex, int passIndex) + internal int GetTextureResourceCount() { - ref var res = ref GetTextureResource(tex); - res.lastReadPassIndex = Math.Max(passIndex, res.lastReadPassIndex); + return m_TextureResources.size; } ref TextureResource GetTextureResource(TextureHandle res) @@ -508,29 +492,36 @@ internal ComputeBufferHandle ImportComputeBuffer(ComputeBuffer computeBuffer) return new ComputeBufferHandle(newHandle); } - internal void CreateAndClearTexturesForPass(RenderGraphContext rgContext, int passIndex, List textures) + internal int GetComputeBufferResourceCount() + { + return m_ComputeBufferResources.size; + } + + internal ref ComputeBufferResource GetComputeBufferResource(ComputeBufferHandle res) { - foreach (var rgResource in textures) + return ref m_ComputeBufferResources[res]; + } + + internal void CreateAndClearTexture(RenderGraphContext rgContext, TextureHandle texture) + { + ref var resource = ref GetTextureResource(texture); + if (!resource.imported) { - ref var resource = ref GetTextureResource(rgResource); - if (!resource.imported && resource.firstWritePassIndex == passIndex) - { - CreateTextureForPass(ref resource); + CreateTextureForPass(ref resource); - if (resource.desc.clearBuffer || m_RenderGraphDebug.clearRenderTargetsAtCreation) + if (resource.desc.clearBuffer || m_RenderGraphDebug.clearRenderTargetsAtCreation) + { + bool debugClear = m_RenderGraphDebug.clearRenderTargetsAtCreation && !resource.desc.clearBuffer; + var name = debugClear ? "RenderGraph: Clear Buffer (Debug)" : "RenderGraph: Clear Buffer"; + using (new ProfilingScope(rgContext.cmd, ProfilingSampler.Get(RenderGraphProfileId.RenderGraphClear))) { - bool debugClear = m_RenderGraphDebug.clearRenderTargetsAtCreation && !resource.desc.clearBuffer; - var name = debugClear ? "RenderGraph: Clear Buffer (Debug)" : "RenderGraph: Clear Buffer"; - using (new ProfilingScope(rgContext.cmd, ProfilingSampler.Get(RenderGraphProfileId.RenderGraphClear))) - { - var clearFlag = resource.desc.depthBufferBits != DepthBits.None ? ClearFlag.Depth : ClearFlag.Color; - var clearColor = debugClear ? Color.magenta : resource.desc.clearColor; - CoreUtils.SetRenderTarget(rgContext.cmd, resource.rt, clearFlag, clearColor); - } + var clearFlag = resource.desc.depthBufferBits != DepthBits.None ? ClearFlag.Depth : ClearFlag.Color; + var clearColor = debugClear ? Color.magenta : resource.desc.clearColor; + CoreUtils.SetRenderTarget(rgContext.cmd, resource.rt, clearFlag, clearColor); } - - LogTextureCreation(resource.rt, resource.desc.clearBuffer || m_RenderGraphDebug.clearRenderTargetsAtCreation); } + + LogTextureCreation(resource.rt, resource.desc.clearBuffer || m_RenderGraphDebug.clearRenderTargetsAtCreation); } } @@ -540,7 +531,7 @@ void CreateTextureForPass(ref TextureResource resource) int hashCode = desc.GetHashCode(); if(resource.rt != null) - throw new InvalidOperationException(string.Format("Trying to create an already created texture ({0}). Texture was probably declared for writing more than once.", resource.desc.name)); + throw new InvalidOperationException(string.Format("Trying to create an already created texture ({0}). Texture was probably declared for writing more than once in the same pass.", resource.desc.name)); resource.rt = null; if (!TryGetRenderTarget(hashCode, out resource.rt)) @@ -578,7 +569,7 @@ void CreateTextureForPass(ref TextureResource resource) resource.cachedHash = hashCode; } - void SetGlobalTextures(RenderGraphContext rgContext, List textures, bool bindDummyTexture) + void SetGlobalTextures(RenderGraphContext rgContext, IReadOnlyCollection textures, bool bindDummyTexture) { foreach (var resource in textures) { @@ -595,62 +586,35 @@ void SetGlobalTextures(RenderGraphContext rgContext, List texture } - internal void PreRenderPassSetGlobalTextures(RenderGraphContext rgContext, List textures) + internal void PreRenderPassSetGlobalTextures(RenderGraphContext rgContext, IReadOnlyCollection textures) { SetGlobalTextures(rgContext, textures, false); } - internal void PostRenderPassUnbindGlobalTextures(RenderGraphContext rgContext, List textures) + internal void PostRenderPassUnbindGlobalTextures(RenderGraphContext rgContext, IReadOnlyCollection textures) { SetGlobalTextures(rgContext, textures, true); } - internal void ReleaseTexturesForPass(RenderGraphContext rgContext, int passIndex, List readTextures, List writtenTextures) + internal void ReleaseTexture(RenderGraphContext rgContext, TextureHandle resource) { - foreach (var resource in readTextures) + ref var resourceDesc = ref GetTextureResource(resource); + if (!resourceDesc.imported) { - ref var resourceDesc = ref GetTextureResource(resource); - if (!resourceDesc.imported && resourceDesc.lastReadPassIndex == passIndex) + if (m_RenderGraphDebug.clearRenderTargetsAtRelease) { - if (m_RenderGraphDebug.clearRenderTargetsAtRelease) + using (new ProfilingScope(rgContext.cmd, ProfilingSampler.Get(RenderGraphProfileId.RenderGraphClearDebug))) { - using (new ProfilingScope(rgContext.cmd, ProfilingSampler.Get(RenderGraphProfileId.RenderGraphClearDebug))) - { - var clearFlag = resourceDesc.desc.depthBufferBits != DepthBits.None ? ClearFlag.Depth : ClearFlag.Color; - CoreUtils.SetRenderTarget(rgContext.cmd, GetTexture(resource), clearFlag, Color.magenta); - } + var clearFlag = resourceDesc.desc.depthBufferBits != DepthBits.None ? ClearFlag.Depth : ClearFlag.Color; + CoreUtils.SetRenderTarget(rgContext.cmd, GetTexture(resource), clearFlag, Color.magenta); } - - ReleaseTextureForPass(resource); - } - } - - // If a resource was created for only a single pass, we don't want users to have to declare explicitly the read operation. - // So to do that, we also update lastReadIndex on resource writes. - // This means that we need to check written resources for destruction too - foreach (var resource in writtenTextures) - { - ref var resourceDesc = ref GetTextureResource(resource); - // <= because a texture that is only declared as written in a single pass (and read implicitly in the same pass) will have the default lastReadPassIndex at -1 - if (!resourceDesc.imported && resourceDesc.lastReadPassIndex <= passIndex) - { - ReleaseTextureForPass(resource); } - } - } - - void ReleaseTextureForPass(TextureHandle res) - { - ref var resource = ref m_TextureResources[res]; - // This can happen because we release texture in two passes (see ReleaseTexturesForPass) and texture can be present in both passes - if (resource.rt != null) - { - LogTextureRelease(resource.rt); - ReleaseTextureResource(resource.cachedHash, resource.rt); - resource.cachedHash = -1; - resource.rt = null; - resource.wasReleased = true; + LogTextureRelease(resourceDesc.rt); + ReleaseTextureResource(resourceDesc.cachedHash, resourceDesc.rt); + resourceDesc.cachedHash = -1; + resourceDesc.rt = null; + resourceDesc.wasReleased = true; } } @@ -761,12 +725,16 @@ internal void Clear() #if DEVELOPMENT_BUILD || UNITY_EDITOR if (m_AllocatedTextures.Count != 0) { - Debug.LogWarning("RenderGraph: Not all textures were released."); + string logMessage = "RenderGraph: Not all textures were released."; + List<(int, RTHandle)> tempList = new List<(int, RTHandle)>(m_AllocatedTextures); foreach (var value in tempList) { + logMessage = $"{logMessage}\n\t{value.Item2.name}"; ReleaseTextureResource(value.Item1, value.Item2); } + + Debug.LogWarning(logMessage); } #endif } diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index eaac5078538..17a49195636 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -127,6 +127,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Add a new parameter to control reflections in recursive rendering. - Added an initial version of SSGI. - Added CustomPassUtils API to simplify Blur, Copy and DrawRenderers custom passes. +- Added Histogram guided automatic exposure. +- Added few exposure debug modes. ### Fixed - Fix when rescale probe all direction below zero (1219246) @@ -615,6 +617,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed taaFrameIndex and XR tests 4052 and 4053 - Fixed the prefab integration of custom passes (Prefab Override Highlight not working as expected). - Cloned volume profile from read only assets are created in the root of the project. (case 1154961) +- Fixed Wizard check on default volume profile to also check it is not the default one in package. +- Fix erroneous central depth sampling in TAA. +- Fixed light layers not correctly disabled when the lightlayers is set to Nothing and Lightlayers isn't enabled in HDRP Asset ### Changed - Improve MIP selection for decals on Transparents @@ -744,6 +749,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Removed logic in the UI to disable parameters for contact shadows and fog volume components as it was going against the concept of the volume system. - Fixed the sub surface mask not being taken into account when computing ray traced sub surface scattering. - MSAA Within Forward Frame Setting is now enabled by default on Cameras when new Render Pipeline Asset is created +- Slightly changed the TAA anti-flicker mechanism so that it is more aggressive on almost static images (only on High preset for now). +- Changed default exposure compensation to 0. +- Refactored shadow caching system. ## [7.1.1] - 2019-09-05 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md b/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md index d9ccbca8c3c..b80751f1047 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Shadows-in-HDRP.md @@ -101,7 +101,50 @@ You can use **Update Mode** to specify the calculation method HDRP uses to updat | **On Enable** | HDRP updates the shadow maps for the light whenever you enable the GameObject. | | **On Demand** | HDRP updates the shadow maps for the light every time you request them. To do this, call the RequestShadowMapRendering() method in the Light's HDAdditionalLightData component. | -**Note:** no matter what Update Mode a Light uses, if Unity resizes the content of the shadow atlas (due to shadow maps not fitting on the atlas at their original resolution), Unity also updates the shadow map to perform the required rescaling. +The High Definition Render Pipeline (HDRP) uses shadow caching to increase performance by not unnecessarily updating the shadow maps for [Lights](Light-Component.md). HDRP has shadow atlases for punctual, area, and directional Lights, as well as separate shadow atlases specifically for cached punctual and cached area Lights. For cached directional Lights, they use the same atlas as normal directional Lights. +A Light's **Update Mode** determines whether or not HDRP caches its shadow map:If you set a Light's **Update Mode** to **OnEnable** or **OnDemand**, HDRP caches the Light's shadow map.If you set a Light's **Update Mode** to **Every Frame**, HDRP does not cache the Light's shadow map. +When a Light that caches its shadows renders its shadow map for the first time, HDRP registers it with the cached shadow manager which assigns the shadow map to a cached shadow atlas. In the case of directional Lights, HDRP uses the same shadow atlas for cached and non-cached directional Lights. + +If the Light's **Update Mode** is set to **OnDemand**, you can manually request HDRP to update the Light's shadow map. To do this, access the Light's **HDAdditionalLightData** component and call the `RequestShadowMapRendering` function. Also, if the Light has multiple shadows (e.g. multiple cascades of a directional light), you can request the update of a specific sub-shadow. To do this, use the `RequestSubShadowMapRendering(shadowIndex)` function. +For a Light that does cache its shadows, if you disable it or set its **Update Mode** to **Every Frame**, you can tell HDRP to preserve the Light's shadow map's place in the cached shadow atlas. This means that, if you enable the Light again, HDRP does not need to re-render the shadow map or place it into a shadow atlas. For information on how to make a Light preserve its shadow map's place in the cached shadow atlas, see [Preserving shadow atlas placement](#preserving-shadow-atlas-placement). + +### Customising shadow caching +HDRP caches shadow maps for punctual Lights into one atlas, area Lights into another, and directional Lights into the same atlas as non-cached Directional Lights. You can change the resolution of the first two cached shadow atlases independently of one another. To do this: + +1. Select an HDRP Asset to view it in the Inspector. +2. For punctual lights, go to **Lighting > Shadows > Punctual Light Shadows**. For area lights, go to **Lighting > Shadows > Area Light Shadows**. +3. Set the value for **Cached Shadow Atlas Resolution** to the value you want. To help with shadow atlas organisation, try to keep the resolution of individual shadow maps as a multiple of 64. For the most optimal organisation, set the same resolution to as many shadow maps as possible. + +If the shadow atlas is full when a Light requests a spot, the cached shadow manager does not add the Light's shadow map and thus the Light does not cast shadows. This means that it is important to manage the space you have available. To check if a Light can fit in the shadow atlas, you can use the `HDCachedShadowManager.instance.WouldFitInAtlas` helper function. To see if a Light already has a place in the atlas or if it is waiting for one, the [Render Pipeline Debug window](Render-Pipeline-Debug-Window.md) includes an option which logs the status of the cached shadow atlas. To use this: + +1. Click menu: **Window > Render Pipeline > Render Pipeline Debug**. +2. Go to **Lighting > Shadows**. +3. Click the **Log Cached Shadow Atlas Status** button. This prints a message to the Console window which describes whether a Light has a place in the atlas or is waiting for one. + + + +After a Scene loads with all the already placed Lights, if you add a new Light with cached shadows to the Scene, HDRP tries to place it in order to fill the holes in the atlas. However, depending on the order of insertion, the atlas may be fragmented and the holes available are not enough to place the Light's shadow map in. In this case, you can defragment the atlas to allow for additional Lights. To do this, pass the target atlas into the following function: `HDCachedShadowManager.instance.DefragAtlas` +Note that this causes HDRP to mark all the shadow maps in the atlas as dirty which means HDRP renders them the moment their parent Light becomes visible. + +### Preserving shadow atlas placement + +If you disable the Light or change its **Update Mode** to **Every Frame**, the cached shadow manager unreserves the Light's shadow map's space in the cached shadow atlas and HDRP begins to render the Light's shadow map to the normal shadow atlases every frame. If the cached shadow manager needs to allocate space on the atlas for another Light, it can overwrite the space currently taken up by the original Light's shadow map. +If you plan to only temporarily set a Light's **Update Mode** to **Every Frame** and want to set it back to **On Enable** or **On Demand** later, you can preserve the Light's shadow map placement in its atlas. This is useful, for example, if you want HDRP to cache a far away Light's shadow map, but update it every frame when it gets close to the [Camera](HDRP-Camera.md). To do this, access the Light's **HDAdditionalLightData** component and enable the **preserveCachedShadow** property. If this property is set to `true`, HDRP preserves the Light's shadow map's space in its shadow atlas. Note that even if this property is enabled, if you destroy the Light, it loses its placement in the shadow atlas. + +### Notes + +While you are in the Unity Editor, HDRP updates shadow maps whenever you modify the Light that casts them. In a built application, HDRP refreshes cached shadow maps when you change different properties on the Light or when you call one of the following functions: + +- SetShadowResolution() +- SetShadowResolutionLevel() +- SetShadowResolutionOverride() +- SetShadowUpdateMode() or shadowUpdateMode. In this case, HDRP only refreshes the cached shadow maps if the mode changes between Every Frame and not Every Frame). + + +Be aware that anything that is view-dependent is likely to create problems with cached shadow maps because HDRP does not automatically update them as the main view moves. A non-obvious example of this is tessellation. Because tessellation factor is view-dependent, the geometry that the main camera sees might mismatch the geometry that HDRP rendered into the cached shadow map. If this visibly occurs, trigger a request for HDRP to update the Light's shadow map. To do this, make sure the Light's **Update Mode** is set to **On Demand** and call `RequestShadowMapRendering`. + + + ## Contact Shadows diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md index 6cd48c9c77a..aaf04d2c617 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2019.3-to-2020.1.md @@ -8,4 +8,8 @@ From Unity 2020.1, the HDRP-specific settings of the scene view camera (anti-ali ## Cookie baking -From Unity 2020.1, Cookie on light are not taken into account for the lightmaps / Lightprobes. This support is always enable with HDRP. \ No newline at end of file +From Unity 2020.1, Cookie on light are not taken into account for the lightmaps / Lightprobes. This support is always enable with HDRP. + +## Default Volume Profile + +From Unity 2020.1, the Default Volume Profile asset has changed so that the Exposure component sets the default Compensation to 0. \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md index 1c53f78fed6..191aa4edc17 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md @@ -6,3 +6,6 @@ In the High Definition Render Pipeline (HDRP), some features work differently be From Unity 2020.2, it is not necessary to change the [HDRP Config package](HDRP-Config-Package.html) in order to set the [Shadows filtering quality](HDRP-Asset.html#FilteringQualities) for Deferred rendering. Instead the filtering quality can be simply set on the [HDRP Asset](HDRP-Asset.html#FilteringQualities) similarly to what was previously setting only the quality for Forward. Note that if previously the Shadow filtering quality wasn't setup on medium on the HDRP Asset you will experience a change of shadow quality as now it will be taken into account. +Starting from 2020.2, HDRP now stores OnEnable and OnDemand shadows in a separate atlas and more API is available to handle them. For more information, see [Shadows in HDRP](Shadows-in-HDRP.md). + +From Unity 2020.2, the shader function `SampleShadow_PCSS` now requires you to pass in an additional float2 parameter which contains the shadow atlas resolution in x and the inverse of the atlas resolution in y. \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Configuration.cs b/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Configuration.cs index 9c3d3962740..81526d8115c 100644 --- a/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Configuration.cs +++ b/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Configuration.cs @@ -460,7 +460,9 @@ bool IsDefaultVolumeProfileAssigned() return false; var hdAsset = HDRenderPipeline.currentAsset; - return hdAsset.defaultVolumeProfile != null && !hdAsset.defaultVolumeProfile.Equals(null); + return hdAsset.defaultVolumeProfile != null + && !hdAsset.defaultVolumeProfile.Equals(null) + && hdAsset.defaultVolumeProfile != hdAsset.renderPipelineEditorResources.defaultSettingsVolumeProfile; } void FixDefaultVolumeProfileAssigned(bool fromAsyncUnused) { @@ -471,7 +473,19 @@ void FixDefaultVolumeProfileAssigned(bool fromAsyncUnused) if (hdrpAsset == null) return; - EditorDefaultSettings.GetOrAssignDefaultVolumeProfile(hdrpAsset); + VolumeProfile defaultSettingsVolumeProfileInPackage = hdrpAsset.renderPipelineEditorResources.defaultSettingsVolumeProfile; + string defaultSettingsVolumeProfilePath = "Assets/" + HDProjectSettings.projectSettingsFolderPath + '/' + defaultSettingsVolumeProfileInPackage.name + ".asset"; + + //try load one if one already exist + VolumeProfile defaultSettingsVolumeProfile = AssetDatabase.LoadAssetAtPath(defaultSettingsVolumeProfilePath); + if (defaultSettingsVolumeProfile == null || defaultSettingsVolumeProfile.Equals(null)) + { + //else create it + AssetDatabase.CopyAsset(AssetDatabase.GetAssetPath(defaultSettingsVolumeProfileInPackage), defaultSettingsVolumeProfilePath); + defaultSettingsVolumeProfile = AssetDatabase.LoadAssetAtPath(defaultSettingsVolumeProfilePath); + } + hdrpAsset.defaultVolumeProfile = defaultSettingsVolumeProfile; + EditorUtility.SetDirty(hdrpAsset); } diff --git a/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs b/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs index 614da9582a7..e1f451f0171 100644 --- a/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs +++ b/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs @@ -108,7 +108,7 @@ public ConfigStyle(string label, string error, string button = resolve, MessageT error: "Default scene prefab must be set to create HD templated scene!"); public static readonly ConfigStyle hdrpVolumeProfile = new ConfigStyle( label: "Default volume profile", - error: "Default volume profile must be assigned in the HDRP asset!"); + error: "Default volume profile must be assigned in the HDRP asset! Also, for it to be editable, it should be outside of package."); public static readonly ConfigStyle vrLegacyVRSystem = new ConfigStyle( label: "Legacy VR System", diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs index fe6def1919f..528c612f80b 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightUI.cs @@ -756,11 +756,7 @@ static void ShowCookieTextureWarnings(Texture cookie, bool useBaking) } } - #if UNITY_2020_2_OR_NEWER if (useBaking && !UnityEditor.EditorSettings.enableCookiesInLightmapper) - #else - if (useBaking && UnityEditor.EditorSettings.disableCookiesInLightmapper) - #endif EditorGUILayout.HelpBox(s_Styles.cookieBaking, MessageType.Warning); if (cookie.width != cookie.height) EditorGUILayout.HelpBox(s_Styles.cookieNonPOT, MessageType.Warning); diff --git a/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ExposureEditor.cs b/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ExposureEditor.cs index a08652ed5d8..35c7c585bbe 100644 --- a/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ExposureEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/PostProcessing/ExposureEditor.cs @@ -1,4 +1,5 @@ using UnityEditor.Rendering; +using UnityEngine; using UnityEngine.Rendering.HighDefinition; namespace UnityEditor.Rendering.HighDefinition @@ -22,6 +23,9 @@ sealed class ExposureEditor : VolumeComponentEditor SerializedDataParameter m_WeightTextureMask; + SerializedDataParameter m_HistogramPercentages; + SerializedDataParameter m_HistogramCurveRemapping; + public override void OnEnable() { var o = new PropertyFetcher(serializedObject); @@ -41,6 +45,10 @@ public override void OnEnable() m_AdaptationSpeedLightToDark = Unpack(o.Find(x => x.adaptationSpeedLightToDark)); m_WeightTextureMask = Unpack(o.Find(x => x.weightTextureMask)); + + m_HistogramPercentages = Unpack(o.Find(x => x.histogramPercentages)); + m_HistogramCurveRemapping = Unpack(o.Find(x => x.histogramUseCurveRemapping)); + } public override void OnInspectorGUI() @@ -65,10 +73,11 @@ public override void OnInspectorGUI() if(m_MeteringMode.value.intValue == (int)MeteringMode.MaskWeighted) PropertyField(m_WeightTextureMask); - PropertyField(m_LuminanceSource); + // Temporary hiding the field since we don't support anything but color buffer for now. + //PropertyField(m_LuminanceSource); - if (m_LuminanceSource.value.intValue == (int)LuminanceSource.LightingBuffer) - EditorGUILayout.HelpBox("Luminance source buffer isn't supported yet.", MessageType.Warning); + //if (m_LuminanceSource.value.intValue == (int)LuminanceSource.LightingBuffer) + // EditorGUILayout.HelpBox("Luminance source buffer isn't supported yet.", MessageType.Warning); if (mode == (int)ExposureMode.CurveMapping) PropertyField(m_CurveMap); @@ -76,7 +85,19 @@ public override void OnInspectorGUI() PropertyField(m_Compensation); PropertyField(m_LimitMin); PropertyField(m_LimitMax); - + + if(mode == (int)ExposureMode.AutomaticHistogram) + { + EditorGUILayout.Space(); + EditorGUILayout.LabelField("Histogram", EditorStyles.miniLabel); + PropertyField(m_HistogramPercentages); + PropertyField(m_HistogramCurveRemapping, EditorGUIUtility.TrTextContent("Use Curve Remapping")); + if (m_HistogramCurveRemapping.value.boolValue) + { + PropertyField(m_CurveMap); + } + } + EditorGUILayout.Space(); EditorGUILayout.LabelField("Adaptation", EditorStyles.miniLabel); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs index 031d4d40558..bf7f0ccc463 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.Skin.cs @@ -160,6 +160,7 @@ public class GeneralSection public static readonly GUIContent maxDecalContent = EditorGUIUtility.TrTextContent("Maximum Clustered Decals on Screen", "Sets the maximum number of decals that can affect transparent GameObjects on screen."); public static readonly GUIContent resolutionContent = EditorGUIUtility.TrTextContent("Resolution", "Specifies the resolution of the shadow Atlas."); + public static readonly GUIContent cachedShadowAtlasResolution = EditorGUIUtility.TrTextContent("Cached Shadow Atlas Resolution", "Specifies the resolution of the shadow Atlas that contains the cached shadow maps."); public static readonly GUIContent directionalShadowPrecisionContent = EditorGUIUtility.TrTextContent("Directional Shadow Precision", "Select the shadow map bit depth, this forces HDRP to use selected bit depth for shadow maps."); public static readonly GUIContent precisionContent = EditorGUIUtility.TrTextContent("Precision", "Select the shadow map bit depth, this forces HDRP to use selected bit depth for shadow maps."); public static readonly GUIContent dynamicRescaleContent = EditorGUIUtility.TrTextContent("Dynamic Rescale", "When enabled, scales the shadow map size using the screen size of the Light to leave more space for other shadows in the atlas."); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs index 1a35e081067..e7862542a9d 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/HDRenderPipelineUI.cs @@ -383,6 +383,15 @@ static void Drawer_SectionShadows(SerializedHDRenderPipelineAsset serialized, Ed serialized.renderPipelineSettings.hdShadowInitParams.shadowResolutionPunctual.ValueGUI(Styles.punctualLightsShadowTiers); EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.hdShadowInitParams.maxPunctualShadowMapResolution, Styles.maxShadowResolution); --EditorGUI.indentLevel; + + ++EditorGUI.indentLevel; + // Because we don't know if the asset is old and had the cached shadow map resolution field, if it was set as default float (0) we force a default. + if (serialized.renderPipelineSettings.hdShadowInitParams.cachedPunctualShadowAtlasResolution.intValue == 0) + { + serialized.renderPipelineSettings.hdShadowInitParams.cachedPunctualShadowAtlasResolution.intValue = 2048; + } + CoreEditorUtils.DrawEnumPopup(serialized.renderPipelineSettings.hdShadowInitParams.cachedPunctualShadowAtlasResolution, typeof(ShadowResolutionValue), Styles.cachedShadowAtlasResolution); + --EditorGUI.indentLevel; } m_ShowAreaLightSection = EditorGUILayout.Foldout(m_ShowAreaLightSection, Styles.areaShadowsSubTitle, true); @@ -405,6 +414,15 @@ static void Drawer_SectionShadows(SerializedHDRenderPipelineAsset serialized, Ed serialized.renderPipelineSettings.hdShadowInitParams.shadowResolutionArea.ValueGUI(Styles.areaLightsShadowTiers); EditorGUILayout.DelayedIntField(serialized.renderPipelineSettings.hdShadowInitParams.maxAreaShadowMapResolution, Styles.maxShadowResolution); --EditorGUI.indentLevel; + + ++EditorGUI.indentLevel; + if (serialized.renderPipelineSettings.hdShadowInitParams.cachedAreaShadowAtlasResolution.intValue == 0) + { + serialized.renderPipelineSettings.hdShadowInitParams.cachedAreaShadowAtlasResolution.intValue = 1024; + } + CoreEditorUtils.DrawEnumPopup(serialized.renderPipelineSettings.hdShadowInitParams.cachedAreaShadowAtlasResolution, typeof(ShadowResolutionValue), Styles.cachedShadowAtlasResolution); + --EditorGUI.indentLevel; + } } diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDShadowInitParameters.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDShadowInitParameters.cs index 1e14c79ab8b..64847791ef9 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDShadowInitParameters.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedHDShadowInitParameters.cs @@ -36,6 +36,9 @@ class SerializedHDShadowInitParameters public SerializedProperty maxScreenSpaceShadowSlots; public SerializedProperty screenSpaceShadowBufferFormat; + public SerializedProperty cachedPunctualShadowAtlasResolution; + public SerializedProperty cachedAreaShadowAtlasResolution; + public SerializedHDShadowInitParameters(SerializedProperty root) { this.root = root; @@ -57,6 +60,9 @@ public SerializedHDShadowInitParameters(SerializedProperty root) maxPunctualShadowMapResolution = root.Find((HDShadowInitParameters s) => s.maxPunctualShadowMapResolution); maxAreaShadowMapResolution = root.Find((HDShadowInitParameters s) => s.maxAreaShadowMapResolution); + cachedPunctualShadowAtlasResolution = root.Find((HDShadowInitParameters s) => s.cachedPunctualLightShadowAtlas); + cachedAreaShadowAtlasResolution = root.Find((HDShadowInitParameters s) => s.cachedAreaLightShadowAtlas); + shadowFilteringQuality = root.Find((HDShadowInitParameters s) => s.shadowFilteringQuality); supportScreenSpaceShadows = root.Find((HDShadowInitParameters s) => s.supportScreenSpaceShadows); maxScreenSpaceShadowSlots = root.Find((HDShadowInitParameters s) => s.maxScreenSpaceShadowSlots); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipelineResources/DefaultSettingsVolumeProfile.asset b/com.unity.render-pipelines.high-definition/Editor/RenderPipelineResources/DefaultSettingsVolumeProfile.asset index a5fe482a2e2..e72cfee66ed 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipelineResources/DefaultSettingsVolumeProfile.asset +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipelineResources/DefaultSettingsVolumeProfile.asset @@ -87,10 +87,18 @@ MonoBehaviour: m_OverrideState: 0 m_Value: 50 min: 0 + minDistance: + m_OverrideState: 0 + m_Value: 0 + min: 0 fadeDistance: m_OverrideState: 0 m_Value: 5 min: 0 + fadeInDistance: + m_OverrideState: 0 + m_Value: 0 + min: 0 m_SampleCount: m_OverrideState: 1 m_Value: 12 @@ -322,8 +330,8 @@ MonoBehaviour: m_OverrideState: 0 m_Value: 0 compensation: - m_OverrideState: 1 - m_Value: 1 + m_OverrideState: 0 + m_Value: 0 limitMin: m_OverrideState: 0 m_Value: -10 @@ -367,6 +375,9 @@ MonoBehaviour: m_OverrideState: 0 m_Value: 1 min: 0.001 + weightTextureMask: + m_OverrideState: 0 + m_Value: {fileID: 0} --- !u!114 &7502528774814404555 MonoBehaviour: m_ObjectHideFlags: 3 diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs index 2c960245d8e..629e439c2eb 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.cs @@ -218,6 +218,7 @@ public class DebugData internal int renderingFulscreenDebugModeEnumIndex; internal int terrainTextureEnumIndex; internal int colorPickerDebugModeEnumIndex; + internal int exposureDebugModeEnumIndex; internal int msaaSampleDebugModeEnumIndex; internal int debugCameraToFreezeEnumIndex; internal int volumeComponentEnumIndex; @@ -407,7 +408,7 @@ public bool IsDebugDisplayEnabled() /// True if any material debug display is enabled. public bool IsDebugMaterialDisplayEnabled() { - return data.materialDebugSettings.IsDebugDisplayEnabled(); + return data.materialDebugSettings.IsDebugDisplayEnabled(); } /// @@ -419,6 +420,15 @@ public bool IsDebugFullScreenEnabled() return data.fullScreenDebugMode != FullScreenDebugMode.None; } + /// + /// Returns true if any full screen exposure debug display is enabled. + /// + /// True if any full screen exposure debug display is enabled. + public bool IsDebugExposureModeEnabled() + { + return data.lightingDebugSettings.exposureDebugMode != ExposureDebugMode.None; + } + /// /// Returns true if material validation is enabled. /// @@ -626,6 +636,15 @@ internal void SetProbeVolumeAtlasSliceMode(ProbeVolumeAtlasSliceMode value) data.lightingDebugSettings.probeVolumeAtlasSliceMode = value; } + /// + /// Set the current Exposure Debug Mode. + /// + /// Desired Probe Volume Debug Mode. + internal void SetExposureDebugMode(ExposureDebugMode value) + { + data.lightingDebugSettings.exposureDebugMode = value; + } + /// /// Set the current Mip Map Debug Mode. /// @@ -843,7 +862,9 @@ void RegisterLightingDebug() shadows.children.Add(new DebugUI.FloatField { displayName = "Range Minimum Value", getter = () => data.lightingDebugSettings.shadowMinValue, setter = value => data.lightingDebugSettings.shadowMinValue = value }); shadows.children.Add(new DebugUI.FloatField { displayName = "Range Maximum Value", getter = () => data.lightingDebugSettings.shadowMaxValue, setter = value => data.lightingDebugSettings.shadowMaxValue = value }); - +#if UNITY_EDITOR + shadows.children.Add(new DebugUI.Button { displayName = "Log Cached Shadow Atlas Status", action = () => HDCachedShadowManager.instance.PrintLightStatusInCachedAtlas() }); +#endif list.Add(shadows); } @@ -872,6 +893,44 @@ void RegisterLightingDebug() } }); + var exposureFoldout = new DebugUI.Foldout + { + displayName = "Exposure ", + children = + { + new DebugUI.EnumField + { + displayName = "Debug Mode", + getter = () => (int) data.lightingDebugSettings.exposureDebugMode, + setter = value => SetExposureDebugMode((ExposureDebugMode) value), + autoEnum = typeof(ExposureDebugMode), onValueChanged = RefreshLightingDebug, + getIndex = () => data.exposureDebugModeEnumIndex, + setIndex = value => data.exposureDebugModeEnumIndex = value + } + } + }; + + if (data.lightingDebugSettings.exposureDebugMode == ExposureDebugMode.HistogramView) + { + exposureFoldout.children.Add( + new DebugUI.BoolField() + { + displayName = "Show Tonemap curve", + getter = () => data.lightingDebugSettings.showTonemapCurveAlongHistogramView, + setter = value => data.lightingDebugSettings.showTonemapCurveAlongHistogramView = value + }); + } + + exposureFoldout.children.Add( + new DebugUI.FloatField + { + displayName = "Debug Exposure Compensation", + getter = () => data.lightingDebugSettings.debugExposure, + setter = value => data.lightingDebugSettings.debugExposure = value + }); + + lighting.children.Add(exposureFoldout); + lighting.children.Add(new DebugUI.EnumField { displayName = "Debug Mode", getter = () => (int)data.lightingDebugSettings.debugLightingMode, setter = value => SetDebugLightingMode((DebugLightingMode)value), autoEnum = typeof(DebugLightingMode), onValueChanged = RefreshLightingDebug, getIndex = () => data.lightingDebugModeEnumIndex, setIndex = value => { data.ResetExclusiveEnumIndices(); data.lightingDebugModeEnumIndex = value; } }); lighting.children.Add(new DebugUI.BitField { displayName = "Hierarchy Debug Mode", getter = () => data.lightingDebugSettings.debugLightFilterMode, setter = value => SetDebugLightFilterMode((DebugLightFilterMode)value), enumType = typeof(DebugLightFilterMode), onValueChanged = RefreshLightingDebug, }); @@ -1125,8 +1184,6 @@ void RegisterLightingDebug() list.Add(new DebugUI.FloatField { displayName = "Debug Overlay Screen Ratio", getter = () => data.debugOverlayRatio, setter = v => data.debugOverlayRatio = v, min = () => 0.1f, max = () => 1f}); - list.Add(new DebugUI.FloatField { displayName = "Debug Exposure Compensation", getter = () => data.lightingDebugSettings.debugExposure, setter = value => data.lightingDebugSettings.debugExposure = value }); - m_DebugLightingItems = list.ToArray(); var panel = DebugManager.instance.GetPanel(k_PanelLighting, true); panel.children.Add(m_DebugLightingItems); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl index 9b5f009aa19..1ed2109002a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl @@ -180,6 +180,7 @@ void DrawInteger(int intValue, float3 fontColor, uint2 currentUnormCoord, inout fixedUnormCoord.x += numEntries * DEBUG_FONT_TEXT_SCALE_WIDTH; // 3. Display the number + [unroll] // Needed to supress warning as some odd code gen is happening here. Is bad for perf, but it is a debug display. for (uint j = 0; j < maxStringSize; ++j) { // Numeric value incurrent font start on the second row at 0 @@ -213,7 +214,7 @@ void DrawInteger(int intValue, float3 fontColor, uint2 currentUnormCoord, inout DrawInteger(intValue, fontColor, currentUnormCoord, fixedUnormCoord, color, 0, false); } -void DrawFloat(float floatValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color) +void DrawFloatExplicitPrecision(float floatValue, float3 fontColor, uint2 currentUnormCoord, uint digitCount, inout uint2 fixedUnormCoord, inout float3 color) { if (IsNaN(floatValue)) { @@ -227,12 +228,17 @@ void DrawFloat(float floatValue, float3 fontColor, uint2 currentUnormCoord, inou bool forceNegativeSign = floatValue >= 0.0f ? false : true; DrawInteger(intValue, fontColor, currentUnormCoord, fixedUnormCoord, color, 0, forceNegativeSign); DrawCharacter('.', fontColor, currentUnormCoord, fixedUnormCoord, color); - int fracValue = int(frac(abs(floatValue)) * 1e6); // 6 digit - int leading0 = 6 - (int(log10(fracValue)) + 1); // Counting leading0 to add in front of the float + int fracValue = int(frac(abs(floatValue)) * pow(10, digitCount)); + int leading0 = digitCount - (int(log10(fracValue)) + 1); // Counting leading0 to add in front of the float DrawInteger(fracValue, fontColor, currentUnormCoord, fixedUnormCoord, color, leading0, false); } } +void DrawFloat(float floatValue, float3 fontColor, uint2 currentUnormCoord, inout uint2 fixedUnormCoord, inout float3 color) +{ + DrawFloatExplicitPrecision(floatValue, fontColor, currentUnormCoord, 6, fixedUnormCoord, color); +} + // Debug rendering is performed at the end of the frame (after post-processing). // Debug textures are never flipped upside-down automatically. Therefore, we must always flip manually. bool ShouldFlipDebugTexture() diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugExposure.shader b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugExposure.shader new file mode 100644 index 00000000000..bdd95e18d60 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugExposure.shader @@ -0,0 +1,552 @@ +Shader "Hidden/HDRP/DebugExposure" +{ + HLSLINCLUDE + + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ExposureCommon.hlsl" + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposureCommon.hlsl" + #define DEBUG_DISPLAY + #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl" + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/ACES.hlsl" + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" + + #pragma vertex Vert + #pragma target 4.5 + #pragma only_renderers d3d11 playstation xboxone vulkan metal switch + + #define PERCENTILE_AS_BARS 0 + + // Contains the scene color post-processed (tonemapped etc.) + TEXTURE2D_X(_DebugFullScreenTexture); + + // Tonemap related + TEXTURE3D(_LogLut3D); + SAMPLER(sampler_LogLut3D); + + float4 _ExposureDebugParams; + float4 _LogLut3D_Params; // x: 1 / lut_size, y: lut_size - 1, z: contribution, w: unused + // Custom tonemapping settings + float4 _CustomToneCurve; + float4 _ToeSegmentA; + float4 _ToeSegmentB; + float4 _MidSegmentA; + float4 _MidSegmentB; + float4 _ShoSegmentA; + float4 _ShoSegmentB; + + #define _DrawTonemapCurve _ExposureDebugParams.x + #define _TonemapType _ExposureDebugParams.y + + + struct Attributes + { + uint vertexID : SV_VertexID; + }; + + struct Varyings + { + float4 positionCS : SV_POSITION; + float2 texcoord : TEXCOORD0; + }; + + Varyings Vert(Attributes input) + { + Varyings output; + output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID); + output.texcoord = GetNormalizedFullScreenTriangleTexCoord(input.vertexID); + + return output; + } + + float3 Tonemap(float3 colorLinear) + { + if(_TonemapType == TONEMAPPINGMODE_NEUTRAL) + { + colorLinear = NeutralTonemap(colorLinear); + } + if (_TonemapType == TONEMAPPINGMODE_ACES) + { + // Note: input is actually ACEScg (AP1 w/ linear encoding) + float3 aces = ACEScg_to_ACES(colorLinear); + colorLinear = AcesTonemap(aces); + } + if (_TonemapType == TONEMAPPINGMODE_CUSTOM) // Custom + { + colorLinear = CustomTonemap(colorLinear, _CustomToneCurve.xyz, _ToeSegmentA, _ToeSegmentB.xy, _MidSegmentA, _MidSegmentB.xy, _ShoSegmentA, _ShoSegmentB.xy); + } + if (_TonemapType == TONEMAPPINGMODE_EXTERNAL) // External + { + float3 colorLutSpace = saturate(LinearToLogC(colorLinear)); + float3 colorLut = ApplyLut3D(TEXTURE3D_ARGS(_LogLut3D, sampler_LogLut3D), colorLutSpace, _LogLut3D_Params.xy); + colorLinear = lerp(colorLinear, colorLut, _LogLut3D_Params.z); + } + + return colorLinear; + } + + float3 ToHeat(float value) + { + float3 r = value * 2.1f - float3(1.8f, 1.14f, 0.3f); + return 1.0f - r * r; + } + + float GetEVAtLocation(float2 uv) + { + return ComputeEV100FromAvgLuminance(max(SampleLuminance(uv), 1e-4)); + } + + // Returns true if it drew the location of the indicator. + void DrawHeatSideBar(float2 uv, float2 startSidebar, float2 endSidebar, float evValueRange, float3 indicatorColor, float2 sidebarSize, float extremeMargin, inout float3 sidebarColor) + { + float2 extremesSize = float2(extremeMargin, 0); + float2 borderSize = 2 * _ScreenSize.zw * _RTHandleScale.xy; + int indicatorHalfSize = 5; + + + if (all(uv > startSidebar) && all(uv < endSidebar)) + { + float inRange = (uv.x - startSidebar.x) / (endSidebar.x - startSidebar.x); + evValueRange = clamp(evValueRange, 0.0f, 1.0f); + int distanceInPixels = abs(evValueRange - inRange) * sidebarSize.x * _ScreenSize.x; + if (distanceInPixels < indicatorHalfSize) + { + sidebarColor = indicatorColor; + } + else if (distanceInPixels < indicatorHalfSize + 1) + { + sidebarColor = 0.0f; + } + else + { + sidebarColor = ToHeat(inRange); + } + } + else if (all(uv > startSidebar - extremesSize) && all(uv < endSidebar)) + { + sidebarColor = float3(0,0,0); + } + else if (all(uv > startSidebar) && all(uv < endSidebar + extremesSize)) + { + sidebarColor = float3(1, 1, 1); + } + else if(all(uv > startSidebar - (extremesSize + borderSize)) && all(uv < endSidebar + (extremesSize + borderSize))) + { + sidebarColor = 0.0f; + } + } + + float GetHistogramValue(float coord, out bool isEdge) + { + float barSize = _ScreenSize.x / HISTOGRAM_BINS; + float bin = coord / barSize; + + float locWithinBin = barSize * frac(bin); + + isEdge = locWithinBin < 1 || locWithinBin > (barSize - 1); + return UnpackWeight(_HistogramBuffer[(uint)(bin)]); + } + + float ComputePercentile(float2 uv, float histSum, out float minPercentileBin, out float maxPercentileBin) + { + float sumBelowValue = 0.0f; + float sumForMin = 0.0f; + float sumForMax = 0.0f; + + minPercentileBin = -1; + maxPercentileBin = -1; + + float ev = GetEVAtLocation(uv); + + for (int i = 0; i < HISTOGRAM_BINS; ++i) + { + float evAtBin = BinLocationToEV(i); + float evAtNextBin = BinLocationToEV(i+1); + + float histVal = UnpackWeight(_HistogramBuffer[i]); + + if (ev >= evAtBin) + { + sumBelowValue += histVal; + } + + //TODO: This could be more precise, now it locks to bin location + if (minPercentileBin < 0) + { + sumForMin += histVal; + if (sumForMin / histSum >= _HistogramMinPercentile) + { + + minPercentileBin = i; + } + } + + if (maxPercentileBin < 0) + { + sumForMax += histVal; + if (sumForMax / histSum > _HistogramMaxPercentile) + { + maxPercentileBin = i; + } + } + } + + return sumBelowValue / histSum; + } + + void DrawHistogramIndicatorBar(float coord, float uvXLocation, float widthNDC, float3 color, inout float3 outColor) + { + float halfWidthInScreen = widthNDC * _ScreenSize.x; + float minScreenPos = (uvXLocation - widthNDC * 0.5) * _ScreenSize.x; + float maxScreenPos = (uvXLocation + widthNDC * 0.5) * _ScreenSize.x; + + if (coord > minScreenPos && coord < maxScreenPos) + { + outColor = color; + } + } + + void DrawTriangleIndicator(float2 coord, float labelBarHeight, float uvXLocation, float widthNDC, float3 color, inout float3 outColor) + { + float halfWidthInScreen = widthNDC * _ScreenSize.x; + float arrowStart = labelBarHeight * 0.4f; + + float heightInIndicator = ((coord.y - arrowStart) / (labelBarHeight - arrowStart)); + float indicatorWidth = 1.0f - heightInIndicator; + + float minScreenPos = (uvXLocation - widthNDC * indicatorWidth * 0.5) * _ScreenSize.x; + float maxScreenPos = (uvXLocation + widthNDC * indicatorWidth * 0.5) * _ScreenSize.x; + + uint triangleBorder = 2; + if (coord.x > minScreenPos && coord.x < maxScreenPos && coord.y >= arrowStart) + { + outColor = color; + } + else if (coord.x > minScreenPos - triangleBorder && coord.x < maxScreenPos + triangleBorder && coord.y > arrowStart - triangleBorder) + { + outColor = 0; + } + } + + void DrawHistogramFrame(float2 uv, uint2 unormCoord, float frameHeight, float3 backgroundColor, float alpha, float maxHist, float minPercentLoc, float maxPercentLoc, inout float3 outColor) + { + float2 borderSize = 2 * _ScreenSize.zw * _RTHandleScale.xy; + float heightLabelBar = (DEBUG_FONT_TEXT_WIDTH * 1.25) * _ScreenSize.w * _RTHandleScale.y; + + if (uv.y > frameHeight) return; + + // ---- Draw General frame ---- + if (uv.x < borderSize.x || uv.x >(1.0f - borderSize.x)) + { + outColor = 0.0; + return; + } + else if (uv.y > frameHeight - borderSize.y || uv.y < borderSize.y) + { + outColor = 0.0; + return; + } + else + { + outColor = lerp(outColor, backgroundColor, alpha); + } + + // ---- Draw label bar ----- + if (uv.y < heightLabelBar) + { + outColor = outColor * 0.075f; + } + + // ---- Draw Buckets frame ---- + + bool isEdgeOfBin = false; + float val = GetHistogramValue(unormCoord.x, isEdgeOfBin); + val /= maxHist; + + val *= 0.95*(frameHeight - heightLabelBar); + val += heightLabelBar; + + if (uv.y < val && uv.y > heightLabelBar) + { + isEdgeOfBin = isEdgeOfBin || (uv.y > val - _ScreenSize.w); +#if PERCENTILE_AS_BARS == 0 + uint bin = uint((unormCoord.x * (HISTOGRAM_BINS)) / (_ScreenSize.x)); + if (bin <= uint(minPercentLoc) && minPercentLoc > 0) + { + outColor.rgb = float3(0, 0, 1); + } + else if(bin >= uint(maxPercentLoc) && maxPercentLoc > 0) + { + outColor.rgb = float3(1, 0, 0); + } + else +#endif + outColor.rgb = float3(1.0f, 1.0f, 1.0f); + if (isEdgeOfBin) outColor.rgb = 0; + } + + // ---- Draw labels ---- + + // Number of labels + int labelCount = 12; + float oneOverLabelCount = rcp(labelCount); + float labelDeltaScreenSpace = _ScreenSize.x * oneOverLabelCount; + + int minLabelLocationX = DEBUG_FONT_TEXT_WIDTH * 0.25; + int maxLabelLocationX = _ScreenSize.x - (DEBUG_FONT_TEXT_WIDTH * 3); + + int labelLocationY = 0.0f; + + [unroll] + for (int i = 0; i <= labelCount; ++i) + { + float t = oneOverLabelCount * i; + float labelValue = lerp(ParamExposureLimitMin, ParamExposureLimitMax, t); + uint2 labelLoc = uint2((uint)lerp(minLabelLocationX, maxLabelLocationX, t), labelLocationY); + DrawFloatExplicitPrecision(labelValue, float3(1.0f, 1.0f, 1.0f), unormCoord, 1, labelLoc, outColor.rgb); + } + + // ---- Draw indicators ---- + float currExposure = _ExposureTexture[int2(0, 0)].y; + float targetExposure = _ExposureDebugTexture[int2(0, 0)].x; + + float evInRange = (currExposure - ParamExposureLimitMin) / (ParamExposureLimitMax - ParamExposureLimitMin); + float targetEVInRange = (targetExposure - ParamExposureLimitMin) / (ParamExposureLimitMax - ParamExposureLimitMin); + + float halfIndicatorSize = 0.007f; + float halfWidthInScreen = halfIndicatorSize * _ScreenSize.x; + + float labelFrameHeightScreen = heightLabelBar * (_ScreenSize.y / _RTHandleScale.y); + + if (uv.y < heightLabelBar) + { + DrawTriangleIndicator(float2(unormCoord.xy), labelFrameHeightScreen, targetEVInRange, halfIndicatorSize, float3(0.9f, 0.75f, 0.1f), outColor); + DrawTriangleIndicator(float2(unormCoord.xy), labelFrameHeightScreen, evInRange, halfIndicatorSize, float3(0.15f, 0.15f, 0.1f), outColor); + + // Find location for percentiles bars. +#if PERCENTILE_AS_BARS + DrawHistogramIndicatorBar(float(unormCoord.x), minPercentLoc, 0.003f, float3(0, 0, 1), outColor); + DrawHistogramIndicatorBar(float(unormCoord.x), maxPercentLoc, 0.003f, float3(1, 0, 0), outColor); +#endif + } + + // ---- Draw Tonemap curve ---- + if (_DrawTonemapCurve) + { + float exposureAtLoc = lerp(ParamExposureLimitMin, ParamExposureLimitMax, uv.x); + const float K = 12.5; // Reflected-light meter calibration constant + float luminanceFromExposure = _ExposureTexture[int2(0, 0)].x * (exp2(exposureAtLoc) * (K / 100.0f)); + + val = saturate(Luminance(Tonemap(luminanceFromExposure))); + val *= 0.95 * (frameHeight - heightLabelBar); + val += heightLabelBar; + + float curveWidth = 4 * _ScreenSize.w; + + if (uv.y < val && uv.y >(val - curveWidth)) + { + outColor = outColor * 0.1 + 0.9 * 0; + } + } + } + + float3 FragMetering(Varyings input) : SV_Target + { + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + float2 uv = input.texcoord.xy; + float3 color = SAMPLE_TEXTURE2D_X_LOD(_DebugFullScreenTexture, s_linear_clamp_sampler, uv, 0.0).xyz; + float weight = WeightSample(input.positionCS.xy, _ScreenSize.xy); + + float pipFraction = 0.33f; + uint borderSize = 3; + float2 topRight = pipFraction * _ScreenSize.xy; + + if (all(input.positionCS.xy < topRight)) + { + float2 scaledUV = uv / pipFraction; + float3 pipColor = SAMPLE_TEXTURE2D_X_LOD(_SourceTexture, s_linear_clamp_sampler, scaledUV, 0.0).xyz; + float weight = WeightSample(scaledUV.xy * _ScreenSize.xy / _RTHandleScale.xy, _ScreenSize.xy); + + return pipColor * weight; + } + else if (all(input.positionCS.xy < (topRight + borderSize))) + { + return float3(0.33f, 0.33f, 0.33f); + } + else + { + return color; + } + } + + float3 FragSceneEV100(Varyings input) : SV_Target + { + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + float2 uv = input.texcoord.xy; + + float3 textColor = 0.0f; + + float2 sidebarSize = float2(0.9, 0.02) * _RTHandleScale.xy; + + float heightLabelBar = (DEBUG_FONT_TEXT_WIDTH * 1.25f) * _ScreenSize.w * _RTHandleScale.y; + + float2 sidebarBottomLeft = float2(0.05 * _RTHandleScale.x, heightLabelBar); + float2 endPointSidebar = sidebarBottomLeft + sidebarSize; + + float3 outputColor = 0; + float ev = GetEVAtLocation(uv); + + float evInRange = (ev - ParamExposureLimitMin) / (ParamExposureLimitMax - ParamExposureLimitMin); + + if (ev < ParamExposureLimitMax && ev > ParamExposureLimitMin) + { + outputColor = ToHeat(evInRange); + } + else if (ev > ParamExposureLimitMax) + { + outputColor = 1.0f; + } + else if (ev < ParamExposureLimitMin) + { + outputColor = 0.0f; + } + + // Get value at indicator + float2 indicatorUV = _MousePixelCoord.zw; + float indicatorEV = GetEVAtLocation(indicatorUV); + float indicatorEVRange = (indicatorEV - ParamExposureLimitMin) / (ParamExposureLimitMax - ParamExposureLimitMin); + + float extremeMargin = 5 * _ScreenSize.z * _RTHandleScale.x; + DrawHeatSideBar(uv, sidebarBottomLeft, endPointSidebar, indicatorEVRange, 0.66f, sidebarSize, extremeMargin, outputColor); + + int2 unormCoord = input.positionCS.xy; + + // Label bar + float2 borderSize = 2 * _ScreenSize.zw * _RTHandleScale.xy; + if (uv.y < heightLabelBar && + uv.x >= (sidebarBottomLeft.x - borderSize.x) && uv.x <= (borderSize.x + endPointSidebar.x)) + { + outputColor = outputColor * 0.075f; + } + + // Number of labels + int labelCount = 8; + float oneOverLabelCount = rcp(labelCount); + float labelDeltaScreenSpace = _ScreenSize.x * oneOverLabelCount; + + int minLabelLocationX = (sidebarBottomLeft.x - borderSize.x) * (_ScreenSize.x / _RTHandleScale.x) + DEBUG_FONT_TEXT_WIDTH * 0.25; + int maxLabelLocationX = (borderSize.x + endPointSidebar.x) * (_ScreenSize.x / _RTHandleScale.x) - (DEBUG_FONT_TEXT_WIDTH * 3); + + int labelLocationY = 0.0f; + + [unroll] + for (int i = 0; i <= labelCount; ++i) + { + float t = oneOverLabelCount * i; + float labelValue = lerp(ParamExposureLimitMin, ParamExposureLimitMax, t); + uint2 labelLoc = uint2((uint)lerp(minLabelLocationX, maxLabelLocationX, t), labelLocationY); + DrawFloatExplicitPrecision(labelValue, float3(1.0f, 1.0f, 1.0f), unormCoord, 1, labelLoc, outputColor.rgb); + } + + int displayTextOffsetX = DEBUG_FONT_TEXT_WIDTH; + int2 textLocation = int2(_MousePixelCoord.x + displayTextOffsetX, _MousePixelCoord.y); + DrawFloatExplicitPrecision(indicatorEV, textColor, unormCoord, 1, textLocation, outputColor.rgb); + textLocation = _MousePixelCoord.xy; + DrawCharacter('X', float3(0.0f, 0.0f, 0.0f), unormCoord, textLocation, outputColor.rgb); + + return outputColor; + } + + + + float3 FragHistogram(Varyings input) : SV_Target + { + UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input); + float2 uv = input.texcoord.xy; + + float3 color = SAMPLE_TEXTURE2D_X_LOD(_DebugFullScreenTexture, s_linear_clamp_sampler, uv, 0.0).xyz; + float weight = WeightSample(input.positionCS.xy, _ScreenSize.xy); + + float3 outputColor = color; + + // Get some overall info from the histogram + float maxValue = 0; + float sum = 0; + for (int i = 0; i < HISTOGRAM_BINS; ++i) + { + float histogramVal = UnpackWeight(_HistogramBuffer[i]); + maxValue = max(histogramVal, maxValue); + sum += histogramVal; + } + + float minPercentileBin = 0; + float maxPercentileBin = 0; + float percentile = ComputePercentile(uv, sum, minPercentileBin, maxPercentileBin); + + if (percentile < _HistogramMinPercentile) + { + outputColor = (input.positionCS.x + input.positionCS.y) % 2 == 0 ? float3(0.0f, 0.0f, 1.0) : color*0.33; + } + if (percentile > _HistogramMaxPercentile) + { + outputColor = (input.positionCS.x + input.positionCS.y) % 2 == 0 ? float3(1.0, 0.0f, 0.0f) : color * 0.33; + } + + float histFrameHeight = 0.2 * _RTHandleScale.y; + float minPercentileLoc = max(minPercentileBin, 0); + float maxPercentileLoc = min(maxPercentileBin, HISTOGRAM_BINS - 1); +#if PERCENTILE_AS_BARS + minPercentileLoc /= (HISTOGRAM_BINS - 1); + maxPercentileLoc /= (HISTOGRAM_BINS - 1); +#endif + + DrawHistogramFrame(uv, input.positionCS.xy, histFrameHeight, float3(0.125,0.125,0.125), 0.4f, maxValue, minPercentileLoc, maxPercentileLoc, outputColor); + + + return outputColor; + } + + ENDHLSL + + SubShader + { + Tags{ "RenderPipeline" = "HDRenderPipeline" } + Pass + { + ZWrite Off + ZTest Always + Blend Off + Cull Off + + HLSLPROGRAM + #pragma fragment FragSceneEV100 + ENDHLSL + } + + Pass + { + ZWrite Off + ZTest Always + Blend Off + Cull Off + + HLSLPROGRAM + #pragma fragment FragMetering + ENDHLSL + } + + Pass + { + ZWrite Off + ZTest Always + Blend Off + Cull Off + + HLSLPROGRAM + #pragma fragment FragHistogram + ENDHLSL + } + + } + Fallback Off +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugExposure.shader.meta b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugExposure.shader.meta new file mode 100644 index 00000000000..4383c002901 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugExposure.shader.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 0ef322534f047a34c96d29419d56d17a +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs b/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs index 2ca520cafff..b45ea0a39f2 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs @@ -162,12 +162,34 @@ public enum ShadowMapDebugMode VisualizeDirectionalLightAtlas, /// Display area lights shadow atlas as an overlay. VisualizeAreaLightAtlas, + /// Display punctual lights cached shadow atlas as an overlay. + VisualizeCachedPunctualLightAtlas, + /// Display area lights cached shadow atlas as an overlay. + VisualizeCachedAreaLightAtlas, /// Display a single light shadow map as an overlay. VisualizeShadowMap, /// Replace rendering with a black and white view of the shadow of a single light in the scene. SingleShadow, } + /// + /// Exposure debug mode. + /// + [GenerateHLSL] + public enum ExposureDebugMode + { + /// No exposure debug. + None, + /// Display the EV100 values of the scene, color-coded. + SceneEV100Values, + /// Display the Histogram used for exposure. + HistogramView, + /// Visualize the scene color weighted as the metering mode selected. + MeteringWeighted, + + } + + /// /// Probe Volume Debug Modes. /// @@ -291,8 +313,12 @@ public bool IsDebugDisplayEnabled() /// Maximum number of lights against which the light overdraw gradient is displayed. public uint maxDebugLightCount = 24; + /// Exposure debug mode. + public ExposureDebugMode exposureDebugMode = ExposureDebugMode.None; /// Exposure compensation to apply on current scene exposure. public float debugExposure = 0.0f; + /// Whether to show tonemap curve in the histogram debug view or not. + public bool showTonemapCurveAlongHistogramView = true; /// Display the light cookies atlas. public bool displayCookieAtlas = false; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl index 28338f1bab5..65580776c7c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/LightingDebug.cs.hlsl @@ -59,8 +59,18 @@ #define SHADOWMAPDEBUGMODE_VISUALIZE_PUNCTUAL_LIGHT_ATLAS (1) #define SHADOWMAPDEBUGMODE_VISUALIZE_DIRECTIONAL_LIGHT_ATLAS (2) #define SHADOWMAPDEBUGMODE_VISUALIZE_AREA_LIGHT_ATLAS (3) -#define SHADOWMAPDEBUGMODE_VISUALIZE_SHADOW_MAP (4) -#define SHADOWMAPDEBUGMODE_SINGLE_SHADOW (5) +#define SHADOWMAPDEBUGMODE_VISUALIZE_CACHED_PUNCTUAL_LIGHT_ATLAS (4) +#define SHADOWMAPDEBUGMODE_VISUALIZE_CACHED_AREA_LIGHT_ATLAS (5) +#define SHADOWMAPDEBUGMODE_VISUALIZE_SHADOW_MAP (6) +#define SHADOWMAPDEBUGMODE_SINGLE_SHADOW (7) + +// +// UnityEngine.Rendering.HighDefinition.ExposureDebugMode: static fields +// +#define EXPOSUREDEBUGMODE_NONE (0) +#define EXPOSUREDEBUGMODE_SCENE_EV100VALUES (1) +#define EXPOSUREDEBUGMODE_HISTOGRAM_VIEW (2) +#define EXPOSUREDEBUGMODE_METERING_WEIGHTED (3) // // UnityEngine.Rendering.HighDefinition.ProbeVolumeDebugMode: static fields diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.Types.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.Types.cs index f7af4cc618f..d733242139f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.Types.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.Types.cs @@ -234,6 +234,11 @@ public HDLightType type { if (type != value) { + if (m_ShadowUpdateMode != ShadowUpdateMode.EveryFrame) + { + HDShadowManager.cachedShadowManager.EvictLight(this); + } + switch (value) { case HDLightType.Directional: @@ -256,6 +261,11 @@ public HDLightType type break; } + if (legacyLight.shadows != LightShadows.None && m_ShadowUpdateMode != ShadowUpdateMode.EveryFrame) + { + HDShadowManager.cachedShadowManager.RegisterLight(this); + } + // If the current light unit is not supported by the new light type, we change it var supportedUnits = GetSupportedLightUnits(value, m_SpotLightShape); if (!supportedUnits.Any(u => u == lightUnit)) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs index f4f1c6073fa..0c8f8dec753 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDAdditionalLightData.cs @@ -1330,6 +1330,18 @@ public ShadowUpdateMode shadowUpdateMode if (m_ShadowUpdateMode == value) return; + if (m_ShadowUpdateMode != ShadowUpdateMode.EveryFrame && value == ShadowUpdateMode.EveryFrame) + { + if(!preserveCachedShadow) + { + HDShadowManager.cachedShadowManager.EvictLight(this); + } + } + else if(legacyLight.shadows != LightShadows.None && m_ShadowUpdateMode == ShadowUpdateMode.EveryFrame && value != ShadowUpdateMode.EveryFrame) + { + HDShadowManager.cachedShadowManager.RegisterLight(this); + } + m_ShadowUpdateMode = value; } } @@ -1373,6 +1385,24 @@ public float barnDoorLength } } + [SerializeField] + bool m_preserveCachedShadow = false; + /// + /// Controls whether the cached shadow maps for this light is preserved upon disabling the light. + /// If this field is set to true, then the light will maintain its space in the cached shadow atlas until it is destroyed. + /// + public bool preserveCachedShadow + { + get => m_preserveCachedShadow; + set + { + if (m_preserveCachedShadow == value) + return; + + m_preserveCachedShadow = value; + } + } + /// /// True if the light affects volumetric fog, false otherwise /// @@ -1445,16 +1475,13 @@ internal int shadowPrecision bool m_WillRenderScreenSpaceShadow; bool m_WillRenderRayTracedShadow; int[] m_ShadowRequestIndices; - bool m_ShadowMapRenderedSinceLastRequest = false; - // Data for cached shadow maps. - Vector2 m_CachedShadowResolution = new Vector2(0,0); - Vector3 m_CachedViewPos = new Vector3(0, 0, 0); - int[] m_CachedResolutionRequestIndices = new int[6]; - bool m_CachedDataIsValid = true; - // This is useful to detect whether the atlas has been repacked since the light was last seen - int m_AtlasShapeID = 0; + // Data for cached shadow maps + [System.NonSerialized] + internal int lightIdxForCachedShadows = -1; + Vector3 m_CachedViewPos = new Vector3(0, 0, 0); + [System.NonSerialized] Plane[] m_ShadowFrustumPlanes = new Plane[6]; @@ -1627,24 +1654,21 @@ public int areaLightEmissiveMeshLayer } } - private void DisableCachedShadowSlot() - { - if (WillRenderShadowMap() && !ShadowIsUpdatedEveryFrame()) - { - HDShadowManager.instance.MarkCachedShadowSlotsAsEmpty(shadowMapType, GetInstanceID()); - HDShadowManager.instance.PruneEmptyCachedSlots(shadowMapType); // We invalidate it all to be sure. - m_ShadowMapRenderedSinceLastRequest = false; - } - } void OnDestroy() { - DisableCachedShadowSlot(); + if(lightIdxForCachedShadows >= 0) // If it is within the cached system we need to evict it. + HDShadowManager.cachedShadowManager.EvictLight(this); } void OnDisable() { - DisableCachedShadowSlot(); + // If it is within the cached system we need to evict it, unless user explicitly requires not to. + if (!preserveCachedShadow && lightIdxForCachedShadows >= 0) + { + HDShadowManager.cachedShadowManager.EvictLight(this); + } + SetEmissiveMeshRendererEnabled(false); s_overlappingHDLights.Remove(this); } @@ -1672,20 +1696,18 @@ int GetShadowRequestCount(HDShadowSettings shadowSettings, HDLightType lightType public void RequestShadowMapRendering() { if(shadowUpdateMode == ShadowUpdateMode.OnDemand) - m_ShadowMapRenderedSinceLastRequest = false; + HDShadowManager.cachedShadowManager.ScheduleShadowUpdate(this); } - internal bool ShouldRenderShadows() + + /// + /// Some lights render more than one shadow maps (e.g. cascade shadow maps or point lights). This method is used to request the rendering of specific shadow map + /// when Update Mode is set to On Demand. For example, to request the update of a second cascade, shadowIndex should be 1. + /// Note: if shadowIndex is a 0-based index and it must be lower than the number of shadow maps a light renders (i.e. cascade count for directional lights, 6 for point lights). + /// + public void RequestSubShadowMapRendering(int shadowIndex) { - switch (shadowUpdateMode) - { - case ShadowUpdateMode.EveryFrame: - return true; - case ShadowUpdateMode.OnDemand: - return !m_ShadowMapRenderedSinceLastRequest; - case ShadowUpdateMode.OnEnable: - return !m_ShadowMapRenderedSinceLastRequest; - } - return true; + if (shadowUpdateMode == ShadowUpdateMode.OnDemand) + HDShadowManager.cachedShadowManager.ScheduleShadowUpdate(this, shadowIndex); } internal bool ShadowIsUpdatedEveryFrame() @@ -1705,6 +1727,11 @@ internal void EvaluateShadowState(HDCamera hdCamera, in ProcessedLightData proce // If the shadow is too far away, we don't render it m_WillRenderShadowMap &= processedLight.lightType == HDLightType.Directional || processedLight.distanceToCamera < shadowFadeDistance; + if (processedLight.lightType == HDLightType.Area && areaLightShape != AreaLightShape.Rectangle) + { + m_WillRenderShadowMap = false; + } + // First we reset the ray tracing and screen space shadow data m_WillRenderScreenSpaceShadow = false; m_WillRenderRayTracedShadow = false; @@ -1742,7 +1769,7 @@ internal void EvaluateShadowState(HDCamera hdCamera, in ProcessedLightData proce } } - private int GetResolutionFromSettings(ShadowMapType shadowMapType, HDShadowInitParameters initParameters) + internal int GetResolutionFromSettings(ShadowMapType shadowMapType, HDShadowInitParameters initParameters) { switch (shadowMapType) { @@ -1787,17 +1814,9 @@ internal void ReserveShadowMap(Camera camera, HDShadowManager shadowManager, HDS viewPortRescaling |= (shadowType == ShadowMapType.PunctualAtlas && initParameters.punctualLightShadowAtlas.useDynamicViewportRescale); viewPortRescaling |= (shadowType == ShadowMapType.AreaLightAtlas && initParameters.areaLightShadowAtlas.useDynamicViewportRescale); - bool shadowsAreCached = !ShouldRenderShadows(); - if (shadowsAreCached) - { - viewportSize = m_CachedShadowResolution; - } - else - { - m_CachedShadowResolution = viewportSize; - } + bool shadowIsInCacheSystem = !ShadowIsUpdatedEveryFrame(); - if (viewPortRescaling && !shadowsAreCached) + if (viewPortRescaling && !shadowIsInCacheSystem) { // resize viewport size by the normalized size of the light on screen float screenArea = screenRect.width * screenRect.height; @@ -1816,11 +1835,11 @@ internal void ReserveShadowMap(Camera camera, HDShadowManager shadowManager, HDS shadowManager.UpdateDirectionalShadowResolution((int)viewportSize.x, shadowSettings.cascadeShadowSplitCount.value); int count = GetShadowRequestCount(shadowSettings, lightType); - bool needsCachedSlotsInAtlas = shadowsAreCached && !(ShadowIsUpdatedEveryFrame() || lightType == HDLightType.Directional); + bool needResolutionRequestNow = !shadowIsInCacheSystem || lightType == HDLightType.Directional; for (int index = 0; index < count; index++) { - m_ShadowRequestIndices[index] = shadowManager.ReserveShadowResolutions(needsCachedSlotsInAtlas ? new Vector2(resolution, resolution) : viewportSize, shadowType, GetInstanceID(), index, needsCachedSlotsInAtlas, out m_CachedResolutionRequestIndices[index]); + m_ShadowRequestIndices[index] = shadowManager.ReserveShadowResolutions(shadowIsInCacheSystem ? new Vector2(resolution, resolution) : viewportSize, shadowMapType, GetInstanceID(), index, needResolutionRequestNow); } } @@ -1885,18 +1904,17 @@ internal int UpdateShadowRequest(HDCamera hdCamera, HDShadowManager manager, HDS shadowRequestCount = 0; HDLightType lightType = type; - ShadowMapType shadowType = GetShadowMapType(lightType); int count = GetShadowRequestCount(shadowSettings, lightType); - bool shadowIsCached = !ShouldRenderShadows() && !lightingDebugSettings.clearShadowAtlas; - bool isUpdatedEveryFrame = ShadowIsUpdatedEveryFrame(); - - bool hasCachedSlotInAtlas = !(ShadowIsUpdatedEveryFrame() || legacyLight.type == LightType.Directional); - bool shouldUseRequestFromCachedList = shadowIsCached && hasCachedSlotInAtlas && !manager.AtlasHasResized(shadowType); - bool cachedDataIsValid = shadowIsCached && m_CachedDataIsValid && (manager.GetAtlasShapeID(shadowType) == m_AtlasShapeID) && manager.CachedDataIsValid(shadowType); - cachedDataIsValid = cachedDataIsValid || (legacyLight.type == LightType.Directional); - shadowIsCached = shadowIsCached && (hasCachedSlotInAtlas && cachedDataIsValid || legacyLight.type == LightType.Directional); + bool shadowIsInCachedSystem = !ShadowIsUpdatedEveryFrame(); + // Note if we are in cached system, but if a placement has not been found by this point we bail out shadows + bool shadowHasAtlasPlacement = true; + if (shadowIsInCachedSystem) + { + // If we force evicted the light, it will have lightIdxForCachedShadows == -1 + shadowHasAtlasPlacement = !HDShadowManager.cachedShadowManager.LightIsPendingPlacement(this, shadowMapType) && (lightIdxForCachedShadows != -1); + } for (int index = 0; index < count; index++) { @@ -1905,17 +1923,28 @@ internal int UpdateShadowRequest(HDCamera hdCamera, HDShadowManager manager, HDS Matrix4x4 invViewProjection = Matrix4x4.identity; int shadowRequestIndex = m_ShadowRequestIndices[index]; - HDShadowResolutionRequest resolutionRequest = manager.GetResolutionRequest(shadowType, shouldUseRequestFromCachedList, shouldUseRequestFromCachedList ? m_CachedResolutionRequestIndices[index] : shadowRequestIndex); + HDShadowResolutionRequest resolutionRequest = manager.GetResolutionRequest(shadowRequestIndex); if (resolutionRequest == null) continue; + int cachedShadowID = lightIdxForCachedShadows + index; + bool shadowNeedsRendering = shadowHasAtlasPlacement; + + if (shadowIsInCachedSystem && shadowHasAtlasPlacement) + { + shadowNeedsRendering = HDShadowManager.cachedShadowManager.ShadowIsPendingUpdate(cachedShadowID, shadowMapType); + HDShadowManager.cachedShadowManager.UpdateResolutionRequest(ref resolutionRequest, cachedShadowID, shadowMapType); + } + + shadowRequest.isInCachedAtlas = shadowIsInCachedSystem; + Vector2 viewportSize = resolutionRequest.resolution; if (shadowRequestIndex == -1) continue; - if (shadowIsCached) + if (!shadowNeedsRendering) { shadowRequest.cachedShadowData.cacheTranslationDelta = cameraPos - m_CachedViewPos; shadowRequest.shouldUseCachedShadow = true; @@ -1928,7 +1957,6 @@ internal int UpdateShadowRequest(HDCamera hdCamera, HDShadowManager manager, HDS { m_CachedViewPos = cameraPos; shadowRequest.shouldUseCachedShadow = false; - m_ShadowMapRenderedSinceLastRequest = true; // Write per light type matrices, splitDatas and culling parameters switch (lightType) @@ -1976,11 +2004,14 @@ internal int UpdateShadowRequest(HDCamera hdCamera, HDShadowManager manager, HDS } shadowRequest.atlasViewport = resolutionRequest.atlasViewport; - manager.UpdateShadowRequest(shadowRequestIndex, shadowRequest); - shadowRequest.shouldUseCachedShadow = shadowRequest.shouldUseCachedShadow && cachedDataIsValid; + manager.UpdateShadowRequest(shadowRequestIndex, shadowRequest, shadowIsInCachedSystem); - m_CachedDataIsValid = manager.CachedDataIsValid(shadowType); - m_AtlasShapeID = manager.GetAtlasShapeID(shadowType); + if(shadowIsInCachedSystem && shadowNeedsRendering) + { + // Handshake with the cached shadow manager to notify about the rendering. + // Technically the rendering has not happened yet, but it is scheduled. + HDShadowManager.cachedShadowManager.MarkShadowAsRendered(cachedShadowID, shadowMapType); + } // Store the first shadow request id to return it if (firstShadowRequestIndex == -1) @@ -1989,7 +2020,7 @@ internal int UpdateShadowRequest(HDCamera hdCamera, HDShadowManager manager, HDS shadowRequestCount++; } - return firstShadowRequestIndex; + return shadowHasAtlasPlacement ? firstShadowRequestIndex : -1; } void SetCommonShadowRequestSettings(HDShadowRequest shadowRequest, VisibleLight visibleLight, Vector3 cameraPos, Matrix4x4 invViewProjection, Vector2 viewportSize, int lightIndex, HDLightType lightType, HDShadowFilteringQuality filteringQuality) @@ -2390,8 +2421,8 @@ public static void InitDefaultHDAdditionalLightData(HDAdditionalLightData lightD void OnValidate() { UpdateBounds(); - DisableCachedShadowSlot(); - m_ShadowMapRenderedSinceLastRequest = false; + + RefreshCachedShadow(); #if UNITY_EDITOR // If modification are due to change on prefab asset that are non overridden on this prefab instance @@ -2726,7 +2757,19 @@ internal void UpdateAllLightValues(bool fromTimeLine) UpdateAreaLightEmissiveMesh(fromTimeLine: fromTimeLine); } -#endregion + internal void RefreshCachedShadow() + { + bool wentThroughCachedShadowSystem = lightIdxForCachedShadows >= 0; + if (wentThroughCachedShadowSystem) + HDShadowManager.cachedShadowManager.EvictLight(this); + + if (!ShadowIsUpdatedEveryFrame() && legacyLight.shadows != LightShadows.None) + { + HDShadowManager.cachedShadowManager.RegisterLight(this); + } + } + + #endregion #region User API functions @@ -2866,19 +2909,40 @@ public void SetLightDimmer(float dimmer = 1, float volumetricDimmer = 1) /// Set the shadow resolution. /// /// Must be between 16 and 16384 - public void SetShadowResolution(int resolution) => shadowResolution.@override = resolution; + public void SetShadowResolution(int resolution) + { + if (shadowResolution.@override != resolution) + { + shadowResolution.@override = resolution; + RefreshCachedShadow(); + } + } /// /// Set the shadow resolution quality level. /// /// The quality level to use - public void SetShadowResolutionLevel(int level) => shadowResolution.level = level; + public void SetShadowResolutionLevel(int level) + { + if (shadowResolution.level != level) + { + shadowResolution.level = level; + RefreshCachedShadow(); + } + } /// /// Set whether the shadow resolution use the override value. /// /// True to use the override value, false otherwise. - public void SetShadowResolutionOverride(bool useOverride) => shadowResolution.useOverride = useOverride; + public void SetShadowResolutionOverride(bool useOverride) + { + if (shadowResolution.useOverride != useOverride) + { + shadowResolution.useOverride = useOverride; + RefreshCachedShadow(); + } + } /// /// Set the near plane of the shadow. @@ -3051,8 +3115,11 @@ ShadowMapType shadowMapType void OnEnable() { - if (shadowUpdateMode == ShadowUpdateMode.OnEnable) - m_ShadowMapRenderedSinceLastRequest = false; + if (shadowUpdateMode != ShadowUpdateMode.EveryFrame && legacyLight.shadows != LightShadows.None) + { + HDShadowManager.cachedShadowManager.RegisterLight(this); + } + SetEmissiveMeshRendererEnabled(true); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl index 8d916005488..3734e9e0704 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl @@ -45,7 +45,14 @@ float GetPunctualShadowAttenuation(HDShadowContext shadowContext, float2 positio sd.atlasOffset = shadowContext.shadowDatas[shadowDataIndex + CubeMapFaceID(-L)].atlasOffset; } - return EvalShadow_PunctualDepth(sd, _ShadowmapAtlas, s_linear_clamp_compare_sampler, positionSS, positionWS, normalWS, L, L_dist, perspecive); + if (sd.isInCachedAtlas > 0) // This is a scalar branch. + { + return EvalShadow_PunctualDepth(sd, _CachedShadowmapAtlas, s_linear_clamp_compare_sampler, positionSS, positionWS, normalWS, L, L_dist, perspecive); + } + else + { + return EvalShadow_PunctualDepth(sd, _ShadowmapAtlas, s_linear_clamp_compare_sampler, positionSS, positionWS, normalWS, L, L_dist, perspecive); + } } float GetPunctualShadowClosestDistance(HDShadowContext shadowContext, SamplerState sampl, real3 positionWS, int shadowDataIndex, float3 L, float3 lightPositionWS, bool pointLight) @@ -67,13 +74,31 @@ float GetPunctualShadowClosestDistance(HDShadowContext shadowContext, SamplerSta sd.rot2 = shadowContext.shadowDatas[shadowDataIndex + CubeMapFaceID(-L)].rot2; } - return EvalShadow_SampleClosestDistance_Punctual(sd, _ShadowmapAtlas, sampl, positionWS, L, lightPositionWS); + if (sd.isInCachedAtlas > 0) // This is a scalar branch. + { + return EvalShadow_SampleClosestDistance_Punctual(sd, _CachedShadowmapAtlas, sampl, positionWS, L, lightPositionWS); + } + else + { + return EvalShadow_SampleClosestDistance_Punctual(sd, _ShadowmapAtlas, sampl, positionWS, L, lightPositionWS); + } } float GetAreaLightAttenuation(HDShadowContext shadowContext, float2 positionSS, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 L, float L_dist) { +#if (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER)) + shadowDataIndex = WaveReadLaneFirst(shadowDataIndex); +#endif HDShadowData sd = shadowContext.shadowDatas[shadowDataIndex]; - return EvalShadow_AreaDepth(sd, _ShadowmapAreaAtlas, positionSS, positionWS, normalWS, L, L_dist, true); + + if (sd.isInCachedAtlas > 0) // This is a scalar branch. + { + return EvalShadow_AreaDepth(sd, _CachedAreaLightShadowmapAtlas, positionSS, positionWS, normalWS, L, L_dist, true); + } + else + { + return EvalShadow_AreaDepth(sd, _ShadowmapAreaAtlas, positionSS, positionWS, normalWS, L, L_dist, true); + } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index 05dec005554..8ed3f8f2455 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -775,10 +775,7 @@ void InitShadowSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources def m_ShadowManager = HDShadowManager.instance; m_ShadowManager.InitShadowManager( defaultResources, - m_ShadowInitParameters.directionalShadowsDepthBits, - m_ShadowInitParameters.punctualLightShadowAtlas, - m_ShadowInitParameters.areaLightShadowAtlas, - m_ShadowInitParameters.maxShadowRequests, + m_ShadowInitParameters, defaultResources.shaders.shadowClearPS ); } @@ -1194,7 +1191,7 @@ internal void GetDirectionalLightData(CommandBuffer cmd, HDCamera hdCamera, Visi var lightData = new DirectionalLightData(); - lightData.lightLayers = additionalLightData.GetLightLayers(); + lightData.lightLayers = hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? additionalLightData.GetLightLayers() : uint.MaxValue; // Light direction for directional is opposite to the forward direction lightData.forward = light.GetForward(); @@ -1346,7 +1343,7 @@ internal void GetLightData(CommandBuffer cmd, HDCamera hdCamera, HDShadowSetting var lightType = processedData.lightType; var visibleLightAxisAndPosition = light.GetAxisAndPosition(); - lightData.lightLayers = additionalLightData.GetLightLayers(); + lightData.lightLayers = hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? additionalLightData.GetLightLayers() : uint.MaxValue; lightData.lightType = gpuLightType; @@ -1843,7 +1840,7 @@ internal bool GetEnvLightData(CommandBuffer cmd, HDCamera hdCamera, in Processed return false; InfluenceVolume influence = probe.influenceVolume; - envLightData.lightLayers = probe.lightLayersAsUInt; + envLightData.lightLayers = hdCamera.frameSettings.IsEnabled(FrameSettingsField.LightLayers) ? probe.lightLayersAsUInt : uint.MaxValue; envLightData.influenceShapeType = influence.envShape; envLightData.weight = processedProbe.weight; envLightData.multiplier = probe.multiplier * m_indirectLightingController.indirectSpecularIntensity.value; @@ -2569,6 +2566,8 @@ bool PrepareLightsForGPU(CommandBuffer cmd, HDCamera hdCamera, CullingResults cu var debugLightFilter = debugDisplaySettings.GetDebugLightFilterMode(); var hasDebugLightFilter = debugLightFilter != DebugLightFilterMode.None; + HDShadowManager.cachedShadowManager.AssignSlotsInAtlases(); + using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.PrepareLightsForGPU))) { Camera camera = hdCamera.camera; @@ -2631,8 +2630,6 @@ bool PrepareLightsForGPU(CommandBuffer cmd, HDCamera hdCamera, CullingResults cu PrepareGPUProbeData(cmd, hdCamera, cullResults, hdProbeCullingResults, processedProbesCount); } - HDShadowManager.instance.CheckForCulledCachedShadows(); - if (decalDatasCount > 0) { for (int i = 0; i < decalDatasCount; i++) @@ -4137,6 +4134,10 @@ static void RenderShadowsDebugOverlay(in DebugParameters debugParameters, in HDS parameters.shadowManager.DisplayShadowAtlas(atlasTextures.punctualShadowAtlas, cmd, parameters.debugShadowMapMaterial, x, y, overlaySize, overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); break; + case ShadowMapDebugMode.VisualizeCachedPunctualLightAtlas: + parameters.shadowManager.DisplayCachedPunctualShadowAtlas(atlasTextures.cachedPunctualShadowAtlas, cmd, parameters.debugShadowMapMaterial, x, y, overlaySize, overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); + HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); + break; case ShadowMapDebugMode.VisualizeDirectionalLightAtlas: parameters.shadowManager.DisplayShadowCascadeAtlas(atlasTextures.cascadeShadowAtlas, cmd, parameters.debugShadowMapMaterial, x, y, overlaySize, overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); @@ -4145,6 +4146,10 @@ static void RenderShadowsDebugOverlay(in DebugParameters debugParameters, in HDS parameters.shadowManager.DisplayAreaLightShadowAtlas(atlasTextures.areaShadowAtlas, cmd, parameters.debugShadowMapMaterial, x, y, overlaySize, overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); break; + case ShadowMapDebugMode.VisualizeCachedAreaLightAtlas: + parameters.shadowManager.DisplayCachedAreaShadowAtlas(atlasTextures.cachedAreaShadowAtlas, cmd, parameters.debugShadowMapMaterial, x, y, overlaySize, overlaySize, lightingDebug.shadowMinValue, lightingDebug.shadowMaxValue, mpb); + HDUtils.NextOverlayCoord(ref x, ref y, overlaySize, overlaySize, hdCamera); + break; default: break; } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs index 926a23f2f84..49bd699a153 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.RenderGraph.cs @@ -30,7 +30,7 @@ public TextureHandle Render(RenderGraph renderGraph, HDCamera hdCamera, TextureH historyRT.referenceSize.y * historyRT.scaleFactor.y); var rtScaleForHistory = hdCamera.historyRTHandleProperties.rtHandleScale; - var aoParameters = PrepareRenderAOParameters(hdCamera, renderGraph.rtHandleProperties, historySize * rtScaleForHistory, frameCount); + var aoParameters = PrepareRenderAOParameters(hdCamera, historySize * rtScaleForHistory, frameCount); var packedData = RenderAO(renderGraph, aoParameters, depthPyramid); result = DenoiseAO(renderGraph, aoParameters, motionVectors, packedData, currentHistory, outputHistory); @@ -102,8 +102,8 @@ TextureHandle DenoiseAO( RenderGraph renderGraph, passData.parameters = parameters; passData.packedData = builder.ReadTexture(aoPackedData); passData.motionVectors = builder.ReadTexture(motionVectors); - passData.packedDataBlurred = builder.WriteTexture(renderGraph.CreateTexture( - new TextureDesc(Vector2.one * scaleFactor, true, true) { colorFormat = GraphicsFormat.R32_UInt, enableRandomWrite = true, name = "AO Packed blurred data" } )); + passData.packedDataBlurred = builder.CreateTransientTexture( + new TextureDesc(Vector2.one * scaleFactor, true, true) { colorFormat = GraphicsFormat.R32_UInt, enableRandomWrite = true, name = "AO Packed blurred data" } ); passData.currentHistory = builder.ReadTexture(currentHistory); // can also be written on first frame, but since it's an imported resource, it doesn't matter in term of lifetime. passData.outputHistory = builder.WriteTexture(outputHistory); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs index 25273975777..74170876cb9 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs @@ -300,7 +300,7 @@ struct RenderAOParameters public ShaderVariablesAmbientOcclusion cb; } - RenderAOParameters PrepareRenderAOParameters(HDCamera camera, RTHandleProperties rtHandleProperties, Vector2 historySize, int frameCount) + RenderAOParameters PrepareRenderAOParameters(HDCamera camera, Vector2 historySize, int frameCount) { var parameters = new RenderAOParameters(); @@ -567,7 +567,7 @@ internal void Dispatch(CommandBuffer cmd, HDCamera camera, int frameCount) currentHistory.referenceSize.y * currentHistory.scaleFactor.y); var rtScaleForHistory = camera.historyRTHandleProperties.rtHandleScale; - var aoParameters = PrepareRenderAOParameters(camera, RTHandles.rtHandleProperties, historySize * rtScaleForHistory, frameCount); + var aoParameters = PrepareRenderAOParameters(camera, historySize * rtScaleForHistory, frameCount); using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.HorizonSSAO))) { RenderAO(aoParameters, m_PackedDataTex, m_Resources, cmd); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs new file mode 100644 index 00000000000..243ae194781 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs @@ -0,0 +1,524 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using UnityEngine.Experimental.Rendering; + +namespace UnityEngine.Rendering.HighDefinition +{ + class HDCachedShadowAtlas : HDShadowAtlas + { + static private int s_InitialCapacity = 256; + + // Constants. + private const int m_MinSlotSize = 64; + private const int m_MaxShadowsPerLight = 6; + + + private int m_NextLightID = 0; + private bool m_CanTryPlacement = false; + + struct CachedShadowRecord + { + internal int shadowIndex; + internal int viewportSize; // We assume only square shadows maps. + internal Vector4 offsetInAtlas; // When is registered xy is the offset in the texture atlas, in UVs, the zw is the entry offset in the C# representation. + } + + private int m_AtlasResolutionInSlots; // Atlas Resolution / m_MinSlotSize + + private bool m_NeedOptimalPacking = true; // Whenever this is set to true, the pending lights are sorted before insertion. + + private List m_AtlasSlots; // One entry per slot (of size m_MinSlotSize) true if occupied, false if free. + + // Note: Some of these could be simple lists, but since we might need to search by index some of them and we want to avoid GC alloc, a dictionary is easier. + // This also mean slightly worse performance, however hopefully the number of cached shadow lights is not huge at any tie. + private Dictionary m_PlacedShadows; + private Dictionary m_ShadowsPendingRendering; + private Dictionary m_RegisteredLightDataPendingPlacement; + private Dictionary m_RecordsPendingPlacement; // Note: this is different from m_RegisteredLightDataPendingPlacement because it contains records that were allocated in the system + // but they lost their spot (e.g. post defrag). They don't have a light associated anymore if not by index, so we keep a separate collection. + + private List m_TempListForPlacement; + + + private ShadowMapType m_ShadowType; + + // ------------------------------------------------------------------------------------------ + // Init Functions + // ------------------------------------------------------------------------------------------ + public HDCachedShadowAtlas(ShadowMapType type) + { + m_PlacedShadows = new Dictionary(s_InitialCapacity); + m_ShadowsPendingRendering = new Dictionary(s_InitialCapacity); + m_TempListForPlacement = new List(s_InitialCapacity); + + m_RegisteredLightDataPendingPlacement = new Dictionary(s_InitialCapacity); + m_RecordsPendingPlacement = new Dictionary(s_InitialCapacity); + + m_ShadowType = type; + } + + public override void InitAtlas(RenderPipelineResources renderPipelineResources, int width, int height, int atlasShaderID, Material clearMaterial, int maxShadowRequests, HDShadowInitParameters initParams, BlurAlgorithm blurAlgorithm = BlurAlgorithm.None, FilterMode filterMode = FilterMode.Bilinear, DepthBits depthBufferBits = DepthBits.Depth16, RenderTextureFormat format = RenderTextureFormat.Shadowmap, string name = "") + { + base.InitAtlas(renderPipelineResources, width, height, atlasShaderID, clearMaterial, maxShadowRequests, initParams, blurAlgorithm, filterMode, depthBufferBits, format, name); + + m_AtlasResolutionInSlots = HDUtils.DivRoundUp(width, m_MinSlotSize); + m_AtlasSlots = new List(m_AtlasResolutionInSlots * m_AtlasResolutionInSlots); + for (int i = 0; i < m_AtlasResolutionInSlots * m_AtlasResolutionInSlots; ++i) + { + m_AtlasSlots.Add(false); + } + + // Note: If changing the characteristics of the atlas via HDRP asset, the lights OnEnable will not be called again so we are missing them, however we can explicitly + // put them back up for placement. If this is the first Init of the atlas, the lines below do nothing. + DefragmentAtlasAndReRender(initParams); + m_CanTryPlacement = true; + m_NeedOptimalPacking = true; + } + // ------------------------------------------------------------------------------------------ + + + + // ------------------------------------------------------------------------------------------ + // Functions to access and deal with the C# representation of the atlas + // ------------------------------------------------------------------------------------------ + private bool IsEntryEmpty(int x, int y) + { + return (m_AtlasSlots[y * m_AtlasResolutionInSlots + x] == false); + } + private bool IsEntryFull(int x, int y) + { + return (m_AtlasSlots[y * m_AtlasResolutionInSlots + x]); + } + + // Always fill slots in a square shape, for example : if x = 1 and y = 2, if numEntries = 2 it will fill {(1,2),(2,2),(1,3),(2,3)} + private void FillEntries(int x, int y, int numEntries) + { + MarkEntries(x, y, numEntries, true); + } + + private void MarkEntries(int x, int y, int numEntries, bool value) + { + for (int j = y; j < y + numEntries; ++j) + { + for (int i = x; i < x + numEntries; ++i) + { + m_AtlasSlots[j * m_AtlasResolutionInSlots + i] = value; + } + } + } + + // Checks if we have a square slot available starting from (x,y) and of size numEntries. + private bool CheckSlotAvailability(int x, int y, int numEntries) + { + for (int j = y; j < y + numEntries; ++j) + { + for (int i = x; i < x + numEntries; ++i) + { + if (i >= m_AtlasResolutionInSlots || j >= m_AtlasResolutionInSlots || IsEntryFull(i, j)) + { + return false; + } + } + } + return true; + } + + internal bool FindSlotInAtlas(int resolution, out int x, out int y) + { + int numEntries = HDUtils.DivRoundUp(resolution, m_MinSlotSize); + + for (int j = 0; j < m_AtlasResolutionInSlots; ++j) + { + for (int i = 0; i < m_AtlasResolutionInSlots; ++i) + { + if (CheckSlotAvailability(i, j, numEntries)) + { + x = i; + y = j; + return true; + } + } + } + + x = 0; + y = 0; + return false; + } + + internal bool GetSlotInAtlas(int resolution, out int x, out int y) + { + if (FindSlotInAtlas(resolution, out x, out y)) + { + int numEntries = HDUtils.DivRoundUp(resolution, m_MinSlotSize); + FillEntries(x, y, numEntries); + return true; + } + + return false; + } + // --------------------------------------------------------------------------------------- + + // ------------------------------------------------------------------------------------------ + // Entry and exit points to the atlas + // ------------------------------------------------------------------------------------------ + + internal int GetNextLightIdentifier() + { + int outputId = m_NextLightID; + m_NextLightID += m_MaxShadowsPerLight; // We give unique identifiers to each + return outputId; + } + + internal void RegisterLight(HDAdditionalLightData lightData) + { + // If we are trying to register something that we have already placed, we do nothing + if (lightData.lightIdxForCachedShadows >= 0 && m_PlacedShadows.ContainsKey(lightData.lightIdxForCachedShadows)) + return; + + // We register only if not already pending placement and if enabled. + if (!m_RegisteredLightDataPendingPlacement.ContainsKey(lightData.lightIdxForCachedShadows) && lightData.isActiveAndEnabled) + { +#if UNITY_2020_2_OR_NEWER + lightData.legacyLight.useViewFrustumForShadowCasterCull = false; +#endif + lightData.lightIdxForCachedShadows = GetNextLightIdentifier(); + + m_RegisteredLightDataPendingPlacement.Add(lightData.lightIdxForCachedShadows, lightData); + m_CanTryPlacement = true; + } + } + + internal void EvictLight(HDAdditionalLightData lightData) + { + m_RegisteredLightDataPendingPlacement.Remove(lightData.lightIdxForCachedShadows); + + int numberOfShadows = (lightData.type == HDLightType.Point) ? 6 : 1; + + int lightIdx = lightData.lightIdxForCachedShadows; + lightData.lightIdxForCachedShadows = -1; + + for (int i = 0; i < numberOfShadows; ++i) + { + bool valueFound = false; + int shadowIdx = lightIdx + i; + + m_RecordsPendingPlacement.Remove(shadowIdx); + + valueFound = m_PlacedShadows.TryGetValue(shadowIdx, out CachedShadowRecord recordToRemove); + + if (valueFound) + { +#if UNITY_2020_2_OR_NEWER + lightData.legacyLight.useViewFrustumForShadowCasterCull = true; +#endif + m_PlacedShadows.Remove(shadowIdx); + m_ShadowsPendingRendering.Remove(shadowIdx); + + MarkEntries((int)recordToRemove.offsetInAtlas.z, (int)recordToRemove.offsetInAtlas.w, HDUtils.DivRoundUp(recordToRemove.viewportSize, m_MinSlotSize), false); + m_CanTryPlacement = true; + } + } + } + + // ------------------------------------------------------------------------------------------ + + + // ------------------------------------------------------------------------------------------ + // Atlassing on the actual textures + // ------------------------------------------------------------------------------------------ + + + void InsertionSort(ref List list, int startIndex, int lastIndex) + { + int i = startIndex; + + while (i < lastIndex) + { + var curr = list[i]; + + int j = i - 1; + + // Sort in descending order. + while ((j >= 0) && ((curr.viewportSize > list[j].viewportSize))) + { + list[j + 1] = list[j]; + j--; + } + + list[j + 1] = curr; + i++; + } + } + + private void AddLightListToRecordList(Dictionary lightList, HDShadowInitParameters initParams, ref List recordList) + { + foreach (var currentLightData in lightList.Values) + { + int resolution = 0; + + resolution = currentLightData.GetResolutionFromSettings(m_ShadowType, initParams); + + HDLightType lightType = currentLightData.type; + int numberOfShadows = (lightType == HDLightType.Point) ? 6 : 1; + + for (int i = 0; i < numberOfShadows; ++i) + { + CachedShadowRecord record; + record.shadowIndex = currentLightData.lightIdxForCachedShadows + i; + record.viewportSize = resolution; + record.offsetInAtlas = new Vector4(-1, -1, -1, -1); // Will be set later. + + recordList.Add(record); + } + } + } + + private bool PlaceMultipleShadows(int startIdx, int numberOfShadows) + { + int firstShadowIdx = m_TempListForPlacement[startIdx].shadowIndex; + + Vector2Int[] placements = new Vector2Int[m_MaxShadowsPerLight]; + int successfullyPlaced = 0; + + for (int j = 0; j < numberOfShadows; ++j) + { + var record = m_TempListForPlacement[startIdx + j]; + + Debug.Assert(firstShadowIdx + j == record.shadowIndex); + + int x, y; + if (GetSlotInAtlas(record.viewportSize, out x, out y)) + { + successfullyPlaced++; + placements[j] = new Vector2Int(x, y); + } + else + { + break; + } + } + + // If they all fit, we actually placed them, otherwise we mark the slot that we temp filled as free and go on. + if(successfullyPlaced == numberOfShadows) // Success. + { + for (int j = 0; j < numberOfShadows; ++j) + { + var record = m_TempListForPlacement[startIdx + j]; + + record.offsetInAtlas = new Vector4(placements[j].x * m_MinSlotSize, placements[j].y * m_MinSlotSize, placements[j].x, placements[j].y); + + m_ShadowsPendingRendering.Add(record.shadowIndex, record); + m_PlacedShadows.Add(record.shadowIndex, record); + } + + return true; + } + else if(successfullyPlaced > 0) // Couldn't place them all, but we placed something, so we revert those placements. + { + int numEntries = HDUtils.DivRoundUp(m_TempListForPlacement[startIdx].viewportSize, m_MinSlotSize); + for (int j=0; j 0 && m_CanTryPlacement) + { + m_TempListForPlacement.Clear(); + + m_TempListForPlacement.AddRange(m_RecordsPendingPlacement.Values); + AddLightListToRecordList(m_RegisteredLightDataPendingPlacement, initParameters, ref m_TempListForPlacement); + + if (m_NeedOptimalPacking) + { + InsertionSort(ref m_TempListForPlacement, 0, m_TempListForPlacement.Count); + m_NeedOptimalPacking = false; + } + + PerformPlacement(); + + m_CanTryPlacement = false; // It is pointless we try the placement every frame if no modifications to the amount of light registered happened. + } + } + + internal void DefragmentAtlasAndReRender(HDShadowInitParameters initParams) + { + m_TempListForPlacement.Clear(); + + m_TempListForPlacement.AddRange(m_PlacedShadows.Values); + m_TempListForPlacement.AddRange(m_RecordsPendingPlacement.Values); + AddLightListToRecordList(m_RegisteredLightDataPendingPlacement, initParams, ref m_TempListForPlacement); + + for (int i = 0; i < m_AtlasResolutionInSlots * m_AtlasResolutionInSlots; ++i) + { + m_AtlasSlots[i] = false; + } + + // Clear the other state lists. + m_PlacedShadows.Clear(); + m_ShadowsPendingRendering.Clear(); + m_RecordsPendingPlacement.Clear(); // We'll reset what records are pending. + + // Sort in order to obtain a more optimal packing. + InsertionSort(ref m_TempListForPlacement, 0, m_TempListForPlacement.Count); + + PerformPlacement(); + + // This is fairly inefficient, but simple and this function should be called very rarely. + // We need to add to pending the records that were placed but were not in m_RegisteredLightDataPendingPlacement + // but they don't have a place yet. + foreach (var record in m_TempListForPlacement) + { + if (!m_PlacedShadows.ContainsKey(record.shadowIndex)) // If we couldn't place it + { + int parentLightIdx = record.shadowIndex - (record.shadowIndex % m_MaxShadowsPerLight); + if (!m_RegisteredLightDataPendingPlacement.ContainsKey(parentLightIdx)) // Did not come originally from m_RegisteredLightDataPendingPlacement + { + if (!m_RecordsPendingPlacement.ContainsKey(record.shadowIndex)) + m_RecordsPendingPlacement.Add(record.shadowIndex, record); + } + } + } + + m_CanTryPlacement = false; + } + + // ------------------------------------------------------------------------------------------ + + + // ------------------------------------------------------------------------------------------ + // Functions to query and change state of a shadow + // ------------------------------------------------------------------------------------------ + internal bool LightIsPendingPlacement(HDAdditionalLightData lightData) + { + return (m_RegisteredLightDataPendingPlacement.ContainsKey(lightData.lightIdxForCachedShadows) || + m_RecordsPendingPlacement.ContainsKey(lightData.lightIdxForCachedShadows)); + } + + internal bool ShadowIsPendingRendering(int shadowIdx) + { + return m_ShadowsPendingRendering.ContainsKey(shadowIdx); + } + + internal void ScheduleShadowUpdate(HDAdditionalLightData lightData) + { + if (!lightData.isActiveAndEnabled) return; + + int lightIdx = lightData.lightIdxForCachedShadows; + Debug.Assert(lightIdx >= 0); + + if (!m_PlacedShadows.ContainsKey(lightIdx)) + { + if (m_RegisteredLightDataPendingPlacement.ContainsKey(lightIdx)) + return; + + RegisterLight(lightData); + } + else + { + int numberOfShadows = (lightData.type == HDLightType.Point) ? 6 : 1; + for (int i = 0; i < numberOfShadows; ++i) + { + int shadowIdx = lightIdx + i; + ScheduleShadowUpdate(shadowIdx); + } + } + } + + internal void ScheduleShadowUpdate(int shadowIdx) + { + // It needs to be placed already, otherwise needs to go through the registering cycle first. + CachedShadowRecord shadowRecord; + bool recordFound = m_PlacedShadows.TryGetValue(shadowIdx, out shadowRecord); + Debug.Assert(recordFound); + // Return to avoid error when assert is skipped. + if (!recordFound) return; + + // It already schedule for update we do nothing; + if (m_ShadowsPendingRendering.ContainsKey(shadowIdx)) + return; + + // Put the record up for rendering + m_ShadowsPendingRendering.Add(shadowIdx, shadowRecord); + } + + internal void MarkAsRendered(int shadowIdx) + { + if (m_ShadowsPendingRendering.ContainsKey(shadowIdx)) + { + m_ShadowsPendingRendering.Remove(shadowIdx); + } + } + + // Used to update the resolution request processed by the light loop + internal void UpdateResolutionRequest(ref HDShadowResolutionRequest request, int shadowIdx) + { + CachedShadowRecord record; + bool valueFound = m_PlacedShadows.TryGetValue(shadowIdx, out record); + + if (!valueFound) + { + Debug.LogWarning("Trying to render a cached shadow map that doesn't have a slot in the atlas yet."); + } + + request.atlasViewport = new Rect(record.offsetInAtlas.x, record.offsetInAtlas.y, record.viewportSize, record.viewportSize); + request.resolution = new Vector2(record.viewportSize, record.viewportSize); + } + + // ------------------------------------------------------------------------------------------ + } +} + + diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs.meta b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs.meta new file mode 100644 index 00000000000..8db859613f5 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowAtlas.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 30d3e37aa9eea124490d8fc2afcb5c8e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowManager.cs new file mode 100644 index 00000000000..dde24b128bd --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowManager.cs @@ -0,0 +1,306 @@ +using System; +using System.Collections.Generic; +using UnityEngine.Experimental.Rendering; +using UnityEngine.Serialization; + +namespace UnityEngine.Rendering.HighDefinition +{ + // Note: The punctual and area light shadows have a specific atlas, however because there can be only be only one directional light casting shadow + // we use this cached shadow manager only as a source of utilities functions, but the data is stored in the dynamic shadow atlas. + + /// + /// The class responsible to handle cached shadow maps (shadows with Update mode set to OnEnable or OnDemand). + /// + public class HDCachedShadowManager + { + private static HDCachedShadowManager s_Instance = new HDCachedShadowManager(); + public static HDCachedShadowManager instance { get { return s_Instance; } } + + // Data for cached directional light shadows. + private const int m_MaxShadowCascades = 4; + private bool[] m_DirectionalShadowPendingUpdate = new bool[m_MaxShadowCascades]; + + // Cached atlas + internal HDCachedShadowAtlas punctualShadowAtlas; + internal HDCachedShadowAtlas areaShadowAtlas; + // Cache here to be able to compute resolutions. + private HDShadowInitParameters m_InitParams; + + // ------------------------ Debug API ------------------------------- +#if UNITY_EDITOR + internal void PrintLightStatusInCachedAtlas() + { + bool headerPrinted = false; + var lights = GameObject.FindObjectsOfType(); + foreach (var light in lights) + { + ShadowMapType shadowMapType = light.GetShadowMapType(light.type); + if (instance.LightIsPendingPlacement(light, shadowMapType)) + { + if (!headerPrinted) + { + Debug.Log(" ===== Lights pending placement in the cached shadow atlas: ===== "); + headerPrinted = true; + } + Debug.Log("\t Name: " + light.name + " Type: " + light.type + " Resolution: " + light.GetResolutionFromSettings(shadowMapType, m_InitParams)); + } + } + + headerPrinted = false; + foreach (var light in lights) + { + ShadowMapType shadowMapType = light.GetShadowMapType(light.type); + if (!(instance.LightIsPendingPlacement(light, light.GetShadowMapType(light.type))) && light.lightIdxForCachedShadows != -1) + { + if (!headerPrinted) + { + Debug.Log("===== Lights placed in cached shadow atlas: ===== "); + headerPrinted = true; + } + Debug.Log("\t Name: " + light.name + " Type: " + light.type + " Resolution: " + light.GetResolutionFromSettings(shadowMapType, m_InitParams)); + } + } + } +#endif + // ------------------------ Public API ------------------------------- + + /// + /// This function verifies if a shadow map of resolution shadowResolution for a light of type lightType would fit in the atlas when inserted. + /// + /// The resolution of the hypothetical shadow map that we are assessing. + /// The type of the light that cast the hypothetical shadow map that we are assessing. + /// True if the shadow map would fit in the atlas, false otherwise. + public bool WouldFitInAtlas(int shadowResolution, HDLightType lightType) + { + bool fits = true; + int x, y; + + if (lightType == HDLightType.Point) + { + for (int i = 0; i < 6; ++i) + { + fits = fits && HDShadowManager.cachedShadowManager.punctualShadowAtlas.FindSlotInAtlas(shadowResolution, out x, out y); + } + } + + if (lightType == HDLightType.Spot) + fits = fits && HDShadowManager.cachedShadowManager.punctualShadowAtlas.FindSlotInAtlas(shadowResolution, out x, out y); + + if (lightType == HDLightType.Area) + fits = fits && HDShadowManager.cachedShadowManager.areaShadowAtlas.FindSlotInAtlas(shadowResolution, out x, out y); + + return fits; + } + + /// + /// If a light is added after a scene is loaded, its placement in the atlas might be not optimal and the suboptimal placement might prevent a light to find a place in the atlas. + /// This function will force a defragmentation of the atlas containing lights of type lightType and redistributes the shadows inside so that the placement is optimal. Note however that this will also mark the shadow maps + /// as dirty and they will be re-rendered as soon the light will come into view for the first time after this function call. + /// + /// The type of the light contained in the atlas that need defragmentation. + public void DefragAtlas(HDLightType lightType) + { + if (lightType == HDLightType.Area) + instance.areaShadowAtlas.DefragmentAtlasAndReRender(instance.m_InitParams); + if (lightType == HDLightType.Point || lightType == HDLightType.Spot) + instance.punctualShadowAtlas.DefragmentAtlasAndReRender(instance.m_InitParams); + } + + /// + /// This function can be used to evict a light from its atlas. The slots occupied by such light will be available to be occupied by other shadows. + /// Note that eviction happens automatically upon light destruction and, if lightData.preserveCachedShadow is false, upon disabling of the light. + /// + /// The light to evict from the atlas. + public void ForceEvictLight(HDAdditionalLightData lightData) + { + EvictLight(lightData); + lightData.lightIdxForCachedShadows = -1; + } + + /// + /// This function can be used to register a light to the cached shadow system if not already registered. It is necessary to call this function if a light has been + /// evicted with ForceEvictLight and it needs to be registered again. Please note that a light is automatically registered when enabled or when the shadow update changes + /// from EveryFrame to OnDemand or OnEnable. + /// + /// The light to register. + public void ForceRegisterLight(HDAdditionalLightData lightData) + { + // Note: this is for now just calling the internal API, but having a separate API helps with future + // changes to the process. + RegisterLight(lightData); + } + + // ------------------------------------------------------------------------------------------------------------------ + + private void MarkAllDirectionalShadowsForUpdate() + { + for (int i = 0; i < m_MaxShadowCascades; ++i) + { + m_DirectionalShadowPendingUpdate[i] = true; + } + } + + private HDCachedShadowManager() + { + punctualShadowAtlas = new HDCachedShadowAtlas(ShadowMapType.PunctualAtlas); + if (ShaderConfig.s_AreaLights == 1) + areaShadowAtlas = new HDCachedShadowAtlas(ShadowMapType.AreaLightAtlas); + } + + internal void InitPunctualShadowAtlas(RenderPipelineResources renderPipelineResources, int width, int height, int atlasShaderID, Material clearMaterial, int maxShadowRequests, HDShadowInitParameters initParams, + HDShadowAtlas.BlurAlgorithm blurAlgorithm = HDShadowAtlas.BlurAlgorithm.None, FilterMode filterMode = FilterMode.Bilinear, DepthBits depthBufferBits = DepthBits.Depth16, RenderTextureFormat format = RenderTextureFormat.Shadowmap, string name = "") + { + m_InitParams = initParams; + punctualShadowAtlas.InitAtlas(renderPipelineResources, width, height, atlasShaderID, clearMaterial, maxShadowRequests, initParams, blurAlgorithm, filterMode, depthBufferBits, format, name); + } + + internal void InitAreaLightShadowAtlas(RenderPipelineResources renderPipelineResources, int width, int height, int atlasShaderID, Material clearMaterial, int maxShadowRequests, HDShadowInitParameters initParams, + HDShadowAtlas.BlurAlgorithm blurAlgorithm = HDShadowAtlas.BlurAlgorithm.None, FilterMode filterMode = FilterMode.Bilinear, DepthBits depthBufferBits = DepthBits.Depth16, RenderTextureFormat format = RenderTextureFormat.Shadowmap, string name = "") + { + m_InitParams = initParams; + areaShadowAtlas.InitAtlas(renderPipelineResources, width, height, atlasShaderID, clearMaterial, maxShadowRequests, initParams, blurAlgorithm, filterMode, depthBufferBits, format, name); + } + + internal void RegisterLight(HDAdditionalLightData lightData) + { + HDLightType lightType = lightData.type; + + if (lightType == HDLightType.Directional) + { + lightData.lightIdxForCachedShadows = 0; + MarkAllDirectionalShadowsForUpdate(); + } + + if (lightType == HDLightType.Spot || lightType == HDLightType.Point) + { + punctualShadowAtlas.RegisterLight(lightData); + } + + if (ShaderConfig.s_AreaLights == 1 && lightType == HDLightType.Area && lightData.areaLightShape == AreaLightShape.Rectangle) + { + areaShadowAtlas.RegisterLight(lightData); + } + } + + internal void EvictLight(HDAdditionalLightData lightData) + { + HDLightType lightType = lightData.type; + + if (lightType == HDLightType.Directional) + { + lightData.lightIdxForCachedShadows = -1; + MarkAllDirectionalShadowsForUpdate(); + } + + if (lightType == HDLightType.Spot || lightType == HDLightType.Point) + { + punctualShadowAtlas.EvictLight(lightData); + } + + if (ShaderConfig.s_AreaLights == 1 && lightType == HDLightType.Area) + { + areaShadowAtlas.EvictLight(lightData); + } + } + + internal void AssignSlotsInAtlases() + { + punctualShadowAtlas.AssignOffsetsInAtlas(m_InitParams); + if(ShaderConfig.s_AreaLights == 1) + areaShadowAtlas.AssignOffsetsInAtlas(m_InitParams); + } + + internal bool ShadowIsPendingUpdate(int shadowIdx, ShadowMapType shadowMapType) + { + if (shadowMapType == ShadowMapType.PunctualAtlas) + return punctualShadowAtlas.ShadowIsPendingRendering(shadowIdx); + if (shadowMapType == ShadowMapType.AreaLightAtlas) + return areaShadowAtlas.ShadowIsPendingRendering(shadowIdx); + if (shadowMapType == ShadowMapType.CascadedDirectional) + return m_DirectionalShadowPendingUpdate[shadowIdx]; + + return false; + } + + internal void MarkShadowAsRendered(int shadowIdx, ShadowMapType shadowMapType) + { + if (shadowMapType == ShadowMapType.PunctualAtlas) + punctualShadowAtlas.MarkAsRendered(shadowIdx); + if (shadowMapType == ShadowMapType.AreaLightAtlas) + areaShadowAtlas.MarkAsRendered(shadowIdx); + if (shadowMapType == ShadowMapType.CascadedDirectional) + m_DirectionalShadowPendingUpdate[shadowIdx] = false; + } + + internal void UpdateResolutionRequest(ref HDShadowResolutionRequest request, int shadowIdx, ShadowMapType shadowMapType) + { + if (shadowMapType == ShadowMapType.PunctualAtlas) + punctualShadowAtlas.UpdateResolutionRequest(ref request, shadowIdx); + else if (shadowMapType == ShadowMapType.AreaLightAtlas) + areaShadowAtlas.UpdateResolutionRequest(ref request, shadowIdx); + } + + internal void UpdateDebugSettings(LightingDebugSettings lightingDebugSettings) + { + punctualShadowAtlas.UpdateDebugSettings(lightingDebugSettings); + if (ShaderConfig.s_AreaLights == 1) + areaShadowAtlas.UpdateDebugSettings(lightingDebugSettings); + } + + internal void ScheduleShadowUpdate(HDAdditionalLightData light) + { + var lightType = light.type; + if (lightType == HDLightType.Point || lightType == HDLightType.Spot) + punctualShadowAtlas.ScheduleShadowUpdate(light); + else if (lightType == HDLightType.Area) + areaShadowAtlas.ScheduleShadowUpdate(light); + else if (lightType == HDLightType.Directional) + { + MarkAllDirectionalShadowsForUpdate(); + } + } + + internal void ScheduleShadowUpdate(HDAdditionalLightData light, int subShadowIndex) + { + var lightType = light.type; + if (lightType == HDLightType.Spot) + punctualShadowAtlas.ScheduleShadowUpdate(light); + if (lightType == HDLightType.Area) + areaShadowAtlas.ScheduleShadowUpdate(light); + if (lightType == HDLightType.Point) + { + Debug.Assert(subShadowIndex < 6); + punctualShadowAtlas.ScheduleShadowUpdate(light.lightIdxForCachedShadows + subShadowIndex); + } + if (lightType == HDLightType.Directional) + { + Debug.Assert(subShadowIndex < m_MaxShadowCascades); + m_DirectionalShadowPendingUpdate[subShadowIndex] = true; + } + } + + internal bool LightIsPendingPlacement(HDAdditionalLightData light, ShadowMapType shadowMapType) + { + if (shadowMapType == ShadowMapType.PunctualAtlas) + return punctualShadowAtlas.LightIsPendingPlacement(light); + if (shadowMapType == ShadowMapType.AreaLightAtlas) + return areaShadowAtlas.LightIsPendingPlacement(light); + + return false; + } + + internal void ClearShadowRequests() + { + punctualShadowAtlas.Clear(); + if (ShaderConfig.s_AreaLights == 1) + areaShadowAtlas.Clear(); + } + + internal void Dispose() + { + punctualShadowAtlas.Release(); + if (ShaderConfig.s_AreaLights == 1) + areaShadowAtlas.Release(); + } + } +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowManager.cs.meta b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowManager.cs.meta new file mode 100644 index 00000000000..a589a9254dc --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDCachedShadowManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fa1ac5557d2a7d24ab8433d01dd9998f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDDynamicShadowAtlas.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDDynamicShadowAtlas.cs new file mode 100644 index 00000000000..67f95deea0f --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDDynamicShadowAtlas.cs @@ -0,0 +1,174 @@ +using System; +using System.Collections.Generic; +using UnityEngine.Experimental.Rendering; + +namespace UnityEngine.Rendering.HighDefinition +{ + partial class HDDynamicShadowAtlas : HDShadowAtlas + { + readonly List m_ShadowResolutionRequests = new List(); + + float m_RcpScaleFactor = 1; + HDShadowResolutionRequest[] m_SortedRequestsCache; + + public HDDynamicShadowAtlas(RenderPipelineResources renderPipelineResources, int width, int height, int atlasShaderID, Material clearMaterial, int maxShadowRequests, HDShadowInitParameters initParams, BlurAlgorithm blurAlgorithm = BlurAlgorithm.None, FilterMode filterMode = FilterMode.Bilinear, DepthBits depthBufferBits = DepthBits.Depth16, RenderTextureFormat format = RenderTextureFormat.Shadowmap, string name = "") + : base(renderPipelineResources, width, height, atlasShaderID, clearMaterial, maxShadowRequests, initParams, blurAlgorithm, filterMode, depthBufferBits, format, name) + { + m_SortedRequestsCache = new HDShadowResolutionRequest[Mathf.CeilToInt(maxShadowRequests)]; + } + + + internal void ReserveResolution(HDShadowResolutionRequest shadowRequest) + { + m_ShadowResolutionRequests.Add(shadowRequest); + } + + // Stable (unlike List.Sort) sorting algorithm which, unlike Linq's, doesn't use JIT (lol). + // Sorts in place. Very efficient (O(n)) for already sorted data. + void InsertionSort(HDShadowResolutionRequest[] array, int startIndex, int lastIndex) + { + int i = startIndex + 1; + + while (i < lastIndex) + { + var curr = array[i]; + + int j = i - 1; + + // Sort in descending order. + while ((j >= 0) && ((curr.resolution.x > array[j].resolution.x) || + (curr.resolution.y > array[j].resolution.y))) + { + array[j + 1] = array[j]; + j--; + } + + array[j + 1] = curr; + i++; + } + } + + private bool AtlasLayout(bool allowResize, HDShadowResolutionRequest[] fullShadowList, int requestsCount) + { + float curX = 0, curY = 0, curH = 0, xMax = width, yMax = height; + m_RcpScaleFactor = 1; + for (int i = 0; i < requestsCount; ++i) + { + var shadowRequest = fullShadowList[i]; + // shadow atlas layouting + Rect viewport = new Rect(Vector2.zero, shadowRequest.resolution); + curH = Mathf.Max(curH, viewport.height); + + if (curX + viewport.width > xMax) + { + curX = 0; + curY += curH; + curH = viewport.height; + } + if (curY + curH > yMax) + { + if (allowResize) + { + LayoutResize(); + return true; + } + + return false; + } + viewport.x = curX; + viewport.y = curY; + shadowRequest.atlasViewport = viewport; + shadowRequest.resolution = viewport.size; + curX += viewport.width; + } + + return true; + } + + internal bool Layout(bool allowResize = true) + { + int n = (m_ShadowResolutionRequests != null) ? m_ShadowResolutionRequests.Count : 0; + int i = 0; + for (; i < m_ShadowResolutionRequests.Count; ++i) + { + m_SortedRequestsCache[i] = m_ShadowResolutionRequests[i]; + } + + InsertionSort(m_SortedRequestsCache, 0, i); + + return AtlasLayout(allowResize, m_SortedRequestsCache, requestsCount: i); + } + + void LayoutResize() + { + int index = 0; + float currentX = 0; + float currentY = 0; + float currentMaxY = 0; + float currentMaxX = 0; + + // Place shadows in a square shape + while (index < m_ShadowResolutionRequests.Count) + { + float y = 0; + float currentMaxXCache = currentMaxX; + do + { + Rect r = new Rect(Vector2.zero, m_ShadowResolutionRequests[index].resolution); + r.x = currentMaxX; + r.y = y; + y += r.height; + currentY = Mathf.Max(currentY, y); + currentMaxXCache = Mathf.Max(currentMaxXCache, currentMaxX + r.width); + m_ShadowResolutionRequests[index].atlasViewport = r; + index++; + } while (y < currentMaxY && index < m_ShadowResolutionRequests.Count); + currentMaxY = Mathf.Max(currentMaxY, currentY); + currentMaxX = currentMaxXCache; + if (index >= m_ShadowResolutionRequests.Count) + continue; + float x = 0; + float currentMaxYCache = currentMaxY; + do + { + Rect r = new Rect(Vector2.zero, m_ShadowResolutionRequests[index].resolution); + r.x = x; + r.y = currentMaxY; + x += r.width; + currentX = Mathf.Max(currentX, x); + currentMaxYCache = Mathf.Max(currentMaxYCache, currentMaxY + r.height); + m_ShadowResolutionRequests[index].atlasViewport = r; + index++; + } while (x < currentMaxX && index < m_ShadowResolutionRequests.Count); + currentMaxX = Mathf.Max(currentMaxX, currentX); + currentMaxY = currentMaxYCache; + } + + float maxResolution = Math.Max(currentMaxX, currentMaxY); + Vector4 scale = new Vector4(width / maxResolution, height / maxResolution, width / maxResolution, height / maxResolution); + m_RcpScaleFactor = Mathf.Min(scale.x, scale.y); + + // Scale down every shadow rects to fit with the current atlas size + foreach (var r in m_ShadowResolutionRequests) + { + Vector4 s = new Vector4(r.atlasViewport.x, r.atlasViewport.y, r.atlasViewport.width, r.atlasViewport.height); + Vector4 reScaled = Vector4.Scale(s, scale); + + r.atlasViewport = new Rect(reScaled.x, reScaled.y, reScaled.z, reScaled.w); + r.resolution = r.atlasViewport.size; + } + } + + public void DisplayAtlas(RTHandle atlasTexture, CommandBuffer cmd, Material debugMaterial, Rect atlasViewport, float screenX, float screenY, float screenSizeX, float screenSizeY, float minValue, float maxValue, MaterialPropertyBlock mpb) + { + base.DisplayAtlas(atlasTexture, cmd, debugMaterial, atlasViewport, screenX, screenY, screenSizeX, screenSizeY, minValue, maxValue, mpb, m_RcpScaleFactor); + } + + public override void Clear() + { + base.Clear(); + m_ShadowResolutionRequests.Clear(); + } + } +} + diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDDynamicShadowAtlas.cs.meta b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDDynamicShadowAtlas.cs.meta new file mode 100644 index 00000000000..462d99d9be8 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDDynamicShadowAtlas.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 163a41e10a94f234f833ed7a4fb29a63 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl index d52b1c8d43f..09a6f0ea95c 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl @@ -7,15 +7,15 @@ // Keep in sync with both HDShadowManager::GetDirectionalShadowAlgorithm() and GetPunctualFilterWidthInTexels() in C# as well! #ifdef SHADOW_LOW -#define PUNCTUAL_FILTER_ALGORITHM(sd, posSS, posTC, tex, samp, bias) SampleShadow_PCF_Tent_3x3(_ShadowAtlasSize.zwxy, posTC, tex, samp, bias) +#define PUNCTUAL_FILTER_ALGORITHM(sd, posSS, posTC, tex, samp, bias) SampleShadow_PCF_Tent_3x3(sd.isInCachedAtlas ? _CachedShadowAtlasSize.zwxy : _ShadowAtlasSize.zwxy, posTC, tex, samp, bias) #define DIRECTIONAL_FILTER_ALGORITHM(sd, posSS, posTC, tex, samp, bias) SampleShadow_PCF_Tent_5x5(_CascadeShadowAtlasSize.zwxy, posTC, tex, samp, bias) #elif defined(SHADOW_MEDIUM) -#define PUNCTUAL_FILTER_ALGORITHM(sd, posSS, posTC, tex, samp, bias) SampleShadow_PCF_Tent_5x5(_ShadowAtlasSize.zwxy, posTC, tex, samp, bias) +#define PUNCTUAL_FILTER_ALGORITHM(sd, posSS, posTC, tex, samp, bias) SampleShadow_PCF_Tent_5x5(sd.isInCachedAtlas ? _CachedShadowAtlasSize.zwxy : _ShadowAtlasSize.zwxy, posTC, tex, samp, bias) #define DIRECTIONAL_FILTER_ALGORITHM(sd, posSS, posTC, tex, samp, bias) SampleShadow_PCF_Tent_7x7(_CascadeShadowAtlasSize.zwxy, posTC, tex, samp, bias) // Note: currently quality settings for PCSS need to be expose in UI and is control in HDLightUI.cs file IsShadowSettings #elif defined(SHADOW_HIGH) -#define PUNCTUAL_FILTER_ALGORITHM(sd, posSS, posTC, tex, samp, bias) SampleShadow_PCSS(posTC, posSS, sd.shadowMapSize.xy * _ShadowAtlasSize.zw, sd.atlasOffset, sd.shadowFilterParams0.x, sd.shadowFilterParams0.w, asint(sd.shadowFilterParams0.y), asint(sd.shadowFilterParams0.z), tex, samp, s_point_clamp_sampler, bias, sd.zBufferParam, true) -#define DIRECTIONAL_FILTER_ALGORITHM(sd, posSS, posTC, tex, samp, bias) SampleShadow_PCSS(posTC, posSS, sd.shadowMapSize.xy * _CascadeShadowAtlasSize.zw, sd.atlasOffset, sd.shadowFilterParams0.x, sd.shadowFilterParams0.w, asint(sd.shadowFilterParams0.y), asint(sd.shadowFilterParams0.z), tex, samp, s_point_clamp_sampler, bias, sd.zBufferParam, false) +#define PUNCTUAL_FILTER_ALGORITHM(sd, posSS, posTC, tex, samp, bias) SampleShadow_PCSS(posTC, posSS, sd.shadowMapSize.xy * (sd.isInCachedAtlas ? _CachedShadowAtlasSize.zw : _ShadowAtlasSize.zw), sd.atlasOffset, sd.shadowFilterParams0.x, sd.shadowFilterParams0.w, asint(sd.shadowFilterParams0.y), asint(sd.shadowFilterParams0.z), tex, samp, s_point_clamp_sampler, bias, sd.zBufferParam, true, (sd.isInCachedAtlas ? _CachedShadowAtlasSize.xz : _ShadowAtlasSize.xz)) +#define DIRECTIONAL_FILTER_ALGORITHM(sd, posSS, posTC, tex, samp, bias) SampleShadow_PCSS(posTC, posSS, sd.shadowMapSize.xy * _CascadeShadowAtlasSize.zw, sd.atlasOffset, sd.shadowFilterParams0.x, sd.shadowFilterParams0.w, asint(sd.shadowFilterParams0.y), asint(sd.shadowFilterParams0.z), tex, samp, s_point_clamp_sampler, bias, sd.zBufferParam, false, _CascadeShadowAtlasSize.xz) #endif #ifndef PUNCTUAL_FILTER_ALGORITHM @@ -122,16 +122,17 @@ float3 EvalShadow_NormalBias(float worldTexelSize, float normalBias, float3 norm // float EvalShadow_PunctualDepth(HDShadowData sd, Texture2D tex, SamplerComparisonState samp, float2 positionSS, float3 positionWS, float3 normalWS, float3 L, float L_dist, bool perspective) { + float2 texelSize = sd.isInCachedAtlas ? _CachedShadowAtlasSize.zw : _ShadowAtlasSize.zw; positionWS = positionWS + sd.cacheTranslationDelta.xyz; /* bias the world position */ float worldTexelSize = EvalShadow_WorldTexelSize(sd.worldTexelSize, L_dist, true); float3 normalBias = EvalShadow_NormalBias(worldTexelSize, sd.normalBias, normalWS); positionWS += normalBias; /* get shadowmap texcoords */ - float3 posTC = EvalShadow_GetTexcoordsAtlas(sd, _ShadowAtlasSize.zw, positionWS, perspective); + float3 posTC = EvalShadow_GetTexcoordsAtlas(sd, texelSize, positionWS, perspective); /* sample the texture */ // We need to do the check on min/max coordinates because if the shadow spot angle is smaller than the actual cone, then we could have artifacts due to the clamp sampler. - float2 maxCoord = (sd.shadowMapSize.xy - 0.5f) * _ShadowAtlasSize.zw + sd.atlasOffset; + float2 maxCoord = (sd.shadowMapSize.xy - 0.5f) * texelSize + sd.atlasOffset; float2 minCoord = sd.atlasOffset; return any(posTC.xy > maxCoord || posTC.xy < minCoord) ? 1.0f : PUNCTUAL_FILTER_ALGORITHM(sd, positionSS, posTC, tex, samp, FIXED_UNIFORM_BIAS); } @@ -141,14 +142,16 @@ float EvalShadow_PunctualDepth(HDShadowData sd, Texture2D tex, SamplerComparison // float EvalShadow_AreaDepth(HDShadowData sd, Texture2D tex, float2 positionSS, float3 positionWS, float3 normalWS, float3 L, float L_dist, bool perspective) { + float2 texelSize = sd.isInCachedAtlas ? _CachedAreaShadowAtlasSize.zw : _AreaShadowAtlasSize.zw; + positionWS = positionWS + sd.cacheTranslationDelta.xyz; /* get shadowmap texcoords */ - float3 posTC = EvalShadow_GetTexcoordsAtlas(sd, _AreaShadowAtlasSize.zw, positionWS, perspective); + float3 posTC = EvalShadow_GetTexcoordsAtlas(sd, texelSize, positionWS, perspective); int blurPassesScale = (1 + min(4, sd.shadowFilterParams0.w) * 4.0f);// This is needed as blurring might cause some leaks. It might be overclipping, but empirically is a good value. - float2 maxCoord = (sd.shadowMapSize.xy - 0.5f * blurPassesScale) * _AreaShadowAtlasSize.zw + sd.atlasOffset; - float2 minCoord = sd.atlasOffset + _AreaShadowAtlasSize.zw * blurPassesScale; + float2 maxCoord = (sd.shadowMapSize.xy - 0.5f * blurPassesScale) * texelSize + sd.atlasOffset; + float2 minCoord = sd.atlasOffset + texelSize * blurPassesScale; if (any(posTC.xy > maxCoord || posTC.xy < minCoord)) { @@ -307,8 +310,10 @@ float EvalShadow_CascadedDepth_Dither(HDShadowContext shadowContext, Texture2D t // TODO: optimize this using LinearEyeDepth() to avoid having to pass the shadowToWorld matrix float EvalShadow_SampleClosestDistance_Punctual(HDShadowData sd, Texture2D tex, SamplerState sampl, float3 positionWS, float3 L, float3 lightPositionWS) { + float2 texelSize = sd.isInCachedAtlas ? _CachedShadowAtlasSize.zw : _ShadowAtlasSize.zw; + float4 closestNDC = { 0,0,0,1 }; - float2 texelIdx = EvalShadow_GetTexcoordsAtlas(sd, _ShadowAtlasSize.zw, positionWS, closestNDC.xy, true); + float2 texelIdx = EvalShadow_GetTexcoordsAtlas(sd, texelSize, positionWS, closestNDC.xy, true); // sample the shadow map closestNDC.z = SAMPLE_TEXTURE2D_LOD(tex, sampl, texelIdx, 0).x; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAtlas.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAtlas.cs index 2a747077acd..38ceccc8740 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAtlas.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAtlas.cs @@ -4,28 +4,24 @@ namespace UnityEngine.Rendering.HighDefinition { - partial class HDShadowAtlas + abstract partial class HDShadowAtlas { public enum BlurAlgorithm - { + { None, EVSM, // exponential variance shadow maps IM // Improved Moment shadow maps } public RTHandle renderTarget { get { return m_Atlas; } } - readonly List m_ShadowResolutionRequests = new List(); readonly List m_ShadowRequests = new List(); - readonly List m_ListOfCachedShadowRequests = new List(); - public int width { get; private set; } public int height { get; private set; } RTHandle m_Atlas; Material m_ClearMaterial; LightingDebugSettings m_LightingDebugSettings; - float m_RcpScaleFactor = 1; FilterMode m_FilterMode; DepthBits m_DepthBufferBits; RenderTextureFormat m_Format; @@ -38,20 +34,10 @@ public enum BlurAlgorithm RTHandle[] m_AtlasMoments = null; RTHandle m_IntermediateSummedAreaTexture; RTHandle m_SummedAreaTexture; - HDShadowResolutionRequest[] m_SortedRequestsCache; - - - public int frameOfCacheValidity { get; private set; } - public int atlasShapeID { get; private set; } - // TODO: This whole caching system needs to be refactored. At the moment there is lots of unecessary data being copied often. - HDShadowResolutionRequest[] m_CachedResolutionRequests; - int m_CachedResolutionRequestsCounter = 0; + public HDShadowAtlas() { } - bool m_HasResizedAtlas = false; - int frameCounter = 0; - - public HDShadowAtlas(RenderPipelineResources renderPipelineResources, int width, int height, int atlasShaderID, Material clearMaterial, int maxShadowRequests, BlurAlgorithm blurAlgorithm = BlurAlgorithm.None, FilterMode filterMode = FilterMode.Bilinear, DepthBits depthBufferBits = DepthBits.Depth16, RenderTextureFormat format = RenderTextureFormat.Shadowmap, string name = "") + public virtual void InitAtlas(RenderPipelineResources renderPipelineResources, int width, int height, int atlasShaderID, Material clearMaterial, int maxShadowRequests, HDShadowInitParameters initParams, BlurAlgorithm blurAlgorithm = BlurAlgorithm.None, FilterMode filterMode = FilterMode.Bilinear, DepthBits depthBufferBits = DepthBits.Depth16, RenderTextureFormat format = RenderTextureFormat.Shadowmap, string name = "") { this.width = width; this.height = height; @@ -64,16 +50,14 @@ public HDShadowAtlas(RenderPipelineResources renderPipelineResources, int width, m_BlurAlgorithm = blurAlgorithm; m_RenderPipelineResources = renderPipelineResources; - m_SortedRequestsCache = new HDShadowResolutionRequest[Mathf.CeilToInt(maxShadowRequests*1.5f)]; - m_CachedResolutionRequests = new HDShadowResolutionRequest[maxShadowRequests]; - for(int i=0; i= 0) && ((curr.resolution.x > array[j].resolution.x) || - (curr.resolution.y > array[j].resolution.y))) - { - array[j + 1] = array[j]; - j--; - } - - array[j + 1] = curr; - i++; - } - } - - internal HDShadowResolutionRequest GetCachedRequest(int cachedIndex) - { - if (cachedIndex < 0 || cachedIndex >= m_ListOfCachedShadowRequests.Count) - return null; - - return m_ListOfCachedShadowRequests[cachedIndex]; - } - - internal bool HasResizedThisFrame() - { - return m_HasResizedAtlas; - } - - internal void MarkCulledShadowMapAsEmptySlots() - { - for(int i=0; i 0) - { - m_ListOfCachedShadowRequests[i].emptyRequest = true; - } - } - - frameCounter++; - } - - internal void PruneDeadCachedLightSlots() - { - m_ListOfCachedShadowRequests.RemoveAll(x => (x.emptyRequest)); - frameOfCacheValidity = 0; // Invalidate cached data. - } - - internal void MarkCachedShadowSlotAsEmpty(int lightID) - { - var subList = m_ListOfCachedShadowRequests.FindAll(x => x.lightID == lightID); - for (int i = 0; i < subList.Count; ++i) - { - subList[i].emptyRequest = true; - } - } - - internal int RegisterCachedLight(HDShadowResolutionRequest request) - { - - // Since we are starting caching light resolution requests, it means that data cached from now on will be valid. - frameOfCacheValidity++; - - // If it is already registered, we do nothing. - int shadowIndex = -1; - for(int i=0; i< m_ListOfCachedShadowRequests.Count; ++i) - { - if(!m_ListOfCachedShadowRequests[i].emptyRequest && m_ListOfCachedShadowRequests[i].lightID == request.lightID && m_ListOfCachedShadowRequests[i].indexInLight == request.indexInLight) - { - shadowIndex = i; - break; - } - } - - if (shadowIndex == -1) - { - // First we search if we have a hole we can fill with it. - float resolutionOfNewLight = request.atlasViewport.width; - request.lastFrameActive = frameCounter; - - int holeWithRightSize = -1; - for (int i = 0; i < m_ListOfCachedShadowRequests.Count; ++i) - { - var currReq = m_ListOfCachedShadowRequests[i]; - if (currReq.emptyRequest && // Is empty - request.atlasViewport.width <= currReq.atlasViewport.width && // fits the request - (currReq.atlasViewport.width - request.atlasViewport.width) <= currReq.atlasViewport.width * 0.1f) // but is not much smaller. - { - holeWithRightSize = i; - break; - } - } - - if (holeWithRightSize >= 0) - { - m_ListOfCachedShadowRequests[holeWithRightSize] = request.ShallowCopy(); - return holeWithRightSize; - } - else - { - - // We need to resort the list, so we use the occasion to reset the pool. This feels suboptimal, but it is the easiest way to comply with the pooling system. - // TODO: Make this cleaner and more efficient. - m_CachedResolutionRequestsCounter = 0; - for (int i=0; i xMax) - { - curX = 0; - curY += curH; - curH = viewport.height; - } - if (curY + curH > yMax) - { - if(enteredWithPrunedCachedList) - { - // We need to resize. We invalidate the data and clear stored list of cached. - frameOfCacheValidity = 0; - m_ListOfCachedShadowRequests.Clear(); - // Since we emptied the cached list, we can start from scratch in the pool - m_CachedResolutionRequestsCounter = 0; - - if (allowResize) - { - LayoutResize(); - m_HasResizedAtlas = true; - return true; - } - - return false; - } - else - { - // We can still prune - PruneDeadCachedLightSlots(); - // Remove cached slots from the currently sorted list (instead of rebuilding it). - // Since it is ordered, the order post deletion is guaranteed. - int newIndex = 0; - for(int j=0; j= m_ShadowResolutionRequests.Count) - continue; - float x = 0; - float currentMaxYCache = currentMaxY; - do - { - Rect r = new Rect(Vector2.zero, m_ShadowResolutionRequests[index].resolution); - r.x = x; - r.y = currentMaxY; - x += r.width; - currentX = Mathf.Max(currentX, x); - currentMaxYCache = Mathf.Max(currentMaxYCache, currentMaxY + r.height); - m_ShadowResolutionRequests[index].atlasViewport = r; - index++; - } while (x < currentMaxX && index < m_ShadowResolutionRequests.Count); - currentMaxX = Mathf.Max(currentMaxX, currentX); - currentMaxY = currentMaxYCache; - } - - float maxResolution = Math.Max(currentMaxX, currentMaxY); - Vector4 scale = new Vector4(width / maxResolution, height / maxResolution, width / maxResolution, height / maxResolution); - m_RcpScaleFactor = Mathf.Min(scale.x, scale.y); - - // Scale down every shadow rects to fit with the current atlas size - foreach (var r in m_ShadowResolutionRequests) - { - Vector4 s = new Vector4(r.atlasViewport.x, r.atlasViewport.y, r.atlasViewport.width, r.atlasViewport.height); - Vector4 reScaled = Vector4.Scale(s, scale); - - r.atlasViewport = new Rect(reScaled.x, reScaled.y, reScaled.z, reScaled.w); - r.resolution = r.atlasViewport.size; - } - - atlasShapeID++; - } - public void RenderShadows(CullingResults cullResults, in ShaderVariablesGlobal globalCB, FrameSettings frameSettings, ScriptableRenderContext renderContext, CommandBuffer cmd) { if (m_ShadowRequests.Count == 0) @@ -578,6 +256,9 @@ unsafe static void EVSMBlurMoments( RenderShadowsParameters parameters, int requestIdx = 0; foreach (var shadowRequest in parameters.shadowRequests) { + if (shadowRequest.shouldUseCachedShadow) + continue; + using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RenderEVSMShadowMapsBlur))) { int downsampledWidth = Mathf.CeilToInt(shadowRequest.atlasViewport.width * 0.5f); @@ -699,7 +380,7 @@ static void IMBlurMoment( RenderShadowsParameters parameters, } } - public void DisplayAtlas(RTHandle atlasTexture, CommandBuffer cmd, Material debugMaterial, Rect atlasViewport, float screenX, float screenY, float screenSizeX, float screenSizeY, float minValue, float maxValue, MaterialPropertyBlock mpb) + public virtual void DisplayAtlas(RTHandle atlasTexture, CommandBuffer cmd, Material debugMaterial, Rect atlasViewport, float screenX, float screenY, float screenSizeX, float screenSizeY, float minValue, float maxValue, MaterialPropertyBlock mpb, float scaleFactor = 1) { if (atlasTexture == null) return; @@ -712,14 +393,13 @@ public void DisplayAtlas(RTHandle atlasTexture, CommandBuffer cmd, Material debu mpb.SetTexture("_AtlasTexture", atlasTexture); mpb.SetVector("_TextureScaleBias", scaleBias); mpb.SetVector("_ValidRange", validRange); - mpb.SetFloat("_RcpGlobalScaleFactor", m_RcpScaleFactor); + mpb.SetFloat("_RcpGlobalScaleFactor", scaleFactor); cmd.SetViewport(new Rect(screenX, screenY, screenSizeX, screenSizeY)); cmd.DrawProcedural(Matrix4x4.identity, debugMaterial, debugMaterial.FindPass("RegularShadow"), MeshTopology.Triangles, 3, 1, mpb); } - public void Clear() + public virtual void Clear() { - m_ShadowResolutionRequests.Clear(); m_ShadowRequests.Clear(); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl index 3dfe1536d2a..fa5b99b316e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl @@ -18,8 +18,10 @@ struct HDShadowContext #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl" TEXTURE2D(_ShadowmapAtlas); +TEXTURE2D(_CachedShadowmapAtlas); TEXTURE2D(_ShadowmapCascadeAtlas); TEXTURE2D(_ShadowmapAreaAtlas); +TEXTURE2D(_CachedAreaLightShadowmapAtlas); StructuredBuffer _HDShadowDatas; // Only the first element is used since we only support one directional light diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs index 52738760492..b63a145def5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.RenderGraph.cs @@ -6,8 +6,10 @@ namespace UnityEngine.Rendering.HighDefinition internal struct ShadowResult { public TextureHandle punctualShadowResult; + public TextureHandle cachedPunctualShadowResult; public TextureHandle directionalShadowResult; public TextureHandle areaShadowResult; + public TextureHandle cachedAreaShadowResult; } partial class HDShadowManager @@ -22,6 +24,10 @@ internal static ShadowResult ReadShadowResult(in ShadowResult shadowResult, Rend result.directionalShadowResult = builder.ReadTexture(shadowResult.directionalShadowResult); if (shadowResult.areaShadowResult.IsValid()) result.areaShadowResult = builder.ReadTexture(shadowResult.areaShadowResult); + if (shadowResult.cachedPunctualShadowResult.IsValid()) + result.cachedPunctualShadowResult = builder.ReadTexture(shadowResult.cachedPunctualShadowResult); + if (shadowResult.cachedAreaShadowResult.IsValid()) + result.cachedAreaShadowResult = builder.ReadTexture(shadowResult.cachedAreaShadowResult); return result; } @@ -35,6 +41,8 @@ internal ShadowResult RenderShadows(RenderGraph renderGraph, in ShaderVariablesG result.punctualShadowResult = m_Atlas.RenderShadows(renderGraph, cullResults, globalCB, hdCamera.frameSettings, "Punctual Lights Shadows rendering"); result.directionalShadowResult = m_CascadeAtlas.RenderShadows(renderGraph, cullResults, globalCB, hdCamera.frameSettings, "Directional Light Shadows rendering"); result.areaShadowResult = m_AreaLightShadowAtlas.RenderShadows(renderGraph, cullResults, globalCB, hdCamera.frameSettings, "Area Light Shadows rendering"); + result.cachedPunctualShadowResult = cachedShadowManager.punctualShadowAtlas.RenderShadows(renderGraph, cullResults, globalCB, hdCamera.frameSettings, "Cached Punctual Lights Shadows rendering"); + result.cachedAreaShadowResult = cachedShadowManager.areaShadowAtlas.RenderShadows(renderGraph, cullResults, globalCB, hdCamera.frameSettings, "Cached Area Lights Shadows rendering"); } // TODO RENDERGRAPH diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs index ef50ee78de8..1410120178f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs @@ -33,7 +33,7 @@ struct HDShadowData public Vector4 shadowFilterParams0; public Vector3 cacheTranslationDelta; - public float _pad0; + public float isInCachedAtlas; public Matrix4x4 shadowToWorld; } @@ -101,6 +101,8 @@ class HDShadowRequest public bool shouldUseCachedShadow = false; public HDShadowData cachedShadowData; + + public bool isInCachedAtlas; } enum DirectionalShadowAlgorithm @@ -158,6 +160,8 @@ internal static HDShadowAtlasInitParams GetDefault() directionalShadowsDepthBits = k_DefaultShadowMapDepthBits, punctualLightShadowAtlas = HDShadowAtlasInitParams.GetDefault(), areaLightShadowAtlas = HDShadowAtlasInitParams.GetDefault(), + cachedPunctualLightShadowAtlas = 2048, + cachedAreaLightShadowAtlas = 1024, shadowResolutionDirectional = new IntScalableSetting(new []{ 256, 512, 1024, 2048 }, ScalableSettingSchemaId.With4Levels), shadowResolutionArea = new IntScalableSetting(new []{ 256, 512, 1024, 2048 }, ScalableSettingSchemaId.With4Levels), shadowResolutionPunctual = new IntScalableSetting(new []{ 256, 512, 1024, 2048 }, ScalableSettingSchemaId.With4Levels), @@ -189,6 +193,12 @@ internal static HDShadowAtlasInitParams GetDefault() /// Initialization parameters for area shadows atlas. public HDShadowAtlasInitParams areaLightShadowAtlas; + /// Resolution for the punctual lights cached shadow maps atlas. + public int cachedPunctualLightShadowAtlas; + + /// Resolution for the area lights cached shadow maps atlas. + public int cachedAreaLightShadowAtlas; + /// Shadow scalable resolution for directional lights. public IntScalableSetting shadowResolutionDirectional; /// Shadow scalable resolution for point lights. @@ -217,13 +227,6 @@ class HDShadowResolutionRequest public Vector2 resolution; public ShadowMapType shadowMapType; - /* Data for cached shadows */ - public int lightID; - public int indexInLight = 0; - public int lastFrameActive = 0; - public bool emptyRequest = false; - public bool hasBeenStoredInCachedList = false; - public HDShadowResolutionRequest ShallowCopy() { return (HDShadowResolutionRequest)this.MemberwiseClone(); @@ -248,9 +251,9 @@ partial class HDShadowManager : IDisposable ComputeBuffer m_DirectionalShadowDataBuffer; // The two shadowmaps atlases we uses, one for directional cascade (without resize) and the second for the rest of the shadows - HDShadowAtlas m_CascadeAtlas; - HDShadowAtlas m_Atlas; - HDShadowAtlas m_AreaLightShadowAtlas; + HDDynamicShadowAtlas m_CascadeAtlas; + HDDynamicShadowAtlas m_Atlas; + HDDynamicShadowAtlas m_AreaLightShadowAtlas; int m_MaxShadowRequests; int m_ShadowRequestCount; @@ -262,40 +265,48 @@ partial class HDShadowManager : IDisposable private static HDShadowManager s_Instance = new HDShadowManager(); public static HDShadowManager instance { get { return s_Instance; } } + public static HDCachedShadowManager cachedShadowManager { get { return HDCachedShadowManager.instance; } } private HDShadowManager() {} - public void InitShadowManager(RenderPipelineResources renderPipelineResources, DepthBits directionalShadowDepthBits, - HDShadowInitParameters.HDShadowAtlasInitParams punctualLightAtlasInfo, HDShadowInitParameters.HDShadowAtlasInitParams areaLightAtlasInfo, int maxShadowRequests, Shader clearShader) + public void InitShadowManager(RenderPipelineResources renderPipelineResources, HDShadowInitParameters initParams, Shader clearShader) { m_ClearShadowMaterial = CoreUtils.CreateEngineMaterial(clearShader); // Prevent the list from resizing their internal container when we add shadow requests - m_ShadowDatas.Capacity = Math.Max(maxShadowRequests, m_ShadowDatas.Capacity); - m_ShadowResolutionRequests = new HDShadowResolutionRequest[maxShadowRequests]; - m_ShadowRequests = new HDShadowRequest[maxShadowRequests]; + m_ShadowDatas.Capacity = Math.Max(initParams.maxShadowRequests, m_ShadowDatas.Capacity); + m_ShadowResolutionRequests = new HDShadowResolutionRequest[initParams.maxShadowRequests]; + m_ShadowRequests = new HDShadowRequest[initParams.maxShadowRequests]; m_CachedDirectionalShadowData = new HDDirectionalShadowData[1]; // we only support directional light shadow - for (int i = 0; i < maxShadowRequests; i++) + for (int i = 0; i < initParams.maxShadowRequests; i++) { m_ShadowResolutionRequests[i] = new HDShadowResolutionRequest(); } // The cascade atlas will be allocated only if there is a directional light - m_Atlas = new HDShadowAtlas(renderPipelineResources, punctualLightAtlasInfo.shadowAtlasResolution, punctualLightAtlasInfo.shadowAtlasResolution, HDShaderIDs._ShadowmapAtlas, m_ClearShadowMaterial, maxShadowRequests, depthBufferBits: punctualLightAtlasInfo.shadowAtlasDepthBits, name: "Shadow Map Atlas"); + m_Atlas = new HDDynamicShadowAtlas(renderPipelineResources, initParams.punctualLightShadowAtlas.shadowAtlasResolution, initParams.punctualLightShadowAtlas.shadowAtlasResolution, + HDShaderIDs._ShadowmapAtlas, m_ClearShadowMaterial, initParams.maxShadowRequests, initParams, depthBufferBits: initParams.punctualLightShadowAtlas.shadowAtlasDepthBits, name: "Shadow Map Atlas"); // Cascade atlas render texture will only be allocated if there is a shadow casting directional light HDShadowAtlas.BlurAlgorithm cascadeBlur = GetDirectionalShadowAlgorithm() == DirectionalShadowAlgorithm.IMS ? HDShadowAtlas.BlurAlgorithm.IM : HDShadowAtlas.BlurAlgorithm.None; - m_CascadeAtlas = new HDShadowAtlas(renderPipelineResources, 1, 1, HDShaderIDs._ShadowmapCascadeAtlas, m_ClearShadowMaterial, maxShadowRequests, cascadeBlur, depthBufferBits: directionalShadowDepthBits, name: "Cascade Shadow Map Atlas"); + m_CascadeAtlas = new HDDynamicShadowAtlas(renderPipelineResources, 1, 1, HDShaderIDs._ShadowmapCascadeAtlas, m_ClearShadowMaterial, initParams.maxShadowRequests, initParams, cascadeBlur, depthBufferBits: initParams.directionalShadowsDepthBits, name: "Cascade Shadow Map Atlas"); if (ShaderConfig.s_AreaLights == 1) - m_AreaLightShadowAtlas = new HDShadowAtlas(renderPipelineResources, areaLightAtlasInfo.shadowAtlasResolution, areaLightAtlasInfo.shadowAtlasResolution, HDShaderIDs._ShadowmapAreaAtlas, m_ClearShadowMaterial, maxShadowRequests, HDShadowAtlas.BlurAlgorithm.EVSM, depthBufferBits: areaLightAtlasInfo.shadowAtlasDepthBits, name: "Area Light Shadow Map Atlas"); + m_AreaLightShadowAtlas = new HDDynamicShadowAtlas(renderPipelineResources, initParams.areaLightShadowAtlas.shadowAtlasResolution, initParams.areaLightShadowAtlas.shadowAtlasResolution, + HDShaderIDs._ShadowmapAreaAtlas, m_ClearShadowMaterial, initParams.maxShadowRequests, initParams, HDShadowAtlas.BlurAlgorithm.EVSM, depthBufferBits: initParams.areaLightShadowAtlas.shadowAtlasDepthBits, name: "Area Light Shadow Map Atlas"); - m_ShadowDataBuffer = new ComputeBuffer(maxShadowRequests, System.Runtime.InteropServices.Marshal.SizeOf(typeof(HDShadowData))); + m_ShadowDataBuffer = new ComputeBuffer(initParams.maxShadowRequests, System.Runtime.InteropServices.Marshal.SizeOf(typeof(HDShadowData))); m_DirectionalShadowDataBuffer = new ComputeBuffer(1, System.Runtime.InteropServices.Marshal.SizeOf(typeof(HDDirectionalShadowData))); - m_MaxShadowRequests = maxShadowRequests; + m_MaxShadowRequests = initParams.maxShadowRequests; + + cachedShadowManager.InitPunctualShadowAtlas(renderPipelineResources, initParams.cachedPunctualLightShadowAtlas, initParams.cachedPunctualLightShadowAtlas, + HDShaderIDs._CachedShadowmapAtlas, m_ClearShadowMaterial, initParams.maxShadowRequests, initParams: initParams, depthBufferBits: initParams.punctualLightShadowAtlas.shadowAtlasDepthBits, name: "Cached Shadow Map Atlas"); + if (ShaderConfig.s_AreaLights == 1) + cachedShadowManager.InitAreaLightShadowAtlas(renderPipelineResources, initParams.cachedAreaLightShadowAtlas, initParams.cachedAreaLightShadowAtlas, + HDShaderIDs._CachedAreaLightShadowmapAtlas, m_ClearShadowMaterial, initParams.maxShadowRequests, initParams: initParams, HDShadowAtlas.BlurAlgorithm.EVSM, depthBufferBits: initParams.areaLightShadowAtlas.shadowAtlasDepthBits, name: "Cached Area Light Shadow Map Atlas"); } public void InitializeNonRenderGraphResources() @@ -340,8 +351,12 @@ public void UpdateShaderVariablesGlobalCB(ref ShaderVariablesGlobal cb) cb._CascadeShadowCount = (uint)(m_CascadeCount + 1); cb._ShadowAtlasSize = new Vector4(m_Atlas.width, m_Atlas.height, 1.0f / m_Atlas.width, 1.0f / m_Atlas.height); cb._CascadeShadowAtlasSize = new Vector4(m_CascadeAtlas.width, m_CascadeAtlas.height, 1.0f / m_CascadeAtlas.width, 1.0f / m_CascadeAtlas.height); + cb._CachedShadowAtlasSize = new Vector4(cachedShadowManager.punctualShadowAtlas.width, cachedShadowManager.punctualShadowAtlas.height, 1.0f / cachedShadowManager.punctualShadowAtlas.width, 1.0f / cachedShadowManager.punctualShadowAtlas.height); if (ShaderConfig.s_AreaLights == 1) + { cb._AreaShadowAtlasSize = new Vector4(m_AreaLightShadowAtlas.width, m_AreaLightShadowAtlas.height, 1.0f / m_AreaLightShadowAtlas.width, 1.0f / m_AreaLightShadowAtlas.height); + cb._CachedAreaShadowAtlasSize = new Vector4(cachedShadowManager.areaShadowAtlas.width, cachedShadowManager.areaShadowAtlas.height, 1.0f / cachedShadowManager.areaShadowAtlas.width, 1.0f / cachedShadowManager.areaShadowAtlas.height); + } } public void UpdateDirectionalShadowResolution(int resolution, int cascadeCount) @@ -356,161 +371,53 @@ public void UpdateDirectionalShadowResolution(int resolution, int cascadeCount) m_CascadeAtlas.UpdateSize(atlasResolution); } - internal int ReserveShadowResolutions(Vector2 resolution, ShadowMapType shadowMapType, int lightID, int index, bool canBeCached, out int cachedRequestIdx) + internal int ReserveShadowResolutions(Vector2 resolution, ShadowMapType shadowMapType, int lightID, int index, bool isDynamicShadow) { - cachedRequestIdx = -1; if (m_ShadowRequestCount >= m_MaxShadowRequests) { Debug.LogWarning("Max shadow requests count reached, dropping all exceeding requests. You can increase this limit by changing the max requests in the HDRP asset"); return -1; } - int cachedIndex = -1; - - m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].resolution = resolution; m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].shadowMapType = shadowMapType; - m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].lightID = lightID; - m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].emptyRequest = false; - m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].indexInLight = index; - m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].atlasViewport.width = resolution.x; - m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].atlasViewport.height = resolution.y; - if (canBeCached) - { - m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].hasBeenStoredInCachedList = true; - } - else - { - m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].hasBeenStoredInCachedList = false; - } - switch (shadowMapType) + // Note: for cached shadows we manage the resolution requests directly on the CachedShadowAtlas as they need special handling. We however keep incrementing the counter for two reasons: + // - Maintain the limit of m_MaxShadowRequests + // - Avoid to refactor other parts that the shadow manager that get requests indices from here. + + if (isDynamicShadow) { - case ShadowMapType.PunctualAtlas: - if(canBeCached) - { - cachedIndex = m_Atlas.RegisterCachedLight(m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter]); - } - m_Atlas.ReserveResolution(m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter]); - break; - case ShadowMapType.AreaLightAtlas: - if(canBeCached) - { - cachedIndex = m_AreaLightShadowAtlas.RegisterCachedLight(m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter]); - } + m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].resolution = resolution; + m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].atlasViewport.width = resolution.x; + m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter].atlasViewport.height = resolution.y; - m_AreaLightShadowAtlas.ReserveResolution(m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter]); - break; - case ShadowMapType.CascadedDirectional: - m_CascadeAtlas.ReserveResolution(m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter]); - break; + switch (shadowMapType) + { + case ShadowMapType.PunctualAtlas: + m_Atlas.ReserveResolution(m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter]); + break; + case ShadowMapType.AreaLightAtlas: + m_AreaLightShadowAtlas.ReserveResolution(m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter]); + break; + case ShadowMapType.CascadedDirectional: + m_CascadeAtlas.ReserveResolution(m_ShadowResolutionRequests[m_ShadowResolutionRequestCounter]); + break; + } } + m_ShadowResolutionRequestCounter++; m_ShadowRequestCount = m_ShadowResolutionRequestCounter; - cachedRequestIdx = cachedIndex; return m_ShadowResolutionRequestCounter - 1; } - internal void MarkCachedShadowSlotsAsEmpty(ShadowMapType shadowMapType, int lightID) - { - switch (shadowMapType) - { - case ShadowMapType.PunctualAtlas: - if(m_Atlas != null) - m_Atlas.MarkCachedShadowSlotAsEmpty(lightID); - break; - case ShadowMapType.AreaLightAtlas: - if (m_AreaLightShadowAtlas != null) - m_AreaLightShadowAtlas.MarkCachedShadowSlotAsEmpty(lightID); - break; - } - } - - internal void CheckForCulledCachedShadows() - { - m_Atlas.MarkCulledShadowMapAsEmptySlots(); - if (ShaderConfig.s_AreaLights == 1) - m_AreaLightShadowAtlas.MarkCulledShadowMapAsEmptySlots(); - } - internal bool CachedDataIsValid(ShadowMapType type) - { - const int thresholdOfValidFrames = 30; - switch (type) - { - case ShadowMapType.PunctualAtlas: - return m_Atlas.frameOfCacheValidity > thresholdOfValidFrames; - case ShadowMapType.AreaLightAtlas: - return m_AreaLightShadowAtlas.frameOfCacheValidity > thresholdOfValidFrames; - } - - return false; - } - - internal void PruneEmptyCachedSlots(ShadowMapType type) + internal HDShadowResolutionRequest GetResolutionRequest(int index) { - switch (type) - { - case ShadowMapType.PunctualAtlas: - if(m_Atlas != null) - m_Atlas.PruneDeadCachedLightSlots(); - break; - case ShadowMapType.AreaLightAtlas: - if (m_AreaLightShadowAtlas != null) - m_AreaLightShadowAtlas.PruneDeadCachedLightSlots(); - break; - default: - break; - } - - } - - internal int GetAtlasShapeID(ShadowMapType type) - { - switch (type) - { - case ShadowMapType.PunctualAtlas: - return m_Atlas.atlasShapeID; - case ShadowMapType.AreaLightAtlas: - return m_AreaLightShadowAtlas.atlasShapeID; - } - return -1; - } - - internal bool AtlasHasResized(ShadowMapType type) - { - switch (type) - { - case ShadowMapType.PunctualAtlas: - return m_Atlas.HasResizedThisFrame(); - case ShadowMapType.AreaLightAtlas: - return m_AreaLightShadowAtlas.HasResizedThisFrame(); - } - - return false; - } - - internal HDShadowResolutionRequest GetResolutionRequest(ShadowMapType type, bool cachedShadow, int index) - { - if(cachedShadow) - { - switch (type) - { - case ShadowMapType.PunctualAtlas: - return m_Atlas.GetCachedRequest(index); - case ShadowMapType.AreaLightAtlas: - return m_AreaLightShadowAtlas.GetCachedRequest(index); - } - } - else - { - if (index < 0 || index >= m_ShadowRequestCount) - return null; - - return m_ShadowResolutionRequests[index]; - } + if (index < 0 || index >= m_ShadowRequestCount) + return null; - return null; + return m_ShadowResolutionRequests[index]; } public Vector2 GetReservedResolution(int index) @@ -521,7 +428,7 @@ public Vector2 GetReservedResolution(int index) return m_ShadowResolutionRequests[index].resolution; } - internal void UpdateShadowRequest(int index, HDShadowRequest shadowRequest) + internal void UpdateShadowRequest(int index, HDShadowRequest shadowRequest, bool isCached = false) { if (index >= m_ShadowRequestCount) return; @@ -532,7 +439,11 @@ internal void UpdateShadowRequest(int index, HDShadowRequest shadowRequest) { case ShadowMapType.PunctualAtlas: { - m_Atlas.AddShadowRequest(shadowRequest); + if (isCached) + cachedShadowManager.punctualShadowAtlas.AddShadowRequest(shadowRequest); + else + m_Atlas.AddShadowRequest(shadowRequest); + break; } case ShadowMapType.CascadedDirectional: @@ -542,7 +453,11 @@ internal void UpdateShadowRequest(int index, HDShadowRequest shadowRequest) } case ShadowMapType.AreaLightAtlas: { - m_AreaLightShadowAtlas.AddShadowRequest(shadowRequest); + if (isCached) + cachedShadowManager.areaShadowAtlas.AddShadowRequest(shadowRequest); + else + m_AreaLightShadowAtlas.AddShadowRequest(shadowRequest); + break; } }; @@ -602,6 +517,8 @@ HDShadowData CreateShadowData(HDShadowRequest shadowRequest, HDShadowAtlas atlas data.shadowFilterParams0 = shadowRequest.evsmParams; } + data.isInCachedAtlas = shadowRequest.isInCachedAtlas ? 1.0f : 0.0f; + return data; } @@ -620,6 +537,8 @@ public void UpdateCullingParameters(ref ScriptableCullingParameters cullingParam public void LayoutShadowMaps(LightingDebugSettings lightingDebugSettings) { + cachedShadowManager.UpdateDebugSettings(lightingDebugSettings); + m_Atlas.UpdateDebugSettings(lightingDebugSettings); if (m_CascadeAtlas != null) @@ -659,6 +578,11 @@ unsafe public void PrepareGPUShadowDatas(CullingResults cullResults, HDCamera ca Debug.Assert(m_ShadowRequests[i] != null); HDShadowAtlas atlas = m_Atlas; + if(m_ShadowRequests[i].isInCachedAtlas) + { + atlas = cachedShadowManager.punctualShadowAtlas; + } + if (m_ShadowRequests[i].shadowMapType == ShadowMapType.CascadedDirectional) { atlas = m_CascadeAtlas; @@ -666,6 +590,10 @@ unsafe public void PrepareGPUShadowDatas(CullingResults cullResults, HDCamera ca else if (m_ShadowRequests[i].shadowMapType == ShadowMapType.AreaLightAtlas) { atlas = m_AreaLightShadowAtlas; + if(m_ShadowRequests[i].isInCachedAtlas) + { + atlas = cachedShadowManager.areaShadowAtlas; + } } HDShadowData shadowData; @@ -722,6 +650,7 @@ public void RenderShadows(ScriptableRenderContext renderContext, CommandBuffer c using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RenderPunctualShadowMaps))) { m_Atlas.RenderShadows(cullResults, globalCB, hdCamera.frameSettings, renderContext, cmd); + cachedShadowManager.punctualShadowAtlas.RenderShadows(cullResults, globalCB, hdCamera.frameSettings, renderContext, cmd); } using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RenderDirectionalShadowMaps))) @@ -732,7 +661,10 @@ public void RenderShadows(ScriptableRenderContext renderContext, CommandBuffer c using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RenderAreaShadowMaps))) { if (ShaderConfig.s_AreaLights == 1) + { m_AreaLightShadowAtlas.RenderShadows(cullResults, globalCB, hdCamera.frameSettings, renderContext, cmd); + cachedShadowManager.areaShadowAtlas.RenderShadows(cullResults, globalCB, hdCamera.frameSettings, renderContext, cmd); + } } } @@ -747,8 +679,12 @@ public void BindResources(CommandBuffer cmd) { m_Atlas.BindResources(cmd); m_CascadeAtlas.BindResources(cmd); + cachedShadowManager.punctualShadowAtlas.BindResources(cmd); if (ShaderConfig.s_AreaLights == 1) + { m_AreaLightShadowAtlas.BindResources(cmd); + cachedShadowManager.areaShadowAtlas.BindResources(cmd); + } } public int GetShadowRequestCount() @@ -764,6 +700,8 @@ public void Clear() if (ShaderConfig.s_AreaLights == 1) m_AreaLightShadowAtlas.Clear(); + cachedShadowManager.ClearShadowRequests(); + m_ShadowResolutionRequestCounter = 0; m_ShadowRequestCount = 0; @@ -775,15 +713,22 @@ public struct ShadowDebugAtlasTextures public RTHandle punctualShadowAtlas; public RTHandle cascadeShadowAtlas; public RTHandle areaShadowAtlas; + + public RTHandle cachedPunctualShadowAtlas; + public RTHandle cachedAreaShadowAtlas; } public ShadowDebugAtlasTextures GetDebugAtlasTextures() { var result = new ShadowDebugAtlasTextures(); if (ShaderConfig.s_AreaLights == 1) + { result.areaShadowAtlas = m_AreaLightShadowAtlas.renderTarget; + result.cachedAreaShadowAtlas = cachedShadowManager.areaShadowAtlas.renderTarget; + } result.punctualShadowAtlas = m_Atlas.renderTarget; result.cascadeShadowAtlas = m_CascadeAtlas.renderTarget; + result.cachedPunctualShadowAtlas = cachedShadowManager.punctualShadowAtlas.renderTarget; return result; } @@ -806,6 +751,17 @@ public void DisplayAreaLightShadowAtlas(RTHandle atlasTexture, CommandBuffer cmd m_AreaLightShadowAtlas.DisplayAtlas(atlasTexture, cmd, debugMaterial, new Rect(0, 0, m_AreaLightShadowAtlas.width, m_AreaLightShadowAtlas.height), screenX, screenY, screenSizeX, screenSizeY, minValue, maxValue, mpb); } + public void DisplayCachedPunctualShadowAtlas(RTHandle atlasTexture, CommandBuffer cmd, Material debugMaterial, float screenX, float screenY, float screenSizeX, float screenSizeY, float minValue, float maxValue, MaterialPropertyBlock mpb) + { + cachedShadowManager.punctualShadowAtlas.DisplayAtlas(atlasTexture, cmd, debugMaterial, new Rect(0, 0, cachedShadowManager.punctualShadowAtlas.width, cachedShadowManager.punctualShadowAtlas.height), screenX, screenY, screenSizeX, screenSizeY, minValue, maxValue, mpb); + } + + public void DisplayCachedAreaShadowAtlas(RTHandle atlasTexture, CommandBuffer cmd, Material debugMaterial, float screenX, float screenY, float screenSizeX, float screenSizeY, float minValue, float maxValue, MaterialPropertyBlock mpb) + { + if (ShaderConfig.s_AreaLights == 1) + cachedShadowManager.areaShadowAtlas.DisplayAtlas(atlasTexture, cmd, debugMaterial, new Rect(0, 0, cachedShadowManager.areaShadowAtlas.width, cachedShadowManager.areaShadowAtlas.height), screenX, screenY, screenSizeX, screenSizeY, minValue, maxValue, mpb); + } + // Warning: must be called after ProcessShadowRequests and RenderShadows to have valid informations public void DisplayShadowMap(in ShadowDebugAtlasTextures atlasTextures, int shadowIndex, CommandBuffer cmd, Material debugMaterial, float screenX, float screenY, float screenSizeX, float screenSizeY, float minValue, float maxValue, MaterialPropertyBlock mpb) { @@ -818,7 +774,10 @@ public void DisplayShadowMap(in ShadowDebugAtlasTextures atlasTextures, int shad { case ShadowMapType.PunctualAtlas: { - m_Atlas.DisplayAtlas(atlasTextures.punctualShadowAtlas, cmd, debugMaterial, shadowRequest.atlasViewport, screenX, screenY, screenSizeX, screenSizeY, minValue, maxValue, mpb); + if (shadowRequest.isInCachedAtlas) + cachedShadowManager.punctualShadowAtlas.DisplayAtlas(atlasTextures.cachedPunctualShadowAtlas, cmd, debugMaterial, shadowRequest.atlasViewport, screenX, screenY, screenSizeX, screenSizeY, minValue, maxValue, mpb); + else + m_Atlas.DisplayAtlas(atlasTextures.punctualShadowAtlas, cmd, debugMaterial, shadowRequest.atlasViewport, screenX, screenY, screenSizeX, screenSizeY, minValue, maxValue, mpb); break; } case ShadowMapType.CascadedDirectional: @@ -829,7 +788,12 @@ public void DisplayShadowMap(in ShadowDebugAtlasTextures atlasTextures, int shad case ShadowMapType.AreaLightAtlas: { if (ShaderConfig.s_AreaLights == 1) - m_AreaLightShadowAtlas.DisplayAtlas(atlasTextures.areaShadowAtlas, cmd, debugMaterial, shadowRequest.atlasViewport, screenX, screenY, screenSizeX, screenSizeY, minValue, maxValue, mpb); + { + if (shadowRequest.isInCachedAtlas) + cachedShadowManager.areaShadowAtlas.DisplayAtlas(atlasTextures.cachedAreaShadowAtlas, cmd, debugMaterial, shadowRequest.atlasViewport, screenX, screenY, screenSizeX, screenSizeY, minValue, maxValue, mpb); + else + m_AreaLightShadowAtlas.DisplayAtlas(atlasTextures.areaShadowAtlas, cmd, debugMaterial, shadowRequest.atlasViewport, screenX, screenY, screenSizeX, screenSizeY, minValue, maxValue, mpb); + } break; } }; @@ -845,6 +809,7 @@ public void Dispose() m_CascadeAtlas.Release(); CoreUtils.Destroy(m_ClearShadowMaterial); + cachedShadowManager.Dispose(); } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs.hlsl index 42dac6b10b9..43c6844777e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs.hlsl @@ -20,7 +20,7 @@ struct HDShadowData float4 shadowMapSize; real4 shadowFilterParams0; float3 cacheTranslationDelta; - float _pad0; + float isInCachedAtlas; float4x4 shadowToWorld; }; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSampling.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSampling.hlsl index aac441d7899..f360bcde710 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSampling.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowSampling.hlsl @@ -266,7 +266,8 @@ float SampleShadow_MSM_1tap(float3 tcs, float lightLeakBias, float momentBias, f // // PCSS sampling // -float SampleShadow_PCSS(float3 tcs, float2 posSS, float2 scale, float2 offset, float shadowSoftness, float minFilterRadius, int blockerSampleCount, int filterSampleCount, Texture2D tex, SamplerComparisonState compSamp, SamplerState samp, float depthBias, float4 zParams, bool isPerspective) +// Note shadowAtlasInfo contains: x: resolution, y: the inverse of atlas resolution +float SampleShadow_PCSS(float3 tcs, float2 posSS, float2 scale, float2 offset, float shadowSoftness, float minFilterRadius, int blockerSampleCount, int filterSampleCount, Texture2D tex, SamplerComparisonState compSamp, SamplerState samp, float depthBias, float4 zParams, bool isPerspective, float2 shadowAtlasInfo) { #if SHADOW_USE_DEPTH_BIAS == 1 // add the depth bias @@ -277,8 +278,6 @@ float SampleShadow_PCSS(float3 tcs, float2 posSS, float2 scale, float2 offset, f float sampleJitterAngle = InterleavedGradientNoise(posSS.xy, taaFrameIndex) * 2.0 * PI; float2 sampleJitter = float2(sin(sampleJitterAngle), cos(sampleJitterAngle)); - // x contains resolution and y the inverse of atlas resolution - float2 shadowAtlasInfo = isPerspective ? _ShadowAtlasSize.xz : _CascadeShadowAtlasSize.xz; // Note: this is a hack, but the original implementation was faulty as it didn't scale offset based on the resolution of the atlas (*not* the shadow map). // All the softness fitting has been done using a reference 4096x4096, hence the following scale. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.cs index eaafd5edd74..7c3280d4d4f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.cs @@ -467,7 +467,7 @@ internal void DestroyVolumetricLightingBuffers() CoreUtils.SafeRelease(m_VisibleVolumeDataBuffer); CoreUtils.SafeRelease(m_VisibleVolumeBoundsBuffer); - m_VisibleVolumeData = null; // free() + m_VisibleVolumeData = null; // free() m_VisibleVolumeBounds = null; // free() } @@ -493,7 +493,7 @@ internal void ResizeVolumetricLightingBuffers(HDCamera hdCamera, int frameIndex) var currentParams = hdCamera.vBufferParams[currIdx]; - ResizeVolumetricBuffer(ref m_DensityBuffer, "VBufferDensity", currentParams.viewportSize.x, + ResizeVolumetricBuffer(ref m_DensityBuffer, "VBufferDensity", currentParams.viewportSize.x, currentParams.viewportSize.y, currentParams.viewportSize.z); ResizeVolumetricBuffer(ref m_LightingBuffer, "VBufferLighting", currentParams.viewportSize.x, diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Exposure.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Exposure.cs index 0007c9c6076..7c942954e1e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Exposure.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Exposure.cs @@ -86,11 +86,25 @@ public sealed class Exposure : VolumeComponent, IPostProcessComponent public MinFloatParameter adaptationSpeedLightToDark = new MinFloatParameter(1f, 0.001f); /// - /// Sets the texture mask used to weight the pixels in the buffer when computing exposure. Used only with . + /// Sets the texture mask used to weight the pixels in the buffer when computing exposure. /// - [Tooltip("Sets the texture mask to be used to weight the pixels in the buffer for the sake of computing exposure..")] + [Tooltip("Sets the texture mask to be used to weight the pixels in the buffer for the sake of computing exposure.")] public NoInterpTextureParameter weightTextureMask = new NoInterpTextureParameter(null); + /// + /// These values are the lower and upper percentages of the histogram that will be used to + /// find a stable average luminance. Values outside of this range will be discarded and won't + /// contribute to the average luminance. + /// + [Tooltip("Sets the range of values (in terms of percentages) of the histogram that are accepted while finding a stable average exposure. Anything outside the value is discarded.")] + public FloatRangeParameter histogramPercentages = new FloatRangeParameter(new Vector2(40.0f, 90.0f), 0.0f, 100.0f); + + /// + /// Sets whether histogram exposure mode will remap the computed exposure with a curve remapping (akin to Curve Remapping mode) + /// + [Tooltip("Sets whether histogram exposure mode will remap the computed exposure with a curve remapping (akin to Curve Remapping mode).")] + public BoolParameter histogramUseCurveRemapping = new BoolParameter(false); + /// /// Tells if the effect needs to be rendered or not. /// @@ -117,6 +131,11 @@ public enum ExposureMode /// Automatic, + /// + /// Automatically sets the exposure depending on what is on screen and can filter out outliers based on provided settings. + /// + AutomaticHistogram, + /// /// Maps the current Scene exposure to a custom curve. /// diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs index b103590431d..ef60f9e25e3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs @@ -6,6 +6,7 @@ namespace UnityEngine.Rendering.HighDefinition /// Available tonemapping modes. /// /// + [GenerateHLSL] public enum TonemappingMode { /// diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs.hlsl new file mode 100644 index 00000000000..01a14dbe92d --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs.hlsl @@ -0,0 +1,17 @@ +// +// This file was automatically generated. Please don't edit by hand. +// + +#ifndef TONEMAPPING_CS_HLSL +#define TONEMAPPING_CS_HLSL +// +// UnityEngine.Rendering.HighDefinition.TonemappingMode: static fields +// +#define TONEMAPPINGMODE_NONE (0) +#define TONEMAPPINGMODE_NEUTRAL (1) +#define TONEMAPPINGMODE_ACES (2) +#define TONEMAPPINGMODE_CUSTOM (3) +#define TONEMAPPINGMODE_EXTERNAL (4) + + +#endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs.hlsl.meta new file mode 100644 index 00000000000..dbc46634e4a --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Components/Tonemapping.cs.hlsl.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 3716aaa9cab64e5419f00d48a69fab04 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs index 5b55edea50a..692f3918445 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.RenderGraph.cs @@ -5,9 +5,9 @@ namespace UnityEngine.Rendering.HighDefinition { partial class PostProcessSystem { - public void Render( RenderGraph renderGraph, - HDCamera hdCamera, - BlueNoise blueNoise, + public void Render( RenderGraph renderGraph, + HDCamera hdCamera, + BlueNoise blueNoise, TextureHandle colorBuffer, TextureHandle afterPostProcessTexture, TextureHandle depthBuffer, diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs index af115aa692b..dd7ce91f082 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/PostProcessSystem.cs @@ -34,11 +34,15 @@ private enum SMAAStage // Exposure data const int k_ExposureCurvePrecision = 128; + const int k_HistogramBins = 128; // Important! If this changes, need to change HistogramExposure.compute readonly Color[] m_ExposureCurveColorArray = new Color[k_ExposureCurvePrecision]; readonly int[] m_ExposureVariants = new int[4]; Texture2D m_ExposureCurveTexture; RTHandle m_EmptyExposureTexture; // RGHalf + RTHandle m_DebugExposureData; + ComputeBuffer m_HistogramBuffer; + readonly int[] m_EmptyHistogram = new int[k_HistogramBins]; // Depth of field data ComputeBuffer m_BokehNearKernel; @@ -188,6 +192,20 @@ public PostProcessSystem(HDRenderPipelineAsset hdAsset, RenderPipelineResources m_KeepAlpha = hdAsset.currentPlatformRenderPipelineSettings.supportsAlpha; } + // Setup a default exposure textures and clear it to neutral values so that the exposure + // multiplier is 1 and thus has no effect + // Beware that 0 in EV100 maps to a multiplier of 0.833 so the EV100 value in this + // neutral exposure texture isn't 0 + m_EmptyExposureTexture = RTHandles.Alloc(1, 1, colorFormat: k_ExposureFormat, + enableRandomWrite: true, name: "Empty EV100 Exposure"); + + m_DebugExposureData = RTHandles.Alloc(1, 1, colorFormat: k_ExposureFormat, + enableRandomWrite: true, name: "Debug Exposure Info" + ); + + + FillEmptyExposureTexture(); + // Call after initializing m_LutSize and m_KeepAlpha as it's needed for render target allocation. InitializeNonRenderGraphResources(hdAsset); } @@ -196,6 +214,9 @@ public void Cleanup() { CleanupNonRenderGraphResources(); + RTHandles.Release(m_EmptyExposureTexture); + m_EmptyExposureTexture = null; + CoreUtils.Destroy(m_ExposureCurveTexture); CoreUtils.Destroy(m_InternalSpectralLut); CoreUtils.Destroy(m_FinalPassMaterial); @@ -208,6 +229,8 @@ public void Cleanup() CoreUtils.SafeRelease(m_NearBokehTileList); CoreUtils.SafeRelease(m_FarBokehTileList); CoreUtils.SafeRelease(m_ContrastAdaptiveSharpen); + CoreUtils.SafeRelease(m_HistogramBuffer); + RTHandles.Release(m_DebugExposureData); m_ExposureCurveTexture = null; m_InternalSpectralLut = null; @@ -220,6 +243,9 @@ public void Cleanup() m_BokehIndirectCmd = null; m_NearBokehTileList = null; m_FarBokehTileList = null; + m_HistogramBuffer = null; + m_DebugExposureData = null; + } public void InitializeNonRenderGraphResources(HDRenderPipelineAsset hdAsset) @@ -247,16 +273,6 @@ public void InitializeNonRenderGraphResources(HDRenderPipelineAsset hdAsset) enableRandomWrite: true ); - // Setup a default exposure textures and clear it to neutral values so that the exposure - // multiplier is 1 and thus has no effect - // Beware that 0 in EV100 maps to a multiplier of 0.833 so the EV100 value in this - // neutral exposure texture isn't 0 - m_EmptyExposureTexture = RTHandles.Alloc(1, 1, colorFormat: k_ExposureFormat, - enableRandomWrite: true, name: "Empty EV100 Exposure" - ); - - FillEmptyExposureTexture(); - // Misc targets m_TempTexture1024 = RTHandles.Alloc( 1024, 1024, colorFormat: GraphicsFormat.R16G16_SFloat, @@ -283,30 +299,30 @@ public void CleanupNonRenderGraphResources() m_Pool.Cleanup(); - RTHandles.Release(m_EmptyExposureTexture); RTHandles.Release(m_TempTexture1024); RTHandles.Release(m_TempTexture32); RTHandles.Release(m_AlphaTexture); RTHandles.Release(m_InternalLogLut); - m_EmptyExposureTexture = null; m_TempTexture1024 = null; m_TempTexture32 = null; m_AlphaTexture = null; m_InternalLogLut = null; } + // In some cases, the internal buffer of render textures might be invalid. // Usually when using these textures with API such as SetRenderTarget, they are recreated internally. // This is not the case when these textures are used exclusively with Compute Shaders. So to make sure they work in this case, we recreate them here. void CheckRenderTexturesValidity() { - if (!m_NonRenderGraphResourcesAvailable) - return; - if (!m_EmptyExposureTexture.rt.IsCreated()) FillEmptyExposureTexture(); + if (!m_NonRenderGraphResourcesAvailable) + return; + + HDUtils.CheckRTCreated(m_DebugExposureData.rt); HDUtils.CheckRTCreated(m_InternalLogLut.rt); HDUtils.CheckRTCreated(m_TempTexture1024.rt); HDUtils.CheckRTCreated(m_TempTexture32.rt); @@ -479,7 +495,14 @@ void PoolSource(ref RTHandle src, RTHandle dst) { using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.DynamicExposure))) { - DoDynamicExposure(cmd, camera, source); + if (m_Exposure.mode.value == ExposureMode.AutomaticHistogram) + { + DoHistogramBasedExposure(cmd, camera, source); + } + else + { + DoDynamicExposure(cmd, camera, source); + } // On reset history we need to apply dynamic exposure immediately to avoid // white or black screen flashes when the current exposure isn't anywhere @@ -796,6 +819,26 @@ public RTHandle GetPreviousExposureTexture(HDCamera camera) return rt ?? m_EmptyExposureTexture; } + internal RTHandle GetExposureDebugData() + { + return m_DebugExposureData; + } + + internal HableCurve GetCustomToneMapCurve() + { + return m_HableCurve; + } + + internal int GetLutSize() + { + return m_LutSize; + } + + internal ComputeBuffer GetHistogramBuffer() + { + return m_HistogramBuffer; + } + void DoFixedExposure(CommandBuffer cmd, HDCamera camera) { var cs = m_Resources.shaders.exposureCS; @@ -874,12 +917,9 @@ void PrepareExposureCurveData(AnimationCurve curve, out float min, out float max m_ExposureCurveTexture.Apply(); } - void DoDynamicExposure(CommandBuffer cmd, HDCamera camera, RTHandle colorBuffer) + void DynamicExposureSetup(CommandBuffer cmd, HDCamera camera, out RTHandle prevExposure, out RTHandle nextExposure) { - var cs = m_Resources.shaders.exposureCS; - int kernel; - - GrabExposureHistoryTextures(camera, out var prevExposure, out var nextExposure); + GrabExposureHistoryTextures(camera, out prevExposure, out nextExposure); // Setup variants var adaptationMode = m_Exposure.adaptationMode.value; @@ -898,6 +938,14 @@ void DoDynamicExposure(CommandBuffer cmd, HDCamera camera, RTHandle colorBuffer) m_ExposureVariants[1] = (int)m_Exposure.meteringMode.value; m_ExposureVariants[2] = (int)adaptationMode; m_ExposureVariants[3] = 0; + } + + void DoDynamicExposure(CommandBuffer cmd, HDCamera camera, RTHandle colorBuffer) + { + var cs = m_Resources.shaders.exposureCS; + int kernel; + + DynamicExposureSetup(cmd, camera, out var prevExposure, out var nextExposure); var sourceTex = colorBuffer; @@ -935,6 +983,8 @@ void DoDynamicExposure(CommandBuffer cmd, HDCamera camera, RTHandle colorBuffer) PrepareExposureCurveData(m_Exposure.curveMap.value, out float min, out float max); cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._ExposureCurveTexture, m_ExposureCurveTexture); cmd.SetComputeVectorParam(cs, HDShaderIDs._ExposureParams, new Vector4(m_Exposure.compensation.value + m_DebugExposureCompensation, min, max, 0f)); + cmd.SetComputeVectorParam(cs, HDShaderIDs._ExposureParams2, new Vector4(min, max, 0f, 0f)); + m_ExposureVariants[3] = 2; } @@ -946,6 +996,75 @@ void DoDynamicExposure(CommandBuffer cmd, HDCamera camera, RTHandle colorBuffer) cmd.DispatchCompute(cs, kernel, 1, 1, 1); } + void DoHistogramBasedExposure(CommandBuffer cmd, HDCamera camera, RTHandle sourceTexture) + { + var cs = m_Resources.shaders.histogramExposureCS; + cs.shaderKeywords = null; + int kernel; + + DynamicExposureSetup(cmd, camera, out var prevExposure, out var nextExposure); + // Parameters + Vector2 histogramFraction = m_Exposure.histogramPercentages.value / 100.0f; + float evRange = m_Exposure.limitMax.value - m_Exposure.limitMin.value; + float histScale = 1.0f / Mathf.Max(1e-5f, evRange); + float histBias = -m_Exposure.limitMin.value * histScale; + Vector4 histogramParams = new Vector4(histScale, histBias, histogramFraction.x, histogramFraction.y); + + ValidateComputeBuffer(ref m_HistogramBuffer, k_HistogramBins, sizeof(uint)); + m_HistogramBuffer.SetData(m_EmptyHistogram); // Clear the histogram + cmd.SetComputeVectorParam(cs, HDShaderIDs._HistogramExposureParams, histogramParams); + + // Generate histogram. + kernel = cs.FindKernel("KHistogramGen"); + cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._PreviousExposureTexture, prevExposure); + cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._SourceTexture, sourceTexture); + if (m_Exposure.meteringMode == MeteringMode.MaskWeighted && m_Exposure.weightTextureMask.value != null) + { + cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._ExposureWeightMask, m_Exposure.weightTextureMask.value); + } + else + { + cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._ExposureWeightMask, Texture2D.whiteTexture); + } + + cmd.SetComputeIntParams(cs, HDShaderIDs._Variants, m_ExposureVariants); + + cmd.SetComputeBufferParam(cs, kernel, HDShaderIDs._HistogramBuffer, m_HistogramBuffer); + + int threadGroupSizeX = 16; + int threadGroupSizeY = 8; + int dispatchSizeX = HDUtils.DivRoundUp(camera.actualWidth / 2, threadGroupSizeX); + int dispatchSizeY = HDUtils.DivRoundUp(camera.actualHeight / 2, threadGroupSizeY); + int totalPixels = camera.actualWidth * camera.actualHeight; + cmd.DispatchCompute(cs, kernel, dispatchSizeX, dispatchSizeY, 1); + + // Now read the histogram + kernel = cs.FindKernel("KHistogramReduce"); + cmd.SetComputeVectorParam(cs, HDShaderIDs._ExposureParams, new Vector4(m_Exposure.compensation.value + m_DebugExposureCompensation, m_Exposure.limitMin.value, m_Exposure.limitMax.value, 0f)); + cmd.SetComputeVectorParam(cs, HDShaderIDs._AdaptationParams, new Vector4(m_Exposure.adaptationSpeedLightToDark.value, m_Exposure.adaptationSpeedDarkToLight.value, 0f, 0f)); + cmd.SetComputeBufferParam(cs, kernel, HDShaderIDs._HistogramBuffer, m_HistogramBuffer); + cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._PreviousExposureTexture, prevExposure); + cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._OutputTexture, nextExposure); + + cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._ExposureCurveTexture, m_ExposureCurveTexture); + m_ExposureVariants[3] = 0; + if (m_Exposure.histogramUseCurveRemapping.value) + { + PrepareExposureCurveData(m_Exposure.curveMap.value, out float min, out float max); + cmd.SetComputeVectorParam(cs, HDShaderIDs._ExposureParams2, new Vector4(min, max, 0f, 0f)); + m_ExposureVariants[3] = 2; + } + cmd.SetComputeIntParams(cs, HDShaderIDs._Variants, m_ExposureVariants); + + if (m_HDInstance.m_CurrentDebugDisplaySettings.data.lightingDebugSettings.exposureDebugMode == ExposureDebugMode.HistogramView) + { + cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._ExposureDebugTexture, m_DebugExposureData); + cs.EnableKeyword("OUTPUT_DEBUG_DATA"); + } + + cmd.DispatchCompute(cs, kernel, 1, 1, 1); + } + #endregion #region Temporal Anti-aliasing diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/Exposure.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/Exposure.compute index 24bb51c8249..4e53910f142 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/Exposure.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/Exposure.compute @@ -1,7 +1,4 @@ -#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" -#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" -#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/PhysicalCamera.hlsl" -#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ExposureCommon.hlsl" #pragma only_renderers d3d11 playstation xboxone vulkan metal switch @@ -11,99 +8,11 @@ #pragma kernel KReduction #pragma kernel KReset -TEXTURE2D(_ExposureCurveTexture); -TEXTURE2D(_PreviousExposureTexture); TEXTURE2D(_InputTexture); -TEXTURE2D(_ExposureWeightMask); - -TEXTURE2D_X(_SourceTexture); - -RW_TEXTURE2D(float2, _OutputTexture); - -SAMPLER(sampler_LinearClamp); - -CBUFFER_START(cb) - float4 _ExposureParams; - float4 _AdaptationParams; - uint4 _Variants; -CBUFFER_END - -#define ParamEV100 _ExposureParams.y -#define ParamExposureCompensation _ExposureParams.x -#define ParamAperture _ExposureParams.y -#define ParamShutterSpeed _ExposureParams.z -#define ParamISO _ExposureParams.w -#define ParamSpeedLightToDark _AdaptationParams.x -#define ParamSpeedDarkToLight _AdaptationParams.y -#define ParamExposureLimitMin _ExposureParams.y -#define ParamExposureLimitMax _ExposureParams.z -#define ParamCurveMin _ExposureParams.y -#define ParamCurveMax _ExposureParams.z -#define ParamSourceBuffer _Variants.x -#define ParamMeteringMode _Variants.y -#define ParamAdaptationMode _Variants.z -#define ParamEvaluateMode _Variants.w - #define PREPASS_TEX_SIZE 1024.0 #define PREPASS_TEX_HALF_SIZE 512.0 -float WeightSample(uint2 pixel) -{ - UNITY_BRANCH - switch (ParamMeteringMode) - { - case 1u: - { - // Spot metering - const float kRadius = 0.075 * PREPASS_TEX_SIZE; - const float2 kCenter = (PREPASS_TEX_HALF_SIZE).xx; - float d = length(kCenter - pixel) - kRadius; - return 1.0 - saturate(d); - } - case 2u: - { - // Center-weighted - const float2 kCenter = (PREPASS_TEX_HALF_SIZE).xx; - return 1.0 - saturate(pow(length(kCenter - pixel) / PREPASS_TEX_HALF_SIZE, 1.0)); - } - case 3u: - { - // Mask weigthing - return SAMPLE_TEXTURE2D_LOD(_ExposureWeightMask, sampler_LinearClamp, pixel * rcp(PREPASS_TEX_SIZE), 0.0).x; - } - - default: - { - // Global average - return 1.0; - } - } -} - -float GetPreviousExposureEV100() -{ - return _PreviousExposureTexture[uint2(0u, 0u)].y; -} - -float AdaptExposure(float exposure) -{ - UNITY_BRANCH - switch (ParamAdaptationMode) - { - case 1u: - { - // Progressive - return ComputeLuminanceAdaptation(GetPreviousExposureEV100(), exposure, ParamSpeedDarkToLight, ParamSpeedLightToDark, unity_DeltaTime.x); - } - default: - { - // Fixed - return exposure; - } - } -} - // // Fixed exposure // Doesn't do anything fancy, simply copies the exposure & clamp values set in the volume system @@ -140,28 +49,10 @@ void KPrePass(uint2 dispatchThreadId : SV_DispatchThreadID) PositionInputs posInputs = GetPositionInput(float2(dispatchThreadId), rcp(PREPASS_TEX_SIZE), uint2(8u, 8u)); float2 uv = ClampAndScaleUVForBilinear(posInputs.positionNDC); - float luma; + float luma = SampleLuminance(uv); - UNITY_BRANCH - switch (ParamSourceBuffer) - { - case 1u: - { - // Color buffer - float prevExposure = ConvertEV100ToExposure(GetPreviousExposureEV100()); - float3 color = SAMPLE_TEXTURE2D_X_LOD(_SourceTexture, sampler_LinearClamp, uv, 0.0).xyz; - luma = Luminance(color / prevExposure); - break; - } - default: - { - // Lighting buffer - luma = 1.0; - break; - } - } + float weight = WeightSample(dispatchThreadId, PREPASS_TEX_SIZE.xx); - float weight = WeightSample(dispatchThreadId); float logLuma = ComputeEV100FromAvgLuminance(max(luma, 1e-4)); _OutputTexture[posInputs.positionSS] = float2(logLuma, weight); } @@ -235,8 +126,7 @@ void KReduction(uint2 groupId : SV_GroupID, uint2 groupThreadId : SV_GroupThread case 2u: { // Curve remapping - float remap = saturate((avgLuminance - ParamCurveMin) / (ParamCurveMax - ParamCurveMin)); - float exposure = SAMPLE_TEXTURE2D_LOD(_ExposureCurveTexture, sampler_LinearClamp, float2(remap, 0.0), 0.0).x; + float exposure = CurveRemap(avgLuminance); exposure = AdaptExposure(exposure - ParamExposureCompensation); _OutputTexture[groupId.xy] = float2(ConvertEV100ToExposure(exposure), exposure); break; diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ExposureCommon.hlsl b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ExposureCommon.hlsl new file mode 100644 index 00000000000..f12efaea4f9 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ExposureCommon.hlsl @@ -0,0 +1,108 @@ +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" +#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/PhysicalCamera.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" + + +TEXTURE2D(_ExposureWeightMask); +TEXTURE2D_X(_SourceTexture); +TEXTURE2D(_PreviousExposureTexture); +RW_TEXTURE2D(float2, _OutputTexture); +TEXTURE2D(_ExposureCurveTexture); + +CBUFFER_START(cb) +float4 _ExposureParams; +float4 _ExposureParams2; +float4 _HistogramExposureParams; +float4 _AdaptationParams; +uint4 _Variants; +CBUFFER_END + +#define ParamEV100 _ExposureParams.y +#define ParamExposureCompensation _ExposureParams.x +#define ParamAperture _ExposureParams.y +#define ParamShutterSpeed _ExposureParams.z +#define ParamISO _ExposureParams.w +#define ParamSpeedLightToDark _AdaptationParams.x +#define ParamSpeedDarkToLight _AdaptationParams.y +#define ParamExposureLimitMin _ExposureParams.y +#define ParamExposureLimitMax _ExposureParams.z +#define ParamCurveMin _ExposureParams2.x +#define ParamCurveMax _ExposureParams2.y +#define ParamSourceBuffer _Variants.x +#define ParamMeteringMode _Variants.y +#define ParamAdaptationMode _Variants.z +#define ParamEvaluateMode _Variants.w + +float GetPreviousExposureEV100() +{ + return _PreviousExposureTexture[uint2(0u, 0u)].y; +} + +float WeightSample(uint2 pixel, float2 sourceSize) +{ + UNITY_BRANCH + switch (ParamMeteringMode) + { + case 1u: + { + // Spot metering + float screenDiagonal = 0.5f * (sourceSize.x + sourceSize.y); + const float kRadius = 0.075 * screenDiagonal; + const float2 kCenter = sourceSize * 0.5f; + float d = length(kCenter - pixel) - kRadius; + return 1.0 - saturate(d); + } + case 2u: + { + // Center-weighted + float screenDiagonal = 0.5f * (sourceSize.x + sourceSize.y); + const float2 kCenter = sourceSize * 0.5f; + return 1.0 - saturate(pow(length(kCenter - pixel) / screenDiagonal, 1.0)); + } + case 3u: + { + // Mask weigthing + return SAMPLE_TEXTURE2D_LOD(_ExposureWeightMask, s_linear_clamp_sampler, pixel * rcp(sourceSize), 0.0).x; + } + + default: + { + // Global average + return 1.0; + } + } +} + +float SampleLuminance(float2 uv) +{ + if (ParamSourceBuffer == 1) + { + // Color buffer + float prevExposure = ConvertEV100ToExposure(GetPreviousExposureEV100()); + float3 color = SAMPLE_TEXTURE2D_X_LOD(_SourceTexture, s_linear_clamp_sampler, uv, 0.0).xyz; + return Luminance(color / prevExposure); + } + else + { + return 1.0f; + } +} + +float AdaptExposure(float exposure) +{ + if (ParamAdaptationMode == 1) + { + return ComputeLuminanceAdaptation(GetPreviousExposureEV100(), exposure, ParamSpeedDarkToLight, ParamSpeedLightToDark, unity_DeltaTime.x); + } + else + { + return exposure; + } +} + +float CurveRemap(float inEV) +{ + float remap = saturate((inEV - ParamCurveMin) / (ParamCurveMax - ParamCurveMin)); + return SAMPLE_TEXTURE2D_LOD(_ExposureCurveTexture, s_linear_clamp_sampler, float2(remap, 0.0), 0.0).x; +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ExposureCommon.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ExposureCommon.hlsl.meta new file mode 100644 index 00000000000..fd95688bcc3 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ExposureCommon.hlsl.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: cb6a39236cce6824cbf70aa0d69f39f6 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute new file mode 100644 index 00000000000..43e5ccbdc54 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute @@ -0,0 +1,183 @@ +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/ExposureCommon.hlsl" +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposureCommon.hlsl" + + +// TODO List to investigate +// - Worth considering multiple histograms per lane in the thread. (i.e. sharedHisto[BINS][NUMB_HIST] ) +// - At the moment the dispatch is at half res, but the buffer sampled is full res, +// causing fairly bad cache behaviour. Can we use the mip chain realistically without issues? [The one we have is blurred and might be incomplete?] + +#pragma kernel KHistogramGen GEN_PASS +#pragma kernel KHistogramReduce REDUCE_PASS +#define GROUP_SIZE_X 16 +#define GROUP_SIZE_Y 8 + +#pragma multi_compile _ OUTPUT_DEBUG_DATA + +// Because atomics are only on uint and we need a weighted value, we need to convert. +// If we multiply the weight by 2048, we get somewhat ok precision and we support up to +// the equivalent of 1920x1080 image in one bin. (Note, we run this at half res, so equivalent of 4k image) +uint PackWeight(float weight) +{ + return uint(weight * 2048); +} + +groupshared uint gs_localHistogram[HISTOGRAM_BINS]; + + +[numthreads(GROUP_SIZE_X, GROUP_SIZE_Y, 1)] +void KHistogramGen(uint groupIndex : SV_GroupIndex, + uint3 dispatchThreadId : SV_DispatchThreadID) +{ + // Groupshared memory is not guaranteed to be 0 initialized. + // Note that currently the branch is always true (GROUP_SIZE_X * GROUP_SIZE_Y == HISTOGRAM_BINS). Here as safeguard if changing group size or bins. + if (groupIndex < HISTOGRAM_BINS) + { + gs_localHistogram[groupIndex] = 0u; + } + + GroupMemoryBarrierWithGroupSync(); + + // TODO: This leads to poor cache behaviour, verify if we can use lower mip of the color pyramid. + uint2 fullResCoords = dispatchThreadId.xy << 1u; + + if (all(fullResCoords < uint2(_ScreenSize.xy))) + { + float2 uv = ClampAndScaleUVForBilinear((fullResCoords + 0.5) * _ScreenSize.zw); + float luminance = SampleLuminance(uv); + float weight = WeightSample(fullResCoords, _ScreenSize.xy); + + uint bin = GetHistogramBinLocation(luminance); + InterlockedAdd(gs_localHistogram[bin], PackWeight(weight)); + } + + GroupMemoryBarrierWithGroupSync(); + + // Note that currently the branch is always true (GROUP_SIZE_X * GROUP_SIZE_Y == HISTOGRAM_BINS). Here as safeguard if changing group size or bins. + if (groupIndex < HISTOGRAM_BINS) + { + InterlockedAdd(_HistogramBuffer[groupIndex], gs_localHistogram[groupIndex]); + } +} + +#define USE_WAVE_INTRINSICS defined(PLATFORM_LANE_COUNT) && defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) + + +#if USE_WAVE_INTRINSICS + +#define WAVE_SIZE PLATFORM_LANE_COUNT +#define SUM_SCRATCH_SIZE HISTOGRAM_BINS / WAVE_SIZE + +#else + +#define SUM_SCRATCH_SIZE HISTOGRAM_BINS + +#endif + +groupshared float gs_partialSums[SUM_SCRATCH_SIZE]; +groupshared float gs_values[HISTOGRAM_BINS]; + +float ComputeTotalSum(uint threadID, float threadVal) +{ + float sum = 0; + +#if USE_WAVE_INTRINSICS + + uint waveCount = (HISTOGRAM_BINS / WAVE_SIZE); + float waveSum = WaveActiveSum(threadVal); + + uint waveIDInGroup = threadID / WAVE_SIZE; + if (WaveIsFirstLane()) + { + gs_partialSums[waveIDInGroup] = waveSum; + } + + // We have values for all the waves, let's sync. + GroupMemoryBarrierWithGroupSync(); + + sum = gs_partialSums[0]; + for (uint i = 1u; i < waveCount; ++i) + { + sum += gs_partialSums[i]; + } + +#else // !USE_WAVE_INTRINSICS + + gs_partialSums[threadID] = threadVal; + + GroupMemoryBarrierWithGroupSync(); + + // Sum all values + for (uint i = HISTOGRAM_BINS >> 1u; i > 0u; i >>= 1u) + { + if (threadID < i) + gs_partialSums[threadID] = (gs_partialSums[threadID] + gs_partialSums[threadID + i]); + + GroupMemoryBarrierWithGroupSync(); + } + + sum = gs_partialSums[0]; + +#endif + + return sum; +} + +void ProcessBin(uint binIndex, inout float2 extremesSums, inout float evSum, inout float totalWeight) +{ + float histVal = gs_values[binIndex]; + float binEV = BinLocationToEV(binIndex); + + // Shadows + float off = min(extremesSums.x, histVal); + extremesSums -= off; + histVal -= off; + // Highlights + histVal = min(extremesSums.y, histVal); + extremesSums.y -= histVal; + + evSum += histVal * binEV; + totalWeight += histVal; +} + +[numthreads(HISTOGRAM_BINS, 1, 1)] +void KHistogramReduce(uint3 dispatchThreadId : SV_DispatchThreadID) +{ + uint threadID = dispatchThreadId.x; + float histogramVal = UnpackWeight(_HistogramBuffer[threadID]); + + gs_values[threadID] = histogramVal; + + float sum = ComputeTotalSum(threadID, histogramVal); + + float2 extremesSums = float2(_HistogramMinPercentile, _HistogramMaxPercentile) * sum; + + // TODO: Can we be a bit more parallel here? + if (threadID == 0) + { + float evProcessedSum = 0; + float w = 0; + + for (int i = 0; i < HISTOGRAM_BINS; ++i) + { + ProcessBin(i, extremesSums, evProcessedSum, w); + } + + w = max(w, 1e-4f); + float avgEV = evProcessedSum * rcp(w); + + if (ParamEvaluateMode == 2) + { + avgEV = CurveRemap(avgEV); + } + + float exposure = AdaptExposure(avgEV - ParamExposureCompensation); + exposure = clamp(exposure, ParamExposureLimitMin, ParamExposureLimitMax); + _OutputTexture[uint2(0, 0)] = float2(ConvertEV100ToExposure(exposure), exposure); +#ifdef OUTPUT_DEBUG_DATA + _ExposureDebugTexture[uint2(0, 0)] = float2(avgEV - ParamExposureCompensation, 0.0f); +#endif + } + + +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute.meta b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute.meta new file mode 100644 index 00000000000..ec4511dfb0c --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposure.compute.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 222da48299136f34b8e3fb75ae9f8ac7 +ComputeShaderImporter: + externalObjects: {} + currentAPIMask: 4 + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposureCommon.hlsl b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposureCommon.hlsl new file mode 100644 index 00000000000..7620df3ec91 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposureCommon.hlsl @@ -0,0 +1,39 @@ + +#define HISTOGRAM_BINS 128 + +#define _HistogramRangeScale _HistogramExposureParams.x +#define _HistogramRangeBias _HistogramExposureParams.y +#define _HistogramMinPercentile _HistogramExposureParams.z +#define _HistogramMaxPercentile _HistogramExposureParams.w + +#ifdef GEN_PASS +RWStructuredBuffer _HistogramBuffer; +#else +StructuredBuffer _HistogramBuffer; +#endif + +#ifdef OUTPUT_DEBUG_DATA +RW_TEXTURE2D(float2, _ExposureDebugTexture); +#else +TEXTURE2D(_ExposureDebugTexture); +#endif + +float UnpackWeight(uint val) +{ + return val * rcp(2048.0f); +} + +float GetFractionWithinHistogram(float value) +{ + return ComputeEV100FromAvgLuminance(value) * _HistogramRangeScale + _HistogramRangeBias; +} + +uint GetHistogramBinLocation(float value) +{ + return uint(saturate(GetFractionWithinHistogram(value)) * (HISTOGRAM_BINS - 1)); +} + +float BinLocationToEV(uint binIdx) +{ + return (binIdx * rcp(float(HISTOGRAM_BINS - 1)) - _HistogramRangeBias) / _HistogramRangeScale; +} diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposureCommon.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposureCommon.hlsl.meta new file mode 100644 index 00000000000..11a0b6748c6 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/HistogramExposureCommon.hlsl.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 8b66a6c34796d04498345e5530eb228c +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntiAliasing.shader b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntiAliasing.shader index f495059c61a..dddee9f8308 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntiAliasing.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntiAliasing.shader @@ -50,6 +50,7 @@ Shader "Hidden/HDRP/TemporalAA" #define CENTRAL_FILTERING NO_FILTERING #define HISTORY_CLIP DIRECT_CLIP #define ANTI_FLICKER 1 + #define ANTI_FLICKER_MV_DEPENDENT 0 #define VELOCITY_REJECTION (defined(ENABLE_MV_REJECTION) && 0) #define PERCEPTUAL_SPACE 1 #define PERCEPTUAL_SPACE_ONLY_END 0 && (PERCEPTUAL_SPACE == 0) @@ -63,6 +64,7 @@ Shader "Hidden/HDRP/TemporalAA" #define CENTRAL_FILTERING BLACKMAN_HARRIS #define HISTORY_CLIP DIRECT_CLIP #define ANTI_FLICKER 1 + #define ANTI_FLICKER_MV_DEPENDENT 1 #define VELOCITY_REJECTION defined(ENABLE_MV_REJECTION) #define PERCEPTUAL_SPACE 1 #define PERCEPTUAL_SPACE_ONLY_END 0 && (PERCEPTUAL_SPACE == 0) @@ -163,7 +165,13 @@ Shader "Hidden/HDRP/TemporalAA" // --------------- Get neighbourhood information and clamp history --------------- float colorLuma = GetLuma(filteredColor); float historyLuma = GetLuma(history); - GetNeighbourhoodCorners(samples, historyLuma, colorLuma, float2(_AntiFlickerIntensity, _ContrastForMaxAntiFlicker)); + +#if ANTI_FLICKER_MV_DEPENDENT || VELOCITY_REJECTION + float motionVectorLength = length(motionVector); +#else + float motionVectorLength = 0.0f; +#endif + GetNeighbourhoodCorners(samples, historyLuma, colorLuma, float2(_AntiFlickerIntensity, _ContrastForMaxAntiFlicker), motionVectorLength); history = GetClippedHistory(filteredColor, history, samples.minNeighbour, samples.maxNeighbour); filteredColor = SharpenColor(samples, filteredColor, sharpenStrength); @@ -189,7 +197,7 @@ Shader "Hidden/HDRP/TemporalAA" // --------------- Blend to final value and output --------------- #if VELOCITY_REJECTION - float lengthMV = length(motionVector) * 10; + float lengthMV = motionVectorLength * 10; blendFactor = ModifyBlendWithMotionVectorRejection(_InputVelocityMagnitudeHistory, lengthMV, prevUV, blendFactor, _SpeedRejectionIntensity); #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl index 0eb2906c180..a55a9af46c5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/TemporalAntialiasing.hlsl @@ -257,7 +257,7 @@ float3 ConvertToOutputSpace(float3 color) // Front most neighbourhood velocity ([Karis 2014]) float2 GetClosestFragment(TEXTURE2D_X(DepthTexture), int2 positionSS) { - float center = LoadCameraDepth(positionSS); + float center = LOAD_TEXTURE2D_X_LOD(DepthTexture, positionSS, 0).r; int2 quadOffset = GetQuadOffset(positionSS); @@ -526,7 +526,7 @@ void MinMaxNeighbourhood(inout NeighbourhoodSamples samples) samples.avgNeighbour *= rcp(NEIGHBOUR_COUNT); } -void VarianceNeighbourhood(inout NeighbourhoodSamples samples, float historyLuma, float colorLuma, float2 antiFlickerParams) +void VarianceNeighbourhood(inout NeighbourhoodSamples samples, float historyLuma, float colorLuma, float2 antiFlickerParams, float motionVectorLen) { CTYPE moment1 = 0; CTYPE moment2 = 0; @@ -552,20 +552,29 @@ void VarianceNeighbourhood(inout NeighbourhoodSamples samples, float historyLuma // and high temporal contrast, we let the history to be closer to be unclipped. To achieve, the min/max bounds // are extended artificially more. #if ANTI_FLICKER - stDevMultiplier = 1.4; + stDevMultiplier = 1.5; float temporalContrast = saturate(abs(colorLuma - historyLuma) / Max3(0.2, colorLuma, historyLuma)); - stDevMultiplier += lerp(0.0, antiFlickerParams.x, smoothstep(0.05, antiFlickerParams.y, temporalContrast)); +#if ANTI_FLICKER_MV_DEPENDENT + const float screenDiag = length(_ScreenSize.xy); + const float maxFactorScale = 2.25f; // when stationary + const float minFactorScale = 0.8f; // when moving more than slightly + float localizedAntiFlicker = lerp(antiFlickerParams.x * minFactorScale, antiFlickerParams.x * maxFactorScale, saturate(1.0f - 2.0f * (motionVectorLen * screenDiag))); +#else + float localizedAntiFlicker = antiFlickerParams.x; +#endif + stDevMultiplier += lerp(0.0, localizedAntiFlicker, smoothstep(0.05, antiFlickerParams.y, temporalContrast)); + #endif samples.minNeighbour = moment1 - stdDev * stDevMultiplier; samples.maxNeighbour = moment1 + stdDev * stDevMultiplier; } -void GetNeighbourhoodCorners(inout NeighbourhoodSamples samples, float historyLuma, float colorLuma, float2 antiFlickerParams) +void GetNeighbourhoodCorners(inout NeighbourhoodSamples samples, float historyLuma, float colorLuma, float2 antiFlickerParams, float motionVecLen) { #if NEIGHBOUROOD_CORNER_METHOD == MINMAX MinMaxNeighbourhood(samples); #else - VarianceNeighbourhood(samples, historyLuma, colorLuma, antiFlickerParams); + VarianceNeighbourhood(samples, historyLuma, colorLuma, antiFlickerParams, motionVecLen); #endif } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs index 81881ecbf12..e77c0825e69 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Camera/HDCamera.cs @@ -746,8 +746,8 @@ internal void ExecuteCaptureActions(RenderGraph renderGraph, TextureHandle input passData.input = builder.ReadTexture(input); // We need to blit to an intermediate texture because input resolution can be bigger than the camera resolution // Since recorder does not know about this, we need to send a texture of the right size. - passData.tempTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(actualWidth, actualHeight) - { colorFormat = inputDesc.colorFormat, name = "TempCaptureActions" })); + passData.tempTexture = builder.CreateTransientTexture(new TextureDesc(actualWidth, actualHeight) + { colorFormat = inputDesc.colorFormat, name = "TempCaptureActions" }); builder.SetRenderFunc( (ExecuteCaptureActionsPassData data, RenderGraphContext ctx) => diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs index 8eda7f371ca..125c2c7d095 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Debug.cs @@ -108,6 +108,8 @@ void RenderDebugOverlays( RenderGraph renderGraph, shadowAtlases.punctualShadowAtlas = data.shadowTextures.punctualShadowResult.IsValid() ? ctx.resources.GetTexture(data.shadowTextures.punctualShadowResult) : null; shadowAtlases.cascadeShadowAtlas = data.shadowTextures.directionalShadowResult.IsValid() ? ctx.resources.GetTexture(data.shadowTextures.directionalShadowResult) : null; shadowAtlases.areaShadowAtlas = data.shadowTextures.areaShadowResult.IsValid() ? ctx.resources.GetTexture(data.shadowTextures.areaShadowResult) : null; + shadowAtlases.cachedPunctualShadowAtlas = data.shadowTextures.cachedPunctualShadowResult.IsValid() ? ctx.resources.GetTexture(data.shadowTextures.cachedPunctualShadowResult) : null; + shadowAtlases.cachedAreaShadowAtlas = data.shadowTextures.cachedAreaShadowResult.IsValid() ? ctx.resources.GetTexture(data.shadowTextures.cachedAreaShadowResult) : null; RenderSkyReflectionOverlay(debugParams, ctx.cmd, ctx.renderGraphPool.GetTempMaterialPropertyBlock(), ref x, ref y, overlaySize); RenderRayCountOverlay(debugParams, ctx.cmd, ref x, ref y, overlaySize); @@ -137,12 +139,12 @@ static void RenderLightVolumes(RenderGraph renderGraph, in DebugParameters debug using (var builder = renderGraph.AddRenderPass("LightVolumes", out var passData)) { passData.parameters = s_lightVolumes.PrepareLightVolumeParameters(debugParameters.hdCamera, debugParameters.debugDisplaySettings.data.lightingDebugSettings, cullResults); - passData.lightCountBuffer = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) - { colorFormat= GraphicsFormat.R32_SFloat, clearBuffer = true, clearColor = Color.black, name = "LightVolumeCount" })); - passData.colorAccumulationBuffer = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) - { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, clearBuffer = true, clearColor = Color.black, name = "LightVolumeColorAccumulation" })); - passData.debugLightVolumesTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) - { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, clearBuffer = true, clearColor = Color.black, enableRandomWrite = true, name = "LightVolumeDebugLightVolumesTexture" })); + passData.lightCountBuffer = builder.CreateTransientTexture(new TextureDesc(Vector2.one, true, true) + { colorFormat= GraphicsFormat.R32_SFloat, clearBuffer = true, clearColor = Color.black, name = "LightVolumeCount" }); + passData.colorAccumulationBuffer = builder.CreateTransientTexture(new TextureDesc(Vector2.one, true, true) + { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, clearBuffer = true, clearColor = Color.black, name = "LightVolumeColorAccumulation" }); + passData.debugLightVolumesTexture = builder.CreateTransientTexture(new TextureDesc(Vector2.one, true, true) + { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, clearBuffer = true, clearColor = Color.black, enableRandomWrite = true, name = "LightVolumeDebugLightVolumesTexture" }); passData.depthBuffer = builder.UseDepthBuffer(depthBuffer, DepthAccess.ReadWrite); passData.destination = builder.WriteTexture(destination); @@ -194,6 +196,14 @@ TextureHandle RenderDebug( RenderGraph renderGraph, m_FullScreenDebugPushed = false; } + // TODO RENDERGRAPH (Needs post processing in Rendergraph to properly be implemented) + if(debugParameters.exposureDebugEnabled) + { + // For reference the following is what is called in the non-render-graph version. + // RenderExposureDebug(debugParams, m_CameraColorBuffer, m_DebugFullScreenTempBuffer,m_PostProcessSystem.GetPreviousExposureTexture(hdCamera), m_PostProcessSystem.GetExposureTexture(hdCamera), + // m_PostProcessSystem.GetExposureDebugData(),m_IntermediateAfterPostProcessBuffer, m_PostProcessSystem.GetCustomToneMapCurve(), m_PostProcessSystem.GetLutSize(), m_PostProcessSystem.GetHistogramBuffer(), cmd); + } + if (debugParameters.colorPickerEnabled) output = ResolveColorPickerDebug(renderGraph, debugParameters, colorPickerDebugTexture); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs index caa18d08333..b17034843db 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs @@ -235,7 +235,7 @@ LightingOutput RenderDeferredLighting( RenderGraph renderGraph, // TODO RENDERGRAPH: Check how to avoid this kind of pattern. // Unfortunately, the low level needs this texture to always be bound with UAV enabled, so in order to avoid effectively creating the full resolution texture here, // we need to create a small dummy texture. - passData.sssDiffuseLightingBuffer = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(1, 1, true, true) { colorFormat = GraphicsFormat.B10G11R11_UFloatPack32, enableRandomWrite = true } )); + passData.sssDiffuseLightingBuffer = builder.CreateTransientTexture(new TextureDesc(1, 1, true, true) { colorFormat = GraphicsFormat.B10G11R11_UFloatPack32, enableRandomWrite = true } ); } passData.depthBuffer = builder.ReadTexture(depthStencilBuffer); passData.depthTexture = builder.ReadTexture(depthPyramidTexture); @@ -274,7 +274,7 @@ LightingOutput RenderDeferredLighting( RenderGraph renderGraph, resources.tileListBuffer = context.resources.GetComputeBuffer(data.tileListBuffer); resources.dispatchIndirectBuffer = context.resources.GetComputeBuffer(data.dispatchIndirectBuffer); - // RENDERGRAPH TODO: try to find a better way to bind this. + // TODO RENDERGRAPH: try to find a better way to bind this. // Issue is that some GBuffers have several names (for example normal buffer is both NormalBuffer and GBuffer1) // So it's not possible to use auto binding via dependency to shaderTagID // Should probably get rid of auto binding and go explicit all the way (might need to wait for us to remove non rendergraph code path). @@ -362,8 +362,8 @@ TextureHandle RenderSSR( RenderGraph renderGraph, // In practice, these textures are sparse (mostly black). Therefore, clearing them is fast (due to CMASK), // and much faster than fully overwriting them from within SSR shaders. - passData.hitPointsTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) - { colorFormat = GraphicsFormat.R16G16_UNorm, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Hit_Point_Texture" })); + passData.hitPointsTexture = builder.CreateTransientTexture(new TextureDesc(Vector2.one, true, true) + { colorFormat = GraphicsFormat.R16G16_UNorm, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Hit_Point_Texture" }); passData.lightingTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R16G16B16A16_SFloat, clearBuffer = true, clearColor = Color.clear, enableRandomWrite = true, name = "SSR_Lighting_Texture" }, HDShaderIDs._SsrLightingTexture)); //passData.hitPointsTexture = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs index ffb4c42da01..c6bafbc3155 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.Prepass.cs @@ -492,7 +492,7 @@ class ResolveStencilPassData public BuildCoarseStencilAndResolveParameters parameters; public TextureHandle inputDepth; public TextureHandle resolvedStencil; - public ComputeBuffer coarseStencilBuffer; + public ComputeBufferHandle coarseStencilBuffer; } void BuildCoarseStencilAndResolveIfNeeded(RenderGraph renderGraph, HDCamera hdCamera, ref PrepassOutput output) @@ -501,8 +501,9 @@ void BuildCoarseStencilAndResolveIfNeeded(RenderGraph renderGraph, HDCamera hdCa { passData.parameters = PrepareBuildCoarseStencilParameters(hdCamera); passData.inputDepth = output.depthBuffer; - passData.coarseStencilBuffer = m_SharedRTManager.GetCoarseStencilBuffer(); - passData.resolvedStencil = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R8G8_UInt, enableRandomWrite = true, name = "StencilBufferResolved" })); + passData.coarseStencilBuffer = builder.WriteComputeBuffer(renderGraph.ImportComputeBuffer(m_SharedRTManager.GetCoarseStencilBuffer())); + if (passData.parameters.resolveIsNecessary) + passData.resolvedStencil = builder.WriteTexture(renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R8G8_UInt, enableRandomWrite = true, name = "StencilBufferResolved" })); builder.SetRenderFunc( (ResolveStencilPassData data, RenderGraphContext context) => { @@ -510,7 +511,7 @@ void BuildCoarseStencilAndResolveIfNeeded(RenderGraph renderGraph, HDCamera hdCa BuildCoarseStencilAndResolveIfNeeded(data.parameters, res.GetTexture(data.inputDepth), res.GetTexture(data.resolvedStencil), - data.coarseStencilBuffer, + res.GetComputeBuffer(data.coarseStencilBuffer), context.cmd); } ); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index 74384efdf78..2c0c9a1b3fd 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -211,14 +211,14 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, hdCamera.ExecuteCaptureActions(m_RenderGraph, colorBuffer); postProcessDest = RenderDebug( m_RenderGraph, - hdCamera, + hdCamera, postProcessDest, - prepassOutput.depthBuffer, - prepassOutput.depthPyramidTexture, - m_DebugFullScreenTexture, - colorPickerTexture, - shadowResult, - cullingResults); + prepassOutput.depthBuffer, + prepassOutput.depthPyramidTexture, + m_DebugFullScreenTexture, + colorPickerTexture, + shadowResult, + cullingResults); BlitFinalCameraTexture(m_RenderGraph, hdCamera, postProcessDest, backBuffer, prepassOutput.resolvedMotionVectorsBuffer, prepassOutput.resolvedNormalBuffer); @@ -459,10 +459,12 @@ void RenderForwardTransparent( RenderGraph renderGraph, bool renderMotionVecForTransparent = NeedMotionVectorForTransparent(hdCamera.frameSettings); - TextureHandle mrt1; + passData.renderTargetCount = 2; + passData.renderTarget[0] = builder.WriteTexture(colorBuffer); + if (renderMotionVecForTransparent) { - mrt1 = motionVectorBuffer; + passData.renderTarget[1] = builder.WriteTexture(motionVectorBuffer); // TODO RENDERGRAPH // WORKAROUND VELOCITY-MSAA // This is a workaround for velocity with MSAA. Currently motion vector resolve is not implemented with MSAA @@ -475,13 +477,9 @@ void RenderForwardTransparent( RenderGraph renderGraph, // It doesn't really matter what gets bound here since the color mask state set will prevent this from ever being written to. However, we still need to bind something // to avoid warnings about unbound render targets. The following rendertarget could really be anything if renderVelocitiesForTransparent // Create a new target here should reuse existing already released one - mrt1 = renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R8G8B8A8_SRGB, name = "Transparency Velocity Dummy" }); + passData.renderTarget[1] = builder.CreateTransientTexture(new TextureDesc(Vector2.one, true, true) { colorFormat = GraphicsFormat.R8G8B8A8_SRGB, name = "Transparency Velocity Dummy" }); } - passData.renderTargetCount = 2; - passData.renderTarget[0] = builder.WriteTexture(colorBuffer); - passData.renderTarget[1] = builder.WriteTexture(mrt1); - if (colorPyramid != null && hdCamera.frameSettings.IsEnabled(FrameSettingsField.Refraction) && !preRefractionPass) { builder.ReadTexture(colorPyramid.Value); @@ -783,16 +781,16 @@ void RenderForwardError(RenderGraph renderGraph, class RenderSkyPassData { - public VisualEnvironment visualEnvironment; - public Light sunLight; - public HDCamera hdCamera; + public VisualEnvironment visualEnvironment; + public Light sunLight; + public HDCamera hdCamera; public TextureHandle volumetricLighting; public TextureHandle colorBuffer; public TextureHandle depthStencilBuffer; public TextureHandle intermediateBuffer; - public DebugDisplaySettings debugDisplaySettings; - public SkyManager skyManager; - public int frameCount; + public DebugDisplaySettings debugDisplaySettings; + public SkyManager skyManager; + public int frameCount; } void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBuffer, TextureHandle volumetricLighting, TextureHandle depthStencilBuffer, TextureHandle depthTexture) @@ -810,7 +808,7 @@ void RenderSky(RenderGraph renderGraph, HDCamera hdCamera, TextureHandle colorBu passData.volumetricLighting = builder.ReadTexture(volumetricLighting); passData.colorBuffer = builder.WriteTexture(colorBuffer); passData.depthStencilBuffer = builder.WriteTexture(depthStencilBuffer); - passData.intermediateBuffer = builder.WriteTexture(renderGraph.CreateTexture(colorBuffer)); + passData.intermediateBuffer = builder.CreateTransientTexture(colorBuffer); passData.debugDisplaySettings = m_CurrentDebugDisplaySettings; passData.skyManager = m_SkyManager; passData.frameCount = m_FrameCount; @@ -928,8 +926,8 @@ class RenderDistortionPassData public Vector4 size; } - void RenderDistortion( RenderGraph renderGraph, - HDCamera hdCamera, + void RenderDistortion( RenderGraph renderGraph, + HDCamera hdCamera, TextureHandle colorBuffer, TextureHandle depthStencilBuffer, TextureHandle colorPyramidBuffer, diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs index 1830c6829c9..1204288ec02 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.SubsurfaceScattering.cs @@ -53,9 +53,9 @@ void RenderSubsurfaceScattering(RenderGraph renderGraph, HDCamera hdCamera, Text passData.sssBuffer = builder.ReadTexture(lightingBuffers.sssBuffer); if (passData.parameters.needTemporaryBuffer) { - passData.cameraFilteringBuffer = builder.WriteTexture(renderGraph.CreateTexture( + passData.cameraFilteringBuffer = builder.CreateTransientTexture( new TextureDesc(Vector2.one, true, true) - { colorFormat = GraphicsFormat.B10G11R11_UFloatPack32, enableRandomWrite = true, clearBuffer = true, clearColor = Color.clear, name = "SSSCameraFiltering" })); + { colorFormat = GraphicsFormat.B10G11R11_UFloatPack32, enableRandomWrite = true, clearBuffer = true, clearColor = Color.clear, name = "SSSCameraFiltering" }); } builder.SetRenderFunc( diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index bbfd0bf5710..c45ed0cf16f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -154,6 +154,7 @@ internal static Volume GetOrCreateDefaultVolume() Material m_DebugFullScreen; MaterialPropertyBlock m_DebugFullScreenPropertyBlock = new MaterialPropertyBlock(); Material m_DebugColorPicker; + Material m_DebugExposure; Material m_ErrorMaterial; Material m_Blit; @@ -770,13 +771,8 @@ void SetRenderingFeatures() #if UNITY_EDITOR // HDRP always enable baking of cookie by default - #if UNITY_2020_2_OR_NEWER m_PreviousEnableCookiesInLightmapper = UnityEditor.EditorSettings.enableCookiesInLightmapper; UnityEditor.EditorSettings.enableCookiesInLightmapper = true; - #else - m_PreviousEnableCookiesInLightmapper = UnityEditor.EditorSettings.disableCookiesInLightmapper; - UnityEditor.EditorSettings.disableCookiesInLightmapper = false; - #endif SceneViewDrawMode.SetupDrawMode(); @@ -872,11 +868,7 @@ void UnsetRenderingFeatures() Lightmapping.ResetDelegate(); #if UNITY_EDITOR - #if UNITY_2020_2_OR_NEWER UnityEditor.EditorSettings.enableCookiesInLightmapper = m_PreviousEnableCookiesInLightmapper; - #else - UnityEditor.EditorSettings.disableCookiesInLightmapper = m_PreviousEnableCookiesInLightmapper; - #endif #endif } @@ -947,6 +939,7 @@ void InitializeDebugMaterials() m_DebugDisplayLatlong = CoreUtils.CreateEngineMaterial(defaultResources.shaders.debugDisplayLatlongPS); m_DebugFullScreen = CoreUtils.CreateEngineMaterial(defaultResources.shaders.debugFullScreenPS); m_DebugColorPicker = CoreUtils.CreateEngineMaterial(defaultResources.shaders.debugColorPickerPS); + m_DebugExposure = CoreUtils.CreateEngineMaterial(defaultResources.shaders.debugExposurePS); m_Blit = CoreUtils.CreateEngineMaterial(defaultResources.shaders.blitPS); m_ErrorMaterial = CoreUtils.CreateEngineMaterial("Hidden/InternalErrorShader"); @@ -1032,6 +1025,7 @@ protected override void Dispose(bool disposing) CoreUtils.Destroy(m_DebugDisplayLatlong); CoreUtils.Destroy(m_DebugFullScreen); CoreUtils.Destroy(m_DebugColorPicker); + CoreUtils.Destroy(m_DebugExposure); CoreUtils.Destroy(m_Blit); CoreUtils.Destroy(m_BlitTexArray); CoreUtils.Destroy(m_BlitTexArraySingleSlice); @@ -1266,8 +1260,10 @@ void CopyDepthBufferIfNeeded(HDCamera hdCamera, CommandBuffer cmd) struct BuildCoarseStencilAndResolveParameters { - public HDCamera hdCamera; - public ComputeShader resolveStencilCS; + public HDCamera hdCamera; + public ComputeShader resolveStencilCS; + public int resolveKernel; + public bool resolveIsNecessary; } BuildCoarseStencilAndResolveParameters PrepareBuildCoarseStencilParameters(HDCamera hdCamera) @@ -1275,6 +1271,19 @@ BuildCoarseStencilAndResolveParameters PrepareBuildCoarseStencilParameters(HDCam var parameters = new BuildCoarseStencilAndResolveParameters(); parameters.hdCamera = hdCamera; parameters.resolveStencilCS = defaultResources.shaders.resolveStencilCS; + + bool MSAAEnabled = hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA); + + // The following features require a copy of the stencil, if none are active, no need to do the resolve. + bool resolveIsNecessary = GetFeatureVariantsEnabled(hdCamera.frameSettings); + resolveIsNecessary = resolveIsNecessary || hdCamera.IsSSREnabled() + || hdCamera.IsTransparentSSREnabled(); + // We need the resolve only with msaa + parameters.resolveIsNecessary = resolveIsNecessary && MSAAEnabled; + + int kernel = SampleCountToPassIndex(MSAAEnabled ? hdCamera.msaaSamples : MSAASamples.None); + parameters.resolveKernel = parameters.resolveIsNecessary ? kernel + 3 : kernel; // We have a different variant if we need to resolve to non-MSAA stencil + return parameters; } @@ -1292,31 +1301,18 @@ static void BuildCoarseStencilAndResolveIfNeeded(BuildCoarseStencilAndResolvePar { using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.CoarseStencilGeneration))) { - var hdCamera = parameters.hdCamera; - bool MSAAEnabled = hdCamera.frameSettings.IsEnabled(FrameSettingsField.MSAA); - - // The following features require a copy of the stencil, if none are active, no need to do the resolve. - bool resolveIsNecessary = GetFeatureVariantsEnabled(hdCamera.frameSettings); - resolveIsNecessary = resolveIsNecessary || hdCamera.IsSSREnabled() - || hdCamera.IsTransparentSSREnabled(); - - // We need the resolve only with msaa - resolveIsNecessary = resolveIsNecessary && MSAAEnabled; - ComputeShader cs = parameters.resolveStencilCS; - int kernel = SampleCountToPassIndex(MSAAEnabled ? hdCamera.msaaSamples : MSAASamples.None); - kernel = resolveIsNecessary ? kernel + 3 : kernel; // We have a different variant if we need to resolve to non-MSAA stencil - cmd.SetComputeBufferParam(cs, kernel, HDShaderIDs._CoarseStencilBuffer, coarseStencilBuffer); - cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._StencilTexture, depthStencilBuffer, 0, RenderTextureSubElement.Stencil); + cmd.SetComputeBufferParam(cs, parameters.resolveKernel, HDShaderIDs._CoarseStencilBuffer, coarseStencilBuffer); + cmd.SetComputeTextureParam(cs, parameters.resolveKernel, HDShaderIDs._StencilTexture, depthStencilBuffer, 0, RenderTextureSubElement.Stencil); - if (resolveIsNecessary) + if (parameters.resolveIsNecessary) { - cmd.SetComputeTextureParam(cs, kernel, HDShaderIDs._OutputStencilBuffer, resolvedStencilBuffer); + cmd.SetComputeTextureParam(cs, parameters.resolveKernel, HDShaderIDs._OutputStencilBuffer, resolvedStencilBuffer); } - int coarseStencilWidth = HDUtils.DivRoundUp(hdCamera.actualWidth, 8); - int coarseStencilHeight = HDUtils.DivRoundUp(hdCamera.actualHeight, 8); - cmd.DispatchCompute(cs, kernel, coarseStencilWidth, coarseStencilHeight, hdCamera.viewCount); + int coarseStencilWidth = HDUtils.DivRoundUp(parameters.hdCamera.actualWidth, 8); + int coarseStencilHeight = HDUtils.DivRoundUp(parameters.hdCamera.actualHeight, 8); + cmd.DispatchCompute(cs, parameters.resolveKernel, coarseStencilWidth, coarseStencilHeight, parameters.hdCamera.viewCount); } } @@ -2709,6 +2705,8 @@ void Callback(CommandBuffer c, HDCamera cam) RenderTargetIdentifier postProcessDest = HDUtils.PostProcessIsFinalPass(hdCamera) ? target.id : m_IntermediateAfterPostProcessBuffer; RenderPostProcess(cullingResults, hdCamera, postProcessDest, renderContext, cmd); + PushFullScreenExposureDebugTexture(cmd, m_IntermediateAfterPostProcessBuffer); + RenderCustomPass(renderContext, cmd, hdCamera, customPassCullingResults, CustomPassInjectionPoint.AfterPostProcess, aovRequest, aovCustomPassBuffers); // Copy and rescale depth buffer for XR devices @@ -4454,7 +4452,8 @@ unsafe void ApplyDebugDisplaySettings(HDCamera hdCamera, CommandBuffer cmd) cmd.SetGlobalTexture(HDShaderIDs._DebugMatCapTexture, defaultResources.textures.matcapTex); if (debugDisplayEnabledOrSceneLightingDisabled || - m_CurrentDebugDisplaySettings.data.colorPickerDebugSettings.colorPickerMode != ColorPickerDebugMode.None) + m_CurrentDebugDisplaySettings.data.colorPickerDebugSettings.colorPickerMode != ColorPickerDebugMode.None || + m_CurrentDebugDisplaySettings.IsDebugExposureModeEnabled()) { // This is for texture streaming m_CurrentDebugDisplaySettings.UpdateMaterials(); @@ -4543,6 +4542,11 @@ void PushColorPickerDebugTexture(CommandBuffer cmd, HDCamera hdCamera, RTHandle } } + bool NeedExposureDebugMode(DebugDisplaySettings debugSettings) + { + return debugSettings.data.lightingDebugSettings.exposureDebugMode != ExposureDebugMode.None; + } + bool NeedsFullScreenDebugMode() { bool fullScreenDebugEnabled = m_CurrentDebugDisplaySettings.data.fullScreenDebugMode != FullScreenDebugMode.None; @@ -4562,6 +4566,14 @@ void PushFullScreenLightingDebugTexture(HDCamera hdCamera, CommandBuffer cmd, RT } } + void PushFullScreenExposureDebugTexture(CommandBuffer cmd, RTHandle textureID) + { + if (m_CurrentDebugDisplaySettings.data.lightingDebugSettings.exposureDebugMode != ExposureDebugMode.None) + { + HDUtils.BlitCameraTexture(cmd, textureID, m_DebugFullScreenTempBuffer); + } + } + internal void PushFullScreenDebugTexture(HDCamera hdCamera, CommandBuffer cmd, RTHandle textureID, FullScreenDebugMode debugMode) { if (debugMode == m_CurrentDebugDisplaySettings.data.fullScreenDebugMode) @@ -4606,6 +4618,10 @@ struct DebugParameters // Color picker public bool colorPickerEnabled; public Material colorPickerMaterial; + + // Exposure + public bool exposureDebugEnabled; + public Material debugExposureMaterial; } DebugParameters PrepareDebugParameters(HDCamera hdCamera, HDUtils.PackedMipChainInfo depthMipInfo) @@ -4630,6 +4646,9 @@ DebugParameters PrepareDebugParameters(HDCamera hdCamera, HDUtils.PackedMipChain parameters.colorPickerEnabled = NeedColorPickerDebug(parameters.debugDisplaySettings); parameters.colorPickerMaterial = m_DebugColorPicker; + parameters.exposureDebugEnabled = NeedExposureDebugMode(parameters.debugDisplaySettings); + parameters.debugExposureMaterial = m_DebugExposure; + return parameters; } @@ -4677,6 +4696,82 @@ static void ResolveColorPickerDebug(in DebugParameters parameters, HDUtils.DrawFullScreen(cmd, parameters.colorPickerMaterial, output); } + static void RenderExposureDebug(in DebugParameters parameters, + RTHandle inputColorBuffer, + RTHandle postprocessedColorBuffer, + RTHandle currentExposure, + RTHandle prevExposure, + RTHandle debugExposureData, + RTHandle output, + HableCurve hableCurve, + int lutSize, + ComputeBuffer histogramBuffer, + CommandBuffer cmd) + { + // Grab exposure parameters + var exposureSettings = parameters.hdCamera.volumeStack.GetComponent(); + + Vector4 exposureParams = new Vector4(exposureSettings.compensation.value + parameters.debugDisplaySettings.data.lightingDebugSettings.debugExposure, exposureSettings.limitMin.value, + exposureSettings.limitMax.value, 0f); + + Vector4 exposureVariants = new Vector4(1.0f, (int)exposureSettings.meteringMode.value, (int)exposureSettings.adaptationMode.value, 0.0f); + Vector2 histogramFraction = exposureSettings.histogramPercentages.value / 100.0f; + float evRange = exposureSettings.limitMax.value - exposureSettings.limitMin.value; + float histScale = 1.0f / Mathf.Max(1e-5f, evRange); + float histBias = -exposureSettings.limitMin.value * histScale; + Vector4 histogramParams = new Vector4(histScale, histBias, histogramFraction.x, histogramFraction.y); + + parameters.debugExposureMaterial.SetVector(HDShaderIDs._HistogramExposureParams, histogramParams); + parameters.debugExposureMaterial.SetVector(HDShaderIDs._Variants, exposureVariants); + parameters.debugExposureMaterial.SetVector(HDShaderIDs._ExposureParams, exposureParams); + parameters.debugExposureMaterial.SetVector(HDShaderIDs._MousePixelCoord, HDUtils.GetMouseCoordinates(parameters.hdCamera)); + parameters.debugExposureMaterial.SetTexture(HDShaderIDs._SourceTexture, inputColorBuffer); + parameters.debugExposureMaterial.SetTexture(HDShaderIDs._DebugFullScreenTexture, postprocessedColorBuffer); + parameters.debugExposureMaterial.SetTexture(HDShaderIDs._PreviousExposureTexture, prevExposure); + parameters.debugExposureMaterial.SetTexture(HDShaderIDs._ExposureTexture, currentExposure); + parameters.debugExposureMaterial.SetTexture(HDShaderIDs._ExposureWeightMask, exposureSettings.weightTextureMask.value); + parameters.debugExposureMaterial.SetBuffer(HDShaderIDs._HistogramBuffer, histogramBuffer); + + + int passIndex = 0; + if (parameters.debugDisplaySettings.data.lightingDebugSettings.exposureDebugMode == ExposureDebugMode.MeteringWeighted) + passIndex = 1; + if (parameters.debugDisplaySettings.data.lightingDebugSettings.exposureDebugMode == ExposureDebugMode.HistogramView) + { + parameters.debugExposureMaterial.SetTexture(HDShaderIDs._ExposureDebugTexture, debugExposureData); + var tonemappingSettings = parameters.hdCamera.volumeStack.GetComponent(); + + bool toneMapIsEnabled = parameters.hdCamera.frameSettings.IsEnabled(FrameSettingsField.Tonemapping); + var tonemappingMode = toneMapIsEnabled ? tonemappingSettings.mode.value : TonemappingMode.None; + + bool drawTonemapCurve = tonemappingMode != TonemappingMode.None && + parameters.debugDisplaySettings.data.lightingDebugSettings.showTonemapCurveAlongHistogramView; + + parameters.debugExposureMaterial.SetVector(HDShaderIDs._ExposureDebugParams, new Vector4(drawTonemapCurve ? 1.0f : 0.0f, (int)tonemappingMode, 0, 0)); + if (drawTonemapCurve) + { + if (tonemappingMode == TonemappingMode.Custom) + { + parameters.debugExposureMaterial.SetVector(HDShaderIDs._CustomToneCurve, hableCurve.uniforms.curve); + parameters.debugExposureMaterial.SetVector(HDShaderIDs._ToeSegmentA, hableCurve.uniforms.toeSegmentA); + parameters.debugExposureMaterial.SetVector(HDShaderIDs._ToeSegmentB, hableCurve.uniforms.toeSegmentB); + parameters.debugExposureMaterial.SetVector(HDShaderIDs._MidSegmentA, hableCurve.uniforms.midSegmentA); + parameters.debugExposureMaterial.SetVector(HDShaderIDs._MidSegmentB, hableCurve.uniforms.midSegmentB); + parameters.debugExposureMaterial.SetVector(HDShaderIDs._ShoSegmentA, hableCurve.uniforms.shoSegmentA); + parameters.debugExposureMaterial.SetVector(HDShaderIDs._ShoSegmentB, hableCurve.uniforms.shoSegmentB); + } + } + else if (tonemappingMode == TonemappingMode.External) + { + parameters.debugExposureMaterial.SetTexture(HDShaderIDs._LogLut3D, tonemappingSettings.lutTexture.value); + parameters.debugExposureMaterial.SetVector(HDShaderIDs._LogLut3D_Params, new Vector4(1f / lutSize, lutSize - 1f, tonemappingSettings.lutContribution.value, 0f)); + } + passIndex = 2; + } + + HDUtils.DrawFullScreen(cmd, parameters.debugExposureMaterial, output, null, passIndex); + } + static void RenderSkyReflectionOverlay(in DebugParameters debugParameters, CommandBuffer cmd, MaterialPropertyBlock mpb, ref float x, ref float y, float overlaySize) { var lightingDebug = debugParameters.debugDisplaySettings.data.lightingDebugSettings; @@ -4719,6 +4814,12 @@ void RenderDebug(HDCamera hdCamera, CommandBuffer cmd, CullingResults cullResult PushColorPickerDebugTexture(cmd, hdCamera, m_IntermediateAfterPostProcessBuffer); } + if (debugParams.exposureDebugEnabled) + { + RenderExposureDebug(debugParams, m_CameraColorBuffer, m_DebugFullScreenTempBuffer,m_PostProcessSystem.GetPreviousExposureTexture(hdCamera), m_PostProcessSystem.GetExposureTexture(hdCamera), + m_PostProcessSystem.GetExposureDebugData(),m_IntermediateAfterPostProcessBuffer, m_PostProcessSystem.GetCustomToneMapCurve(), m_PostProcessSystem.GetLutSize(), m_PostProcessSystem.GetHistogramBuffer(), cmd); + } + // First resolve color picker if (debugParams.colorPickerEnabled) ResolveColorPickerDebug(debugParams, m_DebugColorPickerBuffer, m_IntermediateAfterPostProcessBuffer, cmd); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs index 0f491337b7a..6db4c395dec 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs @@ -83,6 +83,11 @@ static class HDShaderIDs public static readonly int _ShadowmapAreaAtlas = Shader.PropertyToID("_ShadowmapAreaAtlas"); public static readonly int _ShadowmapCascadeAtlas = Shader.PropertyToID("_ShadowmapCascadeAtlas"); + public static readonly int _CachedShadowmapAtlas = Shader.PropertyToID("_CachedShadowmapAtlas"); + public static readonly int _CachedAreaLightShadowmapAtlas = Shader.PropertyToID("_CachedAreaLightShadowmapAtlas"); + public static readonly int _CachedShadowAtlasSize = Shader.PropertyToID("_CachedShadowAtlasSize"); + public static readonly int _CachedAreaShadowAtlasSize = Shader.PropertyToID("_CachedAreaShadowAtlasSize"); + // Moment shadow map data public static readonly int _MomentShadowAtlas = Shader.PropertyToID("_MomentShadowAtlas"); public static readonly int _MomentShadowmapSlotST = Shader.PropertyToID("_MomentShadowmapSlotST"); @@ -597,7 +602,12 @@ static class HDShaderIDs public static readonly int _ExposureTexture = Shader.PropertyToID("_ExposureTexture"); public static readonly int _PrevExposureTexture = Shader.PropertyToID("_PrevExposureTexture"); public static readonly int _PreviousExposureTexture = Shader.PropertyToID("_PreviousExposureTexture"); + public static readonly int _ExposureDebugTexture = Shader.PropertyToID("_ExposureDebugTexture"); public static readonly int _ExposureParams = Shader.PropertyToID("_ExposureParams"); + public static readonly int _ExposureParams2 = Shader.PropertyToID("_ExposureParams2"); + public static readonly int _ExposureDebugParams = Shader.PropertyToID("_ExposureDebugParams"); + public static readonly int _HistogramExposureParams = Shader.PropertyToID("_HistogramExposureParams"); + public static readonly int _HistogramBuffer = Shader.PropertyToID("_HistogramBuffer"); public static readonly int _AdaptationParams = Shader.PropertyToID("_AdaptationParams"); public static readonly int _ExposureCurveTexture = Shader.PropertyToID("_ExposureCurveTexture"); public static readonly int _ExposureWeightMask = Shader.PropertyToID("_ExposureWeightMask"); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs index 391ee0d57e1..3a98956a933 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPipelineResources.cs @@ -25,6 +25,8 @@ public sealed class ShaderResources public Shader debugFullScreenPS; [Reload("Runtime/Debug/DebugColorPicker.Shader")] public Shader debugColorPickerPS; + [Reload("Runtime/Debug/DebugExposure.Shader")] + public Shader debugExposurePS; [Reload("Runtime/Debug/DebugLightVolumes.Shader")] public Shader debugLightVolumePS; [Reload("Runtime/Debug/DebugLightVolumes.compute")] @@ -220,6 +222,8 @@ public sealed class ShaderResources public ComputeShader nanKillerCS; [Reload("Runtime/PostProcessing/Shaders/Exposure.compute")] public ComputeShader exposureCS; + [Reload("Runtime/PostProcessing/Shaders/HistogramExposure.compute")] + public ComputeShader histogramExposureCS; [Reload("Runtime/PostProcessing/Shaders/ApplyExposure.compute")] public ComputeShader applyExposureCS; [Reload("Runtime/PostProcessing/Shaders/UberPost.compute")] diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs index dea46d77d30..df665026da4 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs @@ -315,7 +315,7 @@ public enum FrameSettingsField [FrameSettingsField(2, displayedName: "SS Ambient Occlusion", positiveDependencies: new[] { AsyncCompute }, tooltip: "When enabled, HDRP calculates screen space ambient occlusion asynchronously.")] SSAOAsync = 43, // TODO: Enable thing when the render graph will be the default renderer. - // [FrameSettingsField(2, displayedName: "Contact Shadows", positiveDependencies: new[] { AsyncCompute }, tooltip: "When enabled, HDRP calculates Contact Shadows asynchronously.")] + //[FrameSettingsField(2, displayedName: "Contact Shadows", positiveDependencies: new[] { AsyncCompute }, tooltip: "When enabled, HDRP calculates Contact Shadows asynchronously.")] /// When enabled, HDRP calculates Contact Shadows asynchronously. ContactShadowsAsync = 44, /// When enabled, HDRP calculates volumetric voxelization asynchronously. @@ -671,7 +671,7 @@ public int GetResolvedSssSampleBudget(HDRenderPipelineAsset hdrp) internal bool SSRRunsAsync() => SystemInfo.supportsAsyncCompute && bitDatas[(int)FrameSettingsField.AsyncCompute] && bitDatas[(int)FrameSettingsField.SSRAsync]; internal bool SSAORunsAsync() => SystemInfo.supportsAsyncCompute && bitDatas[(int)FrameSettingsField.AsyncCompute] && bitDatas[(int)FrameSettingsField.SSAOAsync]; // TODO: Re-enable this when the render graph will be used by default. - internal bool ContactShadowsRunAsync() => SystemInfo.supportsAsyncCompute && bitDatas[(int)FrameSettingsField.AsyncCompute] && /* bitDatas[(int)FrameSettingsField.ContactShadowsAsync] */ false; + internal bool ContactShadowsRunAsync() => SystemInfo.supportsAsyncCompute && bitDatas[(int)FrameSettingsField.AsyncCompute] && /*bitDatas[(int)FrameSettingsField.ContactShadowsAsync]*/ false; internal bool VolumeVoxelizationRunsAsync() => SystemInfo.supportsAsyncCompute && bitDatas[(int)FrameSettingsField.AsyncCompute] && bitDatas[(int)FrameSettingsField.VolumeVoxelizationsAsync]; /// Override a frameSettings according to a mask. diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset index dcafb599476..add31419125 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipelineResources/HDRenderPipelineResources.asset @@ -21,12 +21,10 @@ MonoBehaviour: type: 3} debugViewTilesPS: {fileID: 4800000, guid: c7c2bd17b06ceb4468e14081aaf1b96f, type: 3} debugFullScreenPS: {fileID: 4800000, guid: e874aca2df8300a488258738c31f85cf, type: 3} - debugColorPickerPS: {fileID: 4800000, guid: 8137b807709e178498f22ed710864bb0, - type: 3} - debugLightVolumePS: {fileID: 4800000, guid: 8e706c0e71fcec34a8f5c9713e5e2943, - type: 3} - debugLightVolumeCS: {fileID: 7200000, guid: f5d5d21faef5cf445ac2c5d8ff9c4184, - type: 3} + debugColorPickerPS: {fileID: 4800000, guid: 8137b807709e178498f22ed710864bb0, type: 3} + debugExposurePS: {fileID: 4800000, guid: 0ef322534f047a34c96d29419d56d17a, type: 3} + debugLightVolumePS: {fileID: 4800000, guid: 8e706c0e71fcec34a8f5c9713e5e2943, type: 3} + debugLightVolumeCS: {fileID: 7200000, guid: f5d5d21faef5cf445ac2c5d8ff9c4184, type: 3} debugBlitQuad: {fileID: 4800000, guid: cf5ca5b6ef18b3f429ed707ee9ceac9f, type: 3} deferredPS: {fileID: 4800000, guid: 00dd221e34a6ab349a1196b0f2fab693, type: 3} colorPyramidPS: {fileID: 4800000, guid: 2fcfb8d92f45e4549b3f0bad5d0654bf, type: 3} @@ -152,6 +150,7 @@ MonoBehaviour: copyAlphaCS: {fileID: 7200000, guid: c2c7eb6611725264187721ef9df0354b, type: 3} nanKillerCS: {fileID: 7200000, guid: 83982f199acf927499576a99abc9bea9, type: 3} exposureCS: {fileID: 7200000, guid: 976d7bce54fae534fb9ec67e9c18570c, type: 3} + histogramExposureCS: {fileID: 7200000, guid: 222da48299136f34b8e3fb75ae9f8ac7, type: 3} applyExposureCS: {fileID: 7200000, guid: 1a6fea1dc099b984d8f2b27d504dc096, type: 3} uberPostCS: {fileID: 7200000, guid: f1bf52f7c71bffd4f91e6cd90d12a4f7, type: 3} lutBuilder3DCS: {fileID: 7200000, guid: 37f2b1b0ecd6f1c439e4c1b4f2fdb524, type: 3} diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs index b17250fb174..ca44206beb9 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs @@ -146,6 +146,8 @@ unsafe struct ShaderVariablesGlobal public Vector4 _ShadowAtlasSize; public Vector4 _CascadeShadowAtlasSize; public Vector4 _AreaShadowAtlasSize; + public Vector4 _CachedShadowAtlasSize; + public Vector4 _CachedAreaShadowAtlasSize; [HLSLArray(s_MaxEnv2DLight, typeof(Matrix4x4))] public fixed float _Env2DCaptureVP[s_MaxEnv2DLight * 4 * 4]; diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl index eaa41b94a68..ce07922e4f1 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl @@ -72,6 +72,8 @@ GLOBAL_CBUFFER_START(ShaderVariablesGlobal, b0) float4 _ShadowAtlasSize; float4 _CascadeShadowAtlasSize; float4 _AreaShadowAtlasSize; + float4 _CachedShadowAtlasSize; + float4 _CachedAreaShadowAtlasSize; float4x4 _Env2DCaptureVP[32]; float4 _Env2DCaptureForward[32]; float4 _Env2DAtlasScaleOffset[32]; From 0c8b92af38f2f3b7c7d2bc3d941480bba0c2a14f Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sat, 23 May 2020 15:48:13 +0200 Subject: [PATCH 07/11] Revert "Enable "Shaded Wireframe" scene view mode in HDRP & URP (#356)" This reverts commit c8a93e17e6891c325beeebb1a5d0c5eb2ba1eba9. --- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 15 --------------- .../Runtime/RenderPipeline/SceneViewDrawMode.cs | 3 ++- .../Runtime/SceneViewDrawMode.cs | 3 ++- .../Runtime/ScriptableRenderer.cs | 9 --------- 4 files changed, 4 insertions(+), 26 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index c45ed0cf16f..5aaa678d6c8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -2788,9 +2788,6 @@ void Callback(CommandBuffer c, HDCamera cam) // We need to make sure the viewport is correctly set for the editor rendering. It might have been changed by debug overlay rendering just before. cmd.SetViewport(hdCamera.finalViewport); - if (camera.cameraType == CameraType.SceneView) - RenderWireOverlay(cmd, camera, renderContext); - // Render overlay Gizmos if (showGizmos) RenderGizmos(cmd, camera, renderContext, GizmoSubset.PostImageEffects); @@ -3111,18 +3108,6 @@ void RenderGizmos(CommandBuffer cmd, Camera camera, ScriptableRenderContext rend #endif } -#if UNITY_EDITOR - void RenderWireOverlay(CommandBuffer cmd, Camera camera, ScriptableRenderContext renderContext) - { - using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RenderWireFrame))) - { - renderContext.ExecuteCommandBuffer(cmd); - cmd.Clear(); - renderContext.DrawWireOverlay(camera); - } - } -#endif - static RendererListDesc CreateOpaqueRendererListDesc( CullingResults cull, Camera camera, diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs index 2a53fd38784..0ba33475185 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/SceneViewDrawMode.cs @@ -11,7 +11,8 @@ class SceneViewDrawMode static private bool RejectDrawMode(SceneView.CameraMode cameraMode) { - if (cameraMode.drawMode == DrawCameraMode.ShadowCascades || + if (cameraMode.drawMode == DrawCameraMode.TexturedWire || + cameraMode.drawMode == DrawCameraMode.ShadowCascades || cameraMode.drawMode == DrawCameraMode.RenderPaths || cameraMode.drawMode == DrawCameraMode.AlphaChannel || cameraMode.drawMode == DrawCameraMode.Overdraw || diff --git a/com.unity.render-pipelines.universal/Runtime/SceneViewDrawMode.cs b/com.unity.render-pipelines.universal/Runtime/SceneViewDrawMode.cs index 9290c50c960..d9b5cc2004f 100644 --- a/com.unity.render-pipelines.universal/Runtime/SceneViewDrawMode.cs +++ b/com.unity.render-pipelines.universal/Runtime/SceneViewDrawMode.cs @@ -10,7 +10,8 @@ internal static class SceneViewDrawMode static bool RejectDrawMode(SceneView.CameraMode cameraMode) { - if (cameraMode.drawMode == DrawCameraMode.ShadowCascades || + if (cameraMode.drawMode == DrawCameraMode.TexturedWire || + cameraMode.drawMode == DrawCameraMode.ShadowCascades || cameraMode.drawMode == DrawCameraMode.RenderPaths || cameraMode.drawMode == DrawCameraMode.AlphaChannel || cameraMode.drawMode == DrawCameraMode.Overdraw || diff --git a/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs b/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs index 7f9aea8c171..8d1234f08a5 100644 --- a/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs +++ b/com.unity.render-pipelines.universal/Runtime/ScriptableRenderer.cs @@ -432,7 +432,6 @@ public void Execute(ScriptableRenderContext context, ref RenderingData rendering EndXRRendering(context, renderingData, eyeIndex); } - DrawWireOverlay(context, camera); DrawGizmos(context, camera, GizmoSubset.PostImageEffects); InternalFinishRendering(context, cameraData.resolveFinalTarget); @@ -836,14 +835,6 @@ void DrawGizmos(ScriptableRenderContext context, Camera camera, GizmoSubset gizm #endif } - [Conditional("UNITY_EDITOR")] - void DrawWireOverlay(ScriptableRenderContext context, Camera camera) - { -#if UNITY_EDITOR - context.DrawWireOverlay(camera); -#endif - } - // Fill in render pass indices for each block. End index is startIndex + 1. void FillBlockRanges(NativeArray blockEventLimits, NativeArray blockRanges) { From e08b455b1217345cd72a3793a76c0997dd256f53 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sat, 23 May 2020 19:01:26 +0200 Subject: [PATCH 08/11] update screenshots --- .../Linear/WindowsPlayer/Direct3D11/None/001-HDTemplate.png | 4 ++-- .../Linear/WindowsEditor/Direct3D12/None/4052_TAA.png | 4 ++-- .../Linear/WindowsEditor/Vulkan/None/4052_TAA.png | 4 ++-- .../WindowsEditor/Direct3D11/None/ParticleRibbonLit.png | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/001-HDTemplate.png b/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/001-HDTemplate.png index 37f27610b2d..fbba1292d2d 100644 --- a/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/001-HDTemplate.png +++ b/TestProjects/HDRP_RuntimeTests/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/001-HDTemplate.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e2383be9287d59324957fc6d49d10a15806c4e660b2eec41495634e85a6c46aa -size 2297615 +oid sha256:f29de1a928d4458e70387f8675326de37b6110797c1f870aff560c2a68ffd797 +size 2169620 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/4052_TAA.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/4052_TAA.png index 29e9292b101..5fa20859a0c 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/4052_TAA.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/4052_TAA.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:71ccd1b22457703a01b693b7cfbf942789655a93819eeb777280c0d677e94797 -size 193823 +oid sha256:51e3555a5236cf85846b898fd6a883a3eaa8e4580eb01497c6175fb66e2a1db2 +size 195045 diff --git a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png index f10c04ad7cd..c7629f436b4 100644 --- a/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png +++ b/TestProjects/HDRP_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/4052_TAA.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e5e47d48cc5c372d5b864784ba6647f5d1fbe2f4aac72c7f4d2055ba509a1b0a -size 306 +oid sha256:4d56bec0dd2d98438565872b0510350fb0dc71c47cafcc6b7d01941158a5c876 +size 219775 diff --git a/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png b/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png index c859c3b6974..bd0370622ae 100644 --- a/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png +++ b/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ae4f30fa1034f864944232a6e8367ff4d951841116eb60270ab2f1864b0dd52e -size 189993 +oid sha256:c4bab7a0647a60ef231e1e97d05c1afe6b7f454e2197bac183af8e9146790d74 +size 189763 From 44420a62079aafed4089fccd26458ff2a5885ac7 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sat, 23 May 2020 21:08:54 +0200 Subject: [PATCH 09/11] Update ParticleRibbonLit.png --- .../WindowsEditor/Direct3D11/None/ParticleRibbonLit.png | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png b/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png index bd0370622ae..b6f278818f9 100644 --- a/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png +++ b/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c4bab7a0647a60ef231e1e97d05c1afe6b7f454e2197bac183af8e9146790d74 -size 189763 +oid sha256:a18582acac1cebbc30c724cc7b00a811b6ebdeab3b93f63fdf6624f6b5e12ce5 +size 190375 From 67da58781bd6c211a1c9c326238d8d18a56c3e32 Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sat, 23 May 2020 23:01:26 +0200 Subject: [PATCH 10/11] Update ParticleRibbonLit.png --- .../WindowsEditor/Direct3D11/None/ParticleRibbonLit.png | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png b/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png index b6f278818f9..bd0370622ae 100644 --- a/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png +++ b/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D11/None/ParticleRibbonLit.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a18582acac1cebbc30c724cc7b00a811b6ebdeab3b93f63fdf6624f6b5e12ce5 -size 190375 +oid sha256:c4bab7a0647a60ef231e1e97d05c1afe6b7f454e2197bac183af8e9146790d74 +size 189763 From 501dd8b751824410bb39314286984d909081de1d Mon Sep 17 00:00:00 2001 From: Sebastien Lagarde Date: Sun, 24 May 2020 00:37:48 +0200 Subject: [PATCH 11/11] Update ParticleRibbonLit.png --- .../WindowsPlayer/Direct3D11/None/ParticleRibbonLit.png | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/ParticleRibbonLit.png b/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/ParticleRibbonLit.png index b6f278818f9..bd0370622ae 100644 --- a/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/ParticleRibbonLit.png +++ b/TestProjects/VisualEffectGraph/Assets/ReferenceImages/Linear/WindowsPlayer/Direct3D11/None/ParticleRibbonLit.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a18582acac1cebbc30c724cc7b00a811b6ebdeab3b93f63fdf6624f6b5e12ce5 -size 190375 +oid sha256:c4bab7a0647a60ef231e1e97d05c1afe6b7f454e2197bac183af8e9146790d74 +size 189763