升级6.4.升级水,升级天气
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
result._Texture = g_Crest_Cascade##name##source; \
|
||||
result._SamplingParameters = g_Crest_SamplingParametersCascade##name##source; \
|
||||
result._Index = i_Index; \
|
||||
result._IndexI = i_Index; \
|
||||
result._PositionSnapped = perSlice.xy; \
|
||||
result._Texel = perSlice.z; \
|
||||
result._Resolution = perType.y; \
|
||||
@@ -56,6 +57,7 @@
|
||||
result._Texture = i_Cascade._Texture; \
|
||||
result._SamplingParameters = i_Cascade._SamplingParameters; \
|
||||
result._Index = i_Index; \
|
||||
result._IndexI = i_Index; \
|
||||
result._PositionSnapped = perSlice.xy; \
|
||||
result._Texel = perSlice.z; \
|
||||
result._Resolution = perType.y; \
|
||||
@@ -70,6 +72,7 @@
|
||||
const float4 perAll = g_Crest_CascadeData##source[i_Index]; \
|
||||
Cascade result; \
|
||||
result._Index = i_Index; \
|
||||
result._IndexI = i_Index; \
|
||||
result._Scale = perAll.x; \
|
||||
result._Weight = perAll.y; \
|
||||
result._MaximumWavelength = perAll.z; \
|
||||
@@ -140,6 +143,51 @@
|
||||
} \
|
||||
} \
|
||||
return result; \
|
||||
} \
|
||||
half4 Sample##name##Overflow(const Texture2DArray i_Texture, const float2 i_Position, const float i_Border) m_ConstantReturn \
|
||||
{ \
|
||||
half4 result = 0.0; \
|
||||
const float3 uv = WorldToUV(i_Position); \
|
||||
const half2 r = abs(uv.xy - 0.5); \
|
||||
const half rMax = 0.5 - _OneOverResolution * i_Border; \
|
||||
if (max(r.x, r.y) <= rMax) \
|
||||
{ \
|
||||
result = Sample(i_Texture, uv); \
|
||||
} \
|
||||
else if ((_Index + 1) < _Count) \
|
||||
{ \
|
||||
const Cascade cascade = Cascade::Make##name(_Index + 1, this); \
|
||||
const float3 uv = cascade.WorldToUV(i_Position); \
|
||||
const half2 r = abs(uv.xy - 0.5); \
|
||||
const half rMax = 0.5 - cascade._OneOverResolution * i_Border; \
|
||||
if (max(r.x, r.y) <= rMax) \
|
||||
{ \
|
||||
result = Sample(i_Texture, uv); \
|
||||
} \
|
||||
} \
|
||||
return result; \
|
||||
} \
|
||||
half4 Sample##name##Overflow(const Texture2DArray i_Texture, const float3 i_UV, const float i_Border) m_ConstantReturn \
|
||||
{ \
|
||||
half4 result = 0.0; \
|
||||
const half2 r = abs(i_UV.xy - 0.5); \
|
||||
const half rMax = 0.5 - _OneOverResolution * i_Border; \
|
||||
if (max(r.x, r.y) <= rMax) \
|
||||
{ \
|
||||
result = Sample(i_Texture, i_UV); \
|
||||
} \
|
||||
else if ((_Index + 1) < _Count) \
|
||||
{ \
|
||||
const Cascade cascade = Cascade::Make##name(_Index + 1, this); \
|
||||
const float3 uv = cascade.WorldToUV(UVToWorld(i_UV)); \
|
||||
const half2 r = abs(uv.xy - 0.5); \
|
||||
const half rMax = 0.5 - cascade._OneOverResolution * i_Border; \
|
||||
if (max(r.x, r.y) <= rMax) \
|
||||
{ \
|
||||
result = Sample(i_Texture, uv); \
|
||||
} \
|
||||
} \
|
||||
return result; \
|
||||
}
|
||||
|
||||
#define m_SampleWeighted(name, type) \
|
||||
@@ -167,6 +215,7 @@ struct Cascade
|
||||
float _Count;
|
||||
float _OneOverResolution;
|
||||
float _Texel;
|
||||
// NOTE: Currently set to Dynamic Waves, as it is only used by SphereWaterInteraction.compute.
|
||||
float _MaximumWavelength;
|
||||
|
||||
float _Scale;
|
||||
@@ -175,6 +224,8 @@ struct Cascade
|
||||
// For copy constructor.
|
||||
float4 _SamplingParameters[MAX_LOD_COUNT];
|
||||
|
||||
uint _IndexI;
|
||||
|
||||
m_MakeCascadeShared
|
||||
m_MakeCascadeSharedPrevious
|
||||
|
||||
@@ -183,6 +234,7 @@ struct Cascade
|
||||
const float4 perAll = i_Previous ? g_Crest_CascadeDataSource[i_Index] : g_Crest_CascadeData[i_Index];
|
||||
Cascade result;
|
||||
result._Index = i_Index;
|
||||
result._IndexI = i_Index;
|
||||
result._Scale = perAll.x;
|
||||
result._Weight = perAll.y;
|
||||
result._MaximumWavelength = perAll.z;
|
||||
@@ -202,19 +254,25 @@ struct Cascade
|
||||
m_MakeCascadeCopy(Depth)
|
||||
m_MakeCascade(DynamicWaves)
|
||||
m_MakeCascadeCopy(DynamicWaves)
|
||||
#ifdef g_Crest_CascadeDynamicWavesSource
|
||||
m_MakeCascadePrevious(DynamicWaves)
|
||||
#endif
|
||||
m_MakeCascade(Flow)
|
||||
m_MakeCascadeCopy(Flow)
|
||||
m_MakeCascade(Foam)
|
||||
m_MakeCascadeCopy(Foam)
|
||||
#ifdef g_Crest_CascadeFoamSource
|
||||
m_MakeCascadePrevious(Foam)
|
||||
#endif
|
||||
m_MakeCascade(Level)
|
||||
m_MakeCascadeCopy(Level)
|
||||
m_MakeCascade(Scattering)
|
||||
m_MakeCascadeCopy(Scattering)
|
||||
m_MakeCascade(Shadow)
|
||||
m_MakeCascadeCopy(Shadow)
|
||||
#ifdef g_Crest_CascadeShadowSource
|
||||
m_MakeCascadePrevious(Shadow)
|
||||
#endif
|
||||
|
||||
// Convert compute shader id to uv texture coordinates
|
||||
float3 IDToUV(const uint2 i_ID) m_ConstantReturn
|
||||
@@ -232,6 +290,12 @@ struct Cascade
|
||||
return float3((i_Position - _PositionSnapped) / (_Texel * _Resolution) + 0.5, _Index);
|
||||
}
|
||||
|
||||
uint3 WorldToID(const float2 i_Position) m_ConstantReturn
|
||||
{
|
||||
const float3 uv = WorldToUV(i_Position);
|
||||
return uint3(uv.xy * _Resolution, _IndexI);
|
||||
}
|
||||
|
||||
float2 IDToWorld(const uint2 i_ID) m_ConstantReturn
|
||||
{
|
||||
return UVToWorld(IDToUV(i_ID));
|
||||
@@ -305,6 +369,7 @@ struct Cascade
|
||||
m_Sample(Depth, half2, .xy)
|
||||
m_SampleWeighted(Depth, half2)
|
||||
m_Sample(DynamicWaves, half2, .xy)
|
||||
m_SampleWeighted(DynamicWaves, half2)
|
||||
m_Sample(Flow, half2, .xy)
|
||||
m_SampleWeighted(Flow, half2)
|
||||
m_Sample(Foam, half, .x)
|
||||
@@ -354,18 +419,15 @@ struct Cascade
|
||||
float4 position = SampleAnimatedWaves(uv);
|
||||
io_LevelOffset += position.w * i_Weight;
|
||||
io_Position += position.xyz * i_Weight;
|
||||
io_Position.y += position.w * i_Weight;
|
||||
|
||||
// Derivatives
|
||||
{
|
||||
// Compute derivative of water level - needed to get base normal of water. Water
|
||||
// normal, normal map etc is then added to base normal.
|
||||
const float2 dd = float2(_OneOverResolution, 0.0);
|
||||
const float xOffset = SampleAnimatedWaves(uv + dd.xyy).w;
|
||||
const float zOffset = SampleAnimatedWaves(uv + dd.yxy).w;
|
||||
|
||||
// TODO: Is weight in correct position?
|
||||
io_Derivatives.x += i_Weight * (xOffset - position.w) / _Texel;
|
||||
io_Derivatives.y += i_Weight * (zOffset - position.w) / _Texel;
|
||||
const float2 offset = float2(SampleAnimatedWaves(uv + dd.xyy).w, SampleAnimatedWaves(uv + dd.yxy).w);
|
||||
io_Derivatives += ((offset - position.w) / _Texel) * i_Weight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,8 +467,7 @@ struct Cascade
|
||||
return normalize(xProduct).xz;
|
||||
}
|
||||
|
||||
// TODO: Rename
|
||||
void SampleNormals(const float2 i_Position, const float i_Weight, inout half2 io_Normal, inout half io_Determinant) m_ConstantReturn
|
||||
void SampleDisplacementNormal(const float2 i_Position, const float i_Weight, inout half2 io_Normal, inout half io_Determinant) m_ConstantReturn
|
||||
{
|
||||
float3 xDisplacement; float3 zDisplacement;
|
||||
half3 displacement = __SampleDisplacements(i_Position, xDisplacement, zDisplacement).xyz;
|
||||
@@ -456,6 +517,13 @@ struct Cascade
|
||||
return value;
|
||||
}
|
||||
|
||||
void SampleSignedDepthFromSeaLevelAndDistance(const float2 i_Position, const float i_Weight, inout half io_Depth, inout half io_Distance) m_ConstantReturn
|
||||
{
|
||||
const half2 value = SampleSignedDepthFromSeaLevelAndDistance(i_Position) * i_Weight;
|
||||
io_Depth += value.x;
|
||||
io_Distance += value.y;
|
||||
}
|
||||
|
||||
void SampleSignedDepthFromSeaLevel(const float2 i_Position, const float i_Weight, inout half io_Depth) m_ConstantReturn
|
||||
{
|
||||
io_Depth += (g_Crest_WaterCenter.y - SampleSceneHeight(i_Position)) * i_Weight;
|
||||
|
||||
Reference in New Issue
Block a user