Exemple #1
0
 public float4(CGUtility.float3 v, float w = 0f)
 {
     this.x = v.x;
     this.y = v.y;
     this.z = v.z;
     this.w = w;
 }
Exemple #2
0
 private CGUtility.float3 UnpackNormalDXT5nm(CGUtility.float4 packednormal)
 {
     CGUtility.float3 result = new CGUtility.float3(0f, 0f, 0f);
     result.xy = packednormal.wy * 2f - 1f;
     result.z  = Mathf.Sqrt(1f - this.saturate(this.dot(result.xy, result.xy)));
     return(result);
 }
Exemple #3
0
 private void TerrainClip(CGUtility.float3 worldPos)
 {
     if (this.UnderTerrain(worldPos))
     {
         base.clip(0.95f - base.saturate((this.TERRAIN_LEVEL - this.WorldPos.y) / this.SystemCalmHeight));
     }
 }
Exemple #4
0
 public Vector3 NormalAt(Vector3 position, Material material)
 {
     position.y = base.transform.position.y;
     if (material && material.HasProperty("Displacement"))
     {
         this.WATER_BASE(position, 0f);
         this.TERRAIN_DATA();
         this.CameraDisplacement(this.WavesHeight());
         CGUtility.float3 @float = this.WavesNormal();
         if (!float.IsNaN(@float.x) && !float.IsNaN(@float.y) && !float.IsNaN(@float.z))
         {
             return(base.transform.rotation * new Vector3(@float.x, @float.z, @float.y) * this.UnderWater);
         }
     }
     return(Vector3.zero);
 }
Exemple #5
0
 protected bool all(CGUtility.float3 v)
 {
     return(v.x * v.y * v.z != 0f);
 }
Exemple #6
0
 public float2(CGUtility.float3 v)
 {
     this.x = v.x;
     this.y = v.y;
 }
Exemple #7
0
 protected CGUtility.float3 BlendNormals(CGUtility.float3 n1, CGUtility.float3 n2)
 {
     return(this.normalize(new CGUtility.float3(n1.x + n2.x, n1.y + n2.y, n1.z * n2.z)));
 }
Exemple #8
0
 protected CGUtility.float3 normalize(CGUtility.float3 v)
 {
     return(v.normalized);
 }
Exemple #9
0
 private bool UnderTerrain(CGUtility.float3 worldPos)
 {
     this.WATER_BASE(worldPos, base.saturate(base.distance(this.CameraPosition, worldPos) / this.DetailDistance));
     this.TERRAIN_DATA();
     return(this.IS_UNDER_TERRAIN);
 }
Exemple #10
0
 protected CGUtility.float3 lerp(CGUtility.float3 a, CGUtility.float3 b, float x)
 {
     return(new CGUtility.float3(a.x + (b.x - a.x) * x, a.y + (b.y - a.y) * x, a.z + (b.z - a.z) * x));
 }
Exemple #11
0
 protected float dot(CGUtility.float3 a, CGUtility.float3 b)
 {
     return(a.x * b.x + a.y * b.y + a.x * b.z);
 }
Exemple #12
0
 private void CameraUnderWater(CGUtility.float3 CameraPos)
 {
     this.UnderWater = base.saturate(base.sign(CameraPos.y - this.TransformPosition.y - this.CachedWavesHeight)) * 2f - 1f;
 }
Exemple #13
0
 private CGUtility.float3 WavesNormal()
 {
     CGUtility.float3 @float = this.TransformUp;
     if (this.WavesSlots > 0f)
     {
         if (this.WavesCount > 0f)
         {
             @float = this.UnpackBump(this.WavesSample(this.WavesNormalmap1, this.WavesTiling1.x, this.WavesRotation1.x, this.WavesSpeed1.x), this.WavesBump1.x * this.WavesNormalmapBump1);
         }
         if (this.WavesCount > 1f)
         {
             @float = base.BlendNormals(@float, this.UnpackBump(this.WavesSample(this.WavesNormalmap1, this.WavesTiling1.y, this.WavesRotation1.y, this.WavesSpeed1.y), this.WavesBump1.y * this.WavesNormalmapBump1));
         }
         if (this.WavesCount > 2f)
         {
             @float = base.BlendNormals(@float, this.UnpackBump(this.WavesSample(this.WavesNormalmap1, this.WavesTiling1.z, this.WavesRotation1.z, this.WavesSpeed1.z), this.WavesBump1.z * this.WavesNormalmapBump1));
         }
         if (this.WavesCount > 3f)
         {
             @float = base.BlendNormals(@float, this.UnpackBump(this.WavesSample(this.WavesNormalmap1, this.WavesTiling1.w, this.WavesRotation1.w, this.WavesSpeed1.w), this.WavesBump1.w * this.WavesNormalmapBump1));
         }
     }
     if (this.WavesSlots > 1f && this.IS_DETAIL_ONE)
     {
         if (this.WavesCount > 0f)
         {
             @float = base.BlendNormals(@float, this.UnpackBump(this.WavesSample(this.WavesNormalmap2, this.WavesTiling2.x, this.WavesRotation2.x, this.WavesSpeed2.x), this.WavesBump2.x * this.WavesNormalmapBump2));
         }
         if (this.WavesCount > 1f)
         {
             @float = base.BlendNormals(@float, this.UnpackBump(this.WavesSample(this.WavesNormalmap2, this.WavesTiling2.y, this.WavesRotation2.y, this.WavesSpeed2.y), this.WavesBump2.y * this.WavesNormalmapBump2));
         }
         if (this.WavesCount > 2f)
         {
             @float = base.BlendNormals(@float, this.UnpackBump(this.WavesSample(this.WavesNormalmap2, this.WavesTiling2.z, this.WavesRotation2.z, this.WavesSpeed2.z), this.WavesBump2.z * this.WavesNormalmapBump2));
         }
         if (this.WavesCount > 3f)
         {
             @float = base.BlendNormals(@float, this.UnpackBump(this.WavesSample(this.WavesNormalmap2, this.WavesTiling2.w, this.WavesRotation2.w, this.WavesSpeed2.w), this.WavesBump2.w * this.WavesNormalmapBump2));
         }
     }
     if (this.WavesSlots > 2f && this.IS_DETAIL_TWO)
     {
         if (this.WavesCount > 0f)
         {
             @float = base.BlendNormals(@float, this.UnpackBump(this.WavesSample(this.WavesNormalmap3, this.WavesTiling3.x, this.WavesRotation3.x, this.WavesSpeed3.x), this.WavesBump3.x * this.WavesNormalmapBump3));
         }
         if (this.WavesCount > 1f)
         {
             @float = base.BlendNormals(@float, this.UnpackBump(this.WavesSample(this.WavesNormalmap3, this.WavesTiling3.y, this.WavesRotation3.y, this.WavesSpeed3.y), this.WavesBump3.y * this.WavesNormalmapBump3));
         }
         if (this.WavesCount > 2f)
         {
             @float = base.BlendNormals(@float, this.UnpackBump(this.WavesSample(this.WavesNormalmap3, this.WavesTiling3.z, this.WavesRotation3.z, this.WavesSpeed3.z), this.WavesBump3.z * this.WavesNormalmapBump3));
         }
         if (this.WavesCount > 3f)
         {
             @float = base.BlendNormals(@float, this.UnpackBump(this.WavesSample(this.WavesNormalmap3, this.WavesTiling3.w, this.WavesRotation3.w, this.WavesSpeed3.w), this.WavesBump3.w * this.WavesNormalmapBump3));
         }
     }
     if (this.TERRAIN_LEVEL != 0f && this.TERRAIN_LEVEL > this.WorldPos.y - this.SystemCalmHeight)
     {
         @float = base.lerp(this.TransformUp, @float, this.TerrainShore());
     }
     @float = base.lerp(@float, this.TransformUp, this.TERRAIN_BUMP);
     return(base.normalize(@float));
 }
Exemple #14
0
 protected bool any(CGUtility.float3 v)
 {
     return(v.x != 0f || v.y != 0f || v.z != 0f);
 }
Exemple #15
0
 protected float length(CGUtility.float3 v)
 {
     return(v.magnitude);
 }
Exemple #16
0
 protected float distance(CGUtility.float3 a, CGUtility.float3 b)
 {
     return((a - b).magnitude);
 }
Exemple #17
0
 private void WATER_BASE(CGUtility.float3 worldPos, float detail)
 {
     this.WorldPos = worldPos;
     this.LOD      = detail * this.DetailMaxMipMap;
 }