备份CatanBuilding瘦身独立工程
This commit is contained in:
28
LocalPackages/zzwater/shaders/libs/WaveObj.hlsl
Normal file
28
LocalPackages/zzwater/shaders/libs/WaveObj.hlsl
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
//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
|
||||
Reference in New Issue
Block a user