#ifndef WATER_LIGHTING_INCLUDED
#define WATER_LIGHTING_INCLUDED
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
//#define PI 3.1415926
half CalculateFresnelTerm(half3 normalWS, half3 viewDirectionWS)
{
    return pow(1.0 - saturate(dot(normalWS, viewDirectionWS)), 10); //fresnel TODO - find a better place
}
half2 SampleReflectionsUV(half3 normalWS, half3 viewDirectionWS, half2 screenUV, half fresnelTerm, half roughness)
{
    half3 reflection = 0;
    half2 refOffset = 0;
    // get the perspective projection
    float2 p11_22 = float2(unity_CameraInvProjection._11, unity_CameraInvProjection._22) * 10;
    // conver the uvs into view space by "undoing" projection
    float3 viewDir = -(float3((screenUV * 2 - 1) / p11_22, -1));

    half3 viewNormal = mul(normalWS, (float3x3)GetWorldToViewMatrix()).xyz;
    half3 reflectVector = reflect(-viewDir, viewNormal);

    half2 reflectionUV = screenUV + normalWS.zx * half2(0.02, 0.15);
    return reflectionUV;
}
#endif