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); }
private Color tex2Dlod_internal(Texture2D sampler, CGUtility.float4 uv) { if (sampler == null) { return(Color.clear); } uv.x -= (float)((int)uv.x); uv.y -= (float)((int)uv.y); return(sampler.GetPixelBilinear(uv.x, uv.y)); }
private CGUtility.float3 UnpackBump(CGUtility.float4 normal, float bump) { if (base.any(normal.xyz) && bump != 0f) { normal.xyz = base.UnpackNormal(normal).xyz; normal.xy *= bump; return(base.normalize(normal.xyz)); } return(this.TransformUp); }
private CGUtility.float4 WavesSample(Texture2D tex, float tiling, float rotation, float speed) { if (tiling == 0f) { return(0f); } CGUtility.float4 uv = new CGUtility.float4(this.WorldPos.xz, 0f, this.LOD); float num; float num2; base.sincos(base.radians(rotation), out num, out num2); uv.xy = new CGUtility.float2(uv.x * num2 - uv.y * num, uv.x * num + uv.y * num2); uv.x += speed * base._Time.y * this.SystemTime; uv.xy /= tiling; return(base.tex2Dlod(tex, uv)); }
protected bool all(CGUtility.float4 v) { return(v.x * v.y * v.z * v.w != 0f); }
public float3(CGUtility.float4 v) { this.x = v.x; this.y = v.y; this.z = v.z; }
public float2(CGUtility.float4 v) { this.x = v.x; this.y = v.y; }
protected CGUtility.float4 tex2Dlod(Texture2D sampler, CGUtility.float4 uv) { Color color = this.tex2Dlod_internal(sampler, uv); return(new CGUtility.float4(color.r, color.g, color.b, color.a)); }
private void TERRAIN_DATA() { this.terrainData = base.tex2Dlod(this.TerrainFlowHeightmap, this.TerrainCoords()); this.terrainData.xy = this.terrainData.xy * 2f - 1f; this.terrainData.w = this.terrainData.w * this.TerrainHeight; }
protected float length(CGUtility.float4 v) { return(v.magnitude); }
protected CGUtility.float3 UnpackNormal(CGUtility.float4 packednormal) { return(this.UnpackNormalDXT5nm(packednormal)); }
protected CGUtility.float4 lerp(CGUtility.float4 a, CGUtility.float4 b, float x) { return(new CGUtility.float4(a.x + (b.x - a.x) * x, a.y + (b.y - a.y) * x, a.z + (b.z - a.z) * x, a.w + (b.w - a.w) * x)); }
protected float dot(CGUtility.float4 a, CGUtility.float4 b) { return(a.x * b.x + a.y * b.y + a.x * b.z + a.w * b.w); }
protected bool any(CGUtility.float4 v) { return(v.x != 0f || v.y != 0f || v.z != 0f || v.w != 0f); }
protected CGUtility.float4 normalize(CGUtility.float4 v) { return(v.normalized); }
protected float distance(CGUtility.float4 a, CGUtility.float4 b) { return((a - b).magnitude); }
private void LoadProperties(Material material) { if (this.SystemColor.magnitude == 0f && this.SystemValue1 == 0f && this.SystemValue2 == 0f && this.SystemValue3 == 0f && this.SystemValue4 == 0f && this.SystemValue5 == 0f && this.SystemValue6 == 0f && this.SystemVector.magnitude == 0f && this.DetailDistance == 0f && this.DetailMaxMipMap == 0f) { this.Displacement = 0f; } if (this.Flow == 0f && this.TerrainFlowPower == 0f && this.FogDensity == 0f && this.FogPower == 0f) { this.Displacement = 0f; } if (this.Displacement == 0f && this.WavesFoam1.magnitude == 0f && this.WavesFoam2.magnitude == 0f && this.WavesFoam3.magnitude == 0f) { this.Displacement = 0f; } if (this.CachedDisplacement == 0f) { this.Displacement = 0f; } this.SystemColor = material.GetColor("SystemColor"); this.SystemValue1 = material.GetFloat("SystemValue1"); this.SystemValue2 = material.GetFloat("SystemValue2"); this.SystemValue3 = material.GetFloat("SystemValue3"); this.SystemValue4 = material.GetFloat("SystemValue4"); this.SystemValue5 = material.GetFloat("SystemValue5"); this.SystemValue6 = material.GetFloat("SystemValue6"); this.SystemVector = material.GetVector("SystemVector"); this.SystemTime = material.GetFloat("SystemTime"); this.DetailDistance = material.GetFloat("DetailDistance"); this.DetailMaxMipMap = material.GetFloat("DetailMaxMipMap"); this.Terrain_Mapping = material.GetFloat("Terrain_Mapping"); this.TerrainPosition = material.GetVector("TerrainPosition"); this.TerrainResolution = material.GetFloat("TerrainResolution"); this.TerrainFlowHeightmap = (Texture2D)material.GetTexture("TerrainFlowHeightmap"); this.Flow = material.GetFloat("Flow"); this.TerrainFlowPower = material.GetFloat("TerrainFlowPower"); this.TerrainHeight = material.GetFloat("TerrainHeight"); this.SystemCalmHeight = material.GetFloat("SystemCalmHeight"); this.TerrainFog = (Texture2D)material.GetTexture("TerrainFog"); this.FogDensity = material.GetFloat("FogDensity"); this.FogPower = material.GetFloat("FogPower"); this.Displacement = material.GetFloat("Displacement"); this.WavesSlots = material.GetFloat("WavesSlots"); this.WavesCount = material.GetFloat("WavesCount"); this.WavesHeightmap1 = (Texture2D)material.GetTexture("WavesHeightmap1"); this.WavesHeightmap2 = (Texture2D)material.GetTexture("WavesHeightmap2"); this.WavesHeightmap3 = (Texture2D)material.GetTexture("WavesHeightmap3"); this.WavesNormalmap1 = (Texture2D)material.GetTexture("WavesNormalmap1"); this.WavesNormalmap2 = (Texture2D)material.GetTexture("WavesNormalmap2"); this.WavesNormalmap3 = (Texture2D)material.GetTexture("WavesNormalmap3"); this.WavesNormalmapBump1 = material.GetFloat("WavesNormalmapBump1"); this.WavesNormalmapBump2 = material.GetFloat("WavesNormalmapBump2"); this.WavesNormalmapBump3 = material.GetFloat("WavesNormalmapBump3"); this.WavesTiling1 = material.GetVector("WavesTiling1"); this.WavesTiling2 = material.GetVector("WavesTiling2"); this.WavesTiling3 = material.GetVector("WavesTiling3"); this.WavesRotation1 = material.GetVector("WavesRotation1"); this.WavesRotation2 = material.GetVector("WavesRotation2"); this.WavesRotation3 = material.GetVector("WavesRotation3"); this.WavesAmplitude1 = material.GetVector("WavesAmplitude1"); this.WavesAmplitude2 = material.GetVector("WavesAmplitude2"); this.WavesAmplitude3 = material.GetVector("WavesAmplitude3"); this.WavesSpeed1 = material.GetVector("WavesSpeed1"); this.WavesSpeed2 = material.GetVector("WavesSpeed2"); this.WavesSpeed3 = material.GetVector("WavesSpeed3"); this.WavesBump1 = material.GetVector("WavesBump1"); this.WavesBump2 = material.GetVector("WavesBump2"); this.WavesBump3 = material.GetVector("WavesBump3"); this.WavesFoam1 = material.GetVector("WavesFoam1"); this.WavesFoam2 = material.GetVector("WavesFoam2"); this.WavesFoam3 = material.GetVector("WavesFoam3"); }