#ifndef URP_TRANSFORMS_INCLUDED
#define URP_TRANSFORMS_INCLUDED

//URP 扩展transform

#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

inline float3 ObjSpaceViewDir(in float4 v)
{
    float3 objSpaceCameraPos = mul(unity_WorldToObject, float4(_WorldSpaceCameraPos.xyz, 1)).xyz;
    return objSpaceCameraPos - v.xyz;
}

inline float3 ObjSpaceLightDir(in float4 v)
{
    float3 objSpaceLightPos = mul(unity_WorldToObject, _MainLightPosition.xyz).xyz;
#ifndef USING_LIGHT_MULTI_COMPILE
    return objSpaceLightPos.xyz - v.xyz * _MainLightPosition.w;
#else
#ifndef USING_DIRECTIONAL_LIGHT
    return objSpaceLightPos.xyz - v.xyz;
#else
    return objSpaceLightPos.xyz;
#endif
#endif
}

inline float3 UnityObjectToViewPos(in float3 pos)
{
    return mul(UNITY_MATRIX_V, mul(UNITY_MATRIX_M, float4(pos, 1.0))).xyz;
}
inline float3 UnityObjectToViewPos(float4 pos)
{
    return UnityObjectToViewPos(pos.xyz);
}

#endif