还原水插件
This commit is contained in:
@@ -66,67 +66,6 @@ float4 SampleTextureCatmullRom(in Texture2D<float4> tex, in SamplerState linearS
|
||||
return result;
|
||||
}
|
||||
|
||||
float4 CubicWeights(const float f)
|
||||
{
|
||||
const float f2 = f * f;
|
||||
const float f3 = f2 * f;
|
||||
|
||||
// Catmull–Rom (a = -0.5)
|
||||
return float4
|
||||
(
|
||||
-0.5 * f3 + f2 - 0.5 * f,
|
||||
1.5 * f3 - 2.5 * f2 + 1.0,
|
||||
-1.5 * f3 + 2.0 * f2 + 0.5 * f,
|
||||
0.5 * f3 - 0.5 * f2
|
||||
);
|
||||
}
|
||||
|
||||
float4 SampleBicubicRepeat
|
||||
(
|
||||
const Texture2DArray<float4> i_Texture,
|
||||
const float2 i_UV,
|
||||
const uint2 i_Size,
|
||||
const uint i_Slice
|
||||
)
|
||||
{
|
||||
// Convert to texel space (centered at pixel centers).
|
||||
const float2 samplePosition = i_UV * (float2)i_Size - 0.5;
|
||||
const int2 texelPosition = (int2)floor(samplePosition);
|
||||
const float2 f = samplePosition - (float2)texelPosition;
|
||||
|
||||
// Precompute weights.
|
||||
const float4 wx = CubicWeights(f.x);
|
||||
const float4 wy = CubicWeights(f.y);
|
||||
|
||||
const uint2 size = i_Size - 1;
|
||||
|
||||
const uint4 x = uint4
|
||||
(
|
||||
(texelPosition.x - 1) & size.x,
|
||||
(texelPosition.x + 0) & size.x,
|
||||
(texelPosition.x + 1) & size.x,
|
||||
(texelPosition.x + 2) & size.x
|
||||
);
|
||||
|
||||
// Horizontal pass.
|
||||
float4 row[4];
|
||||
[unroll]
|
||||
for (int j = -1; j <= 2; ++j)
|
||||
{
|
||||
const int y = (texelPosition.y + j) & size.y;
|
||||
|
||||
const float4 t0 = i_Texture[uint3(x.x, y, i_Slice)];
|
||||
const float4 t1 = i_Texture[uint3(x.y, y, i_Slice)];
|
||||
const float4 t2 = i_Texture[uint3(x.z, y, i_Slice)];
|
||||
const float4 t3 = i_Texture[uint3(x.w, y, i_Slice)];
|
||||
|
||||
row[j + 1] = t0 * wx.x + t1 * wx.y + t2 * wx.z + t3 * wx.w;
|
||||
}
|
||||
|
||||
// Vertical pass.
|
||||
return row[0] * wy.x + row[1] * wy.y + row[2] * wy.z + row[3] * wy.w;
|
||||
}
|
||||
|
||||
m_UtilityNameSpaceEnd
|
||||
|
||||
#endif // d_WaveHarmonic_Utility_Filtering
|
||||
|
||||
@@ -43,16 +43,6 @@ float2 WorldNormalToScreenDirection(const float3 i_PositionWS, const float3 i_No
|
||||
return direction;
|
||||
}
|
||||
|
||||
float3 SafeComputeWorldSpacePosition(float2 positionNDC, float deviceDepth, float4x4 invViewProjMatrix)
|
||||
{
|
||||
float4 positionCS = ComputeClipSpacePosition(positionNDC, deviceDepth);
|
||||
float4 hpositionWS = mul(invViewProjMatrix, positionCS);
|
||||
|
||||
// w is sometimes zero when using oblique projection.
|
||||
// Zero is better than NaN.
|
||||
return hpositionWS.w > 0.0 ? hpositionWS.xyz / hpositionWS.w : 0.0;
|
||||
}
|
||||
|
||||
m_UtilityNameSpaceEnd
|
||||
|
||||
#endif // d_WaveHarmonic_Utility_Helpers
|
||||
|
||||
@@ -86,9 +86,6 @@
|
||||
// Transparent Objects Receives Shadows
|
||||
//
|
||||
|
||||
// WebGPU does not like the binding.
|
||||
#ifndef SHADER_API_WEBGPU
|
||||
|
||||
#if _SURFACE_TYPE_TRANSPARENT
|
||||
#if _TRANSPARENT_RECEIVES_SHADOWS
|
||||
#if SHADERPASS == SHADERPASS_FORWARD || SHADERPASS == SHADERPASS_FORWARD_ADD
|
||||
@@ -111,6 +108,4 @@ float4 _ShadowMapTexture_TexelSize;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // SHADER_API_WEBGPU
|
||||
|
||||
#endif // d_WaveHarmonic_Utility_ShaderGraphDefines
|
||||
|
||||
@@ -21,6 +21,24 @@
|
||||
#define CLUSTER_LIGHT_LOOP_SUBTRACTIVE_LIGHT_CHECK FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
|
||||
#endif // FORWARD_PLUS_SUBTRACTIVE_LIGHT_CHECK
|
||||
|
||||
#if UNITY_VERSION >= 60000000
|
||||
#if defined(STEREO_INSTANCING_ON) || defined(STEREO_MULTIVIEW_ON)
|
||||
#if _ALPHATEST_ON
|
||||
#if !USE_CLUSTER_LIGHT_LOOP
|
||||
// If not clustered and additional light shadows and XR, the shading model
|
||||
// completely breaks. It is like shadow attenuation is NaN or some obscure
|
||||
// compiler issue. For 2022.3, it is broken for forward+ only, but cannot be fixed.
|
||||
#define d_ShadowMaskBroken 1
|
||||
#else
|
||||
#if _RECEIVE_SHADOWS_OFF
|
||||
// Right eye broken rendering similar to above.
|
||||
#define d_AdditionalLightsBroken 1
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // CREST_URP
|
||||
|
||||
#if CREST_HDRP
|
||||
@@ -60,10 +78,7 @@ void PrimaryLight
|
||||
#elif CREST_BIRP
|
||||
#ifndef USING_DIRECTIONAL_LIGHT
|
||||
// Yes. This function wants the world position of the surface.
|
||||
o_Direction = UnityWorldSpaceLightDir(i_PositionWS);
|
||||
// Prevents divide by zero.
|
||||
if (all(o_Direction == 0)) o_Direction = half3(0.0, 1.0, 0.0);
|
||||
o_Direction = normalize(o_Direction);
|
||||
o_Direction = normalize(UnityWorldSpaceLightDir(i_PositionWS));
|
||||
#else
|
||||
o_Direction = _WorldSpaceLightPos0.xyz;
|
||||
// Prevents divide by zero.
|
||||
@@ -138,6 +153,14 @@ LIGHT_LOOP_BEGIN(pixelLightCount)
|
||||
// Includes shadows and cookies.
|
||||
Light light = GetAdditionalLight(lightIndex, inputData, shadowMask, aoFactor);
|
||||
|
||||
#if d_ShadowMaskBroken
|
||||
light.shadowAttenuation = 1.0;
|
||||
#endif
|
||||
|
||||
#if d_AdditionalLightsBroken
|
||||
light.color = 0.0;
|
||||
#endif
|
||||
|
||||
#ifdef _LIGHT_LAYERS
|
||||
if (IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user