升级水插件
This commit is contained in:
@@ -8,6 +8,14 @@
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Globals.hlsl"
|
||||
#include "Packages/com.waveharmonic.crest/Runtime/Shaders/Library/Cascade.hlsl"
|
||||
|
||||
// These are per cascade, set per chunk instance.
|
||||
CBUFFER_START(CrestChunkGeometryData)
|
||||
float _Crest_ChunkMeshScaleAlpha;
|
||||
float _Crest_ChunkMeshScaleAlphaSource;
|
||||
float _Crest_ChunkGeometryGridWidth;
|
||||
float _Crest_ChunkGeometryGridWidthSource;
|
||||
CBUFFER_END
|
||||
|
||||
m_CrestNameSpace
|
||||
|
||||
// i_meshScaleAlpha is passed in as it is provided per tile and is set only for LOD0
|
||||
@@ -49,7 +57,8 @@ void SnapAndTransitionVertLayout(in const float4x4 i_objectMatrix, in const floa
|
||||
objectPosXZWS += _WorldSpaceCameraPos.xz;
|
||||
#endif
|
||||
|
||||
io_worldPos.xz -= frac(objectPosXZWS / GRID_SIZE_2) * GRID_SIZE_2; // caution - sign of frac might change in non-hlsl shaders
|
||||
const float2 gridOffset = frac(objectPosXZWS / GRID_SIZE_2) * GRID_SIZE_2;
|
||||
io_worldPos.xz -= gridOffset; // caution - sign of frac might change in non-hlsl shaders
|
||||
|
||||
// compute lod transition alpha
|
||||
o_lodAlpha = ComputeLodAlpha(io_worldPos, i_meshScaleAlpha, i_cascadeData0);
|
||||
@@ -63,6 +72,20 @@ void SnapAndTransitionVertLayout(in const float4x4 i_objectMatrix, in const floa
|
||||
const float minRadius = 0.375;
|
||||
if (abs(offset.x) < minRadius) io_worldPos.x += offset.x * o_lodAlpha * GRID_SIZE_4;
|
||||
if (abs(offset.y) < minRadius) io_worldPos.z += offset.y * o_lodAlpha * GRID_SIZE_4;
|
||||
|
||||
#if SHADER_API_VULKAN
|
||||
#if CREST_HDRP
|
||||
#if _TRANSPARENT_WRITES_MOTION_VEC
|
||||
// Fixes artifacts where parts of the surface appear to be clipped. It appears to
|
||||
// be a precision issue (LOD resolution not power of 2), but only when the MV code
|
||||
// path is active - even though it writes to a separate target.
|
||||
if (any(isinf(gridOffset)))
|
||||
{
|
||||
o_lodAlpha = 0.0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void SnapAndTransitionVertLayout(in const float i_meshScaleAlpha, in const Cascade i_cascadeData0, in const float i_geometryGridSize, inout float3 io_worldPos, out float o_lodAlpha)
|
||||
|
||||
Reference in New Issue
Block a user