先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
44 lines
1.1 KiB
HLSL
44 lines
1.1 KiB
HLSL
//Functionality to sample the water's displacement pre-pass buffer
|
|
|
|
uniform bool _WaterDisplacementPrePassAvailable;
|
|
|
|
uniform float3 _WaterDisplacementCoords;
|
|
//XY: Bounds min
|
|
//Z: Bounds size
|
|
uniform Texture2D _WaterDisplacementBuffer;
|
|
#ifndef UNITY_CORE_SAMPLERS_INCLUDED
|
|
SamplerState sampler_LinearClamp;
|
|
#endif
|
|
|
|
//Position, relative to rendering bounds (normalized 0-1)
|
|
float2 WorldToDisplacementUV(float3 positionWS)
|
|
{
|
|
return (positionWS.xz - _WaterDisplacementCoords.xy) / _WaterDisplacementCoords.z;
|
|
}
|
|
|
|
float SampleDisplacementBuffer(float2 uv)
|
|
{
|
|
if(_WaterDisplacementPrePassAvailable == false) return 0;
|
|
const float height = _WaterDisplacementBuffer.SampleLevel(sampler_LinearClamp, uv, 0).r;
|
|
|
|
//Need to figure out how to determine if a void is hit
|
|
//if(height == 0.0f) return -1000;
|
|
|
|
return height;
|
|
}
|
|
|
|
//Main function
|
|
float SampleWaterHeight(float3 positionWS)
|
|
{
|
|
return SampleDisplacementBuffer(WorldToDisplacementUV(positionWS));
|
|
}
|
|
|
|
//Shader Graph
|
|
void SampleWaterHeight_float(float3 positionWS, out float height)
|
|
{
|
|
#if defined(SHADERGRAPH_PREVIEW)
|
|
height = 0;
|
|
#else
|
|
height = SampleWaterHeight(positionWS);
|
|
#endif
|
|
} |