29 lines
919 B
HLSL
29 lines
919 B
HLSL
|
|
//UNITY_SHADER_NO_UPGRADE
|
|
#ifndef WATER_OBJ_INCLUDE
|
|
#define WATER_OBJ_INCLUDE
|
|
|
|
#ifndef GET_TF_FROM_M
|
|
#define GET_TF_FROM_M(m) dot(float3(m[0].w, m[1].w, m[2].w),1)
|
|
#endif
|
|
|
|
inline float3 GetObjWaveDisplacement(float3 positionOS, float4 waterDir, float freq, float intensity, float factor)
|
|
{
|
|
float3 positionWS = TransformObjectToWorld(positionOS);
|
|
float objFreq = _Time.y * freq + positionWS.y ;
|
|
float objPhase = objFreq + GET_TF_FROM_M(GetObjectToWorldMatrix()) * waterDir.w;
|
|
|
|
float branchPhase = objPhase + dot(positionOS.xyz,1);
|
|
|
|
float offset = sin(objPhase) + cos(branchPhase);
|
|
|
|
return normalize(waterDir.xyz) * offset * factor * intensity;
|
|
}
|
|
|
|
void GGetObjWaveDisplacement_float(float3 positionOS, float4 waterDir, float freq, float intensity, float factor, out float3 Out)
|
|
{
|
|
Out = GetObjWaveDisplacement(positionOS, waterDir, freq, intensity, factor);
|
|
}
|
|
|
|
#endif //WATER_OBJ_INCLUDE
|