'push'
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#ifndef d_WaveHarmonic_Utility_RenderPipeline_Compute
|
||||
#define d_WaveHarmonic_Utility_RenderPipeline_Compute
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Settings.Crest.hlsl"
|
||||
|
||||
// Compute does not have an equivalent of PackageRequirements.
|
||||
// We must handle it ourselves.
|
||||
|
||||
// Fallback to BIRP if HDRP package missing.
|
||||
#if _HRP
|
||||
#if (CREST_PACKAGE_HDRP != 1)
|
||||
#undef _HRP
|
||||
#define _BRP 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Fallback to BIRP if URP package missing.
|
||||
#if _URP
|
||||
#if (CREST_PACKAGE_URP != 1)
|
||||
#undef _URP
|
||||
#define _BRP 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if _BRP
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Legacy/Core.hlsl"
|
||||
#endif
|
||||
|
||||
#if _HRP
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
||||
#endif
|
||||
|
||||
#if _URP
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Stereo Rendering
|
||||
//
|
||||
|
||||
// Unity 6 only, but had compilation errors for non HDRP anyway:
|
||||
// #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureXR.hlsl"
|
||||
|
||||
#ifndef RW_TEXTURE2D_X
|
||||
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
|
||||
#define COORD_TEXTURE2D_X(pixelCoord) uint3(pixelCoord, SLICE_ARRAY_INDEX)
|
||||
#define RW_TEXTURE2D_X(type, textureName) RW_TEXTURE2D_ARRAY(type, textureName)
|
||||
#else // UNITY_STEREO
|
||||
#define COORD_TEXTURE2D_X(pixelCoord) pixelCoord
|
||||
#define RW_TEXTURE2D_X RW_TEXTURE2D
|
||||
#endif // UNITY_STEREO
|
||||
#endif // RW_TEXTURE2D_X
|
||||
|
||||
#ifndef UNITY_XR_ASSIGN_VIEW_INDEX
|
||||
// Helper macro to assign view index during compute/ray pass (usually from SV_DispatchThreadID or DispatchRaysIndex())
|
||||
#if defined(SHADER_STAGE_COMPUTE) || defined(SHADER_STAGE_RAY_TRACING)
|
||||
#if defined(UNITY_STEREO_INSTANCING_ENABLED)
|
||||
#define UNITY_XR_ASSIGN_VIEW_INDEX(viewIndex) unity_StereoEyeIndex = viewIndex;
|
||||
#else
|
||||
#define UNITY_XR_ASSIGN_VIEW_INDEX(viewIndex)
|
||||
#endif
|
||||
#endif
|
||||
#endif // UNITY_XR_ASSIGN_VIEW_INDEX
|
||||
|
||||
#endif // d_WaveHarmonic_Utility_RenderPipeline_Compute
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68cb1a44e787e45bd9de666d527b10f2
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff5a7cc0943db46db9eac87f50e38097
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,12 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#ifndef d_WaveHarmonic_Utility_RenderPipeline_HDRP_Common
|
||||
#define d_WaveHarmonic_Utility_RenderPipeline_HDRP_Common
|
||||
|
||||
#define LoadSceneColor LoadCameraColor
|
||||
#define LoadSceneDepth LoadCameraDepth
|
||||
#define SampleSceneColor SampleCameraColor
|
||||
#define SampleSceneDepth SampleCameraDepth
|
||||
|
||||
#endif // d_WaveHarmonic_Utility_RenderPipeline_HDRP_Common
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 327c164f365e1468789c5950ac945e17
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,107 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
#ifndef d_WaveHarmonic_Utility_RenderPipeline_Shadows
|
||||
#define d_WaveHarmonic_Utility_RenderPipeline_Shadows
|
||||
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Macros.hlsl"
|
||||
|
||||
#if _BRP
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Utility/Legacy/Shadows.hlsl"
|
||||
|
||||
bool _Crest_ClearShadows;
|
||||
#endif
|
||||
|
||||
#if _HRP
|
||||
// TODO: We might be able to expose this to give developers the option.
|
||||
// #pragma multi_compile SHADOW_ULTRA_LOW SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH
|
||||
|
||||
// Ultra low uses Gather to filter which should be same cost as not filtering. See algorithms per keyword:
|
||||
// Runtime/Lighting/Shadow/HDShadowAlgorithms.hlsl
|
||||
#define SHADOW_ULTRA_LOW
|
||||
#define AREA_SHADOW_LOW
|
||||
#define PUNCTUAL_SHADOW_ULTRA_LOW
|
||||
#define DIRECTIONAL_SHADOW_ULTRA_LOW
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl"
|
||||
#endif
|
||||
|
||||
#if _URP
|
||||
// Maybe this is the equivalent of the SHADOW_COLLECTOR_PASS define?
|
||||
// Inspired from com.unity.render-pipelines.universal/Shaders/Utils/ScreenSpaceShadows.shader
|
||||
#define _MAIN_LIGHT_SHADOWS_CASCADE
|
||||
#define MAIN_LIGHT_CALCULATE_SHADOWS
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl"
|
||||
#endif
|
||||
|
||||
m_UtilityNameSpace
|
||||
|
||||
#if _BRP
|
||||
half SampleShadows(const float4 i_positionWS)
|
||||
{
|
||||
// NOTE: "Shadow Projection > Close Fit" can still produce artefacts when away from caster, but this
|
||||
// appears to be an improvement over the compute shader.
|
||||
|
||||
// Calculate depth. Normally this would be depth from the depth buffer.
|
||||
float z = dot(i_positionWS.xyz - _WorldSpaceCameraPos.xyz, unity_CameraToWorld._m02_m12_m22);
|
||||
|
||||
float4 weights = GET_CASCADE_WEIGHTS(i_positionWS.xyz, z);
|
||||
float4 shadowCoord = GET_SHADOW_COORDINATES(i_positionWS, weights);
|
||||
half shadows = UNITY_SAMPLE_SHADOW(_ShadowMapTexture, shadowCoord);
|
||||
if (_Crest_ClearShadows) shadows = 1.0;
|
||||
shadows = lerp(_LightShadowData.r, 1.0, shadows);
|
||||
|
||||
return shadows;
|
||||
}
|
||||
|
||||
half ComputeShadowFade(const float4 i_positionWS)
|
||||
{
|
||||
float z = dot(i_positionWS.xyz - _WorldSpaceCameraPos.xyz, unity_CameraToWorld._m02_m12_m22);
|
||||
float fadeDistance = UnityComputeShadowFadeDistance(i_positionWS.xyz, z);
|
||||
float fade = UnityComputeShadowFade(fadeDistance);
|
||||
return fade;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if _HRP
|
||||
half SampleShadows(const float4 i_positionWS)
|
||||
{
|
||||
// Get directional light data. By definition we only have one directional light casting shadow.
|
||||
DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex];
|
||||
HDShadowContext context = InitShadowContext();
|
||||
|
||||
// Zeros are for screen space position and world space normal which are for filtering and normal bias
|
||||
// respectively. They did not appear to have an impact.
|
||||
half shadows = GetDirectionalShadowAttenuation(context, 0, i_positionWS.xyz, 0, _DirectionalShadowIndex, -light.forward);
|
||||
// Apply shadow strength from main light.
|
||||
shadows = LerpWhiteTo(shadows, light.shadowDimmer);
|
||||
|
||||
return shadows;
|
||||
}
|
||||
|
||||
half ComputeShadowFade(const float4 i_positionWS)
|
||||
{
|
||||
// TODO: Work out shadow fade.
|
||||
return 0.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if _URP
|
||||
half SampleShadows(const float4 i_positionWS)
|
||||
{
|
||||
// Includes soft shadows if _SHADOWS_SOFT is defined (requires multi-compile pragma).
|
||||
return MainLightRealtimeShadow(TransformWorldToShadowCoord(i_positionWS.xyz));
|
||||
}
|
||||
|
||||
half ComputeShadowFade(const float4 i_positionWS)
|
||||
{
|
||||
return GetShadowFade(i_positionWS.xyz);
|
||||
}
|
||||
#endif
|
||||
|
||||
m_UtilityNameSpaceEnd
|
||||
|
||||
#endif // d_WaveHarmonic_Utility_RenderPipeline_Shadows
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07d6b2cd79ac04fa5b56cffd5fb1bb31
|
||||
ShaderIncludeImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user