public int AddProfile(SubsurfaceProfileData data, SubsurfaceProfile profile) { int subsurfaceProfileEntry = -1; int num = 0; while (num < this.entries.Count) { if (this.entries[num].profile != profile) { num++; } else { subsurfaceProfileEntry = num; this.entries[subsurfaceProfileEntry] = new SubsurfaceProfileTexture.SubsurfaceProfileEntry(data, profile); break; } } if (subsurfaceProfileEntry < 0) { subsurfaceProfileEntry = this.entries.Count; this.entries.Add(new SubsurfaceProfileTexture.SubsurfaceProfileEntry(data, profile)); } this.ReleaseTexture(); return(subsurfaceProfileEntry); }
private Texture2D CreateTexture() { if (this.entries.Count <= 0) { return((Texture2D)null); } int length = 32; int num1 = Mathf.Max(this.entries.Count, 64); this.ReleaseTexture(); this.texture = new Texture2D(length, num1, (TextureFormat)17, false, true); ((Object)this.texture).set_name("SubsurfaceProfiles"); ((UnityEngine.Texture) this.texture).set_wrapMode((TextureWrapMode)1); ((UnityEngine.Texture) this.texture).set_filterMode((FilterMode)1); Color[] pixels = this.texture.GetPixels(0); for (int index = 0; index < pixels.Length; ++index) { pixels[index] = Color.get_clear(); } Color[] target = new Color[length]; for (int index1 = 0; index1 < this.entries.Count; ++index1) { SubsurfaceProfileData data = this.entries[index1].data; data.SubsurfaceColor = SubsurfaceProfileTexture.ColorClamp(data.SubsurfaceColor, 0.0f, 1f); data.FalloffColor = SubsurfaceProfileTexture.ColorClamp(data.FalloffColor, 0.009f, 1f); target[0] = data.SubsurfaceColor; target[0].a = (__Null)0.0; SeparableSSS.CalculateKernel(target, 1, 13, data.SubsurfaceColor, data.FalloffColor); SeparableSSS.CalculateKernel(target, 14, 9, data.SubsurfaceColor, data.FalloffColor); SeparableSSS.CalculateKernel(target, 23, 6, data.SubsurfaceColor, data.FalloffColor); int num2 = length * (num1 - index1 - 1); for (int index2 = 0; index2 < 29; ++index2) { Color color = Color.op_Multiply(target[index2], new Color(1f, 1f, 1f, 0.3333333f)); ref __Null local = ref color.a;
public void UpdateProfile(int id, SubsurfaceProfileData data) { if (id < 0) { return; } this.entries[id] = new SubsurfaceProfileTexture.SubsurfaceProfileEntry(data, this.entries[id].profile); this.ReleaseTexture(); }
private Texture2D CreateTexture() { if (this.entries.Count <= 0) { return(null); } int num = 32; int num1 = Mathf.Max(this.entries.Count, 64); this.ReleaseTexture(); this.texture = new Texture2D(num, num1, TextureFormat.RGBAHalf, false, true) { name = "SubsurfaceProfiles", wrapMode = TextureWrapMode.Clamp, filterMode = FilterMode.Bilinear }; Color[] pixels = this.texture.GetPixels(0); for (int i = 0; i < (int)pixels.Length; i++) { pixels[i] = Color.clear; } Color[] subsurfaceColor = new Color[num]; for (int j = 0; j < this.entries.Count; j++) { SubsurfaceProfileData item = this.entries[j].data; item.SubsurfaceColor = SubsurfaceProfileTexture.ColorClamp(item.SubsurfaceColor, 0f, 1f); item.FalloffColor = SubsurfaceProfileTexture.ColorClamp(item.FalloffColor, 0.009f, 1f); subsurfaceColor[0] = item.SubsurfaceColor; subsurfaceColor[0].a = 0f; SeparableSSS.CalculateKernel(subsurfaceColor, 1, 13, item.SubsurfaceColor, item.FalloffColor); SeparableSSS.CalculateKernel(subsurfaceColor, 14, 9, item.SubsurfaceColor, item.FalloffColor); SeparableSSS.CalculateKernel(subsurfaceColor, 23, 6, item.SubsurfaceColor, item.FalloffColor); int num2 = num * (num1 - j - 1); for (int k = 0; k < 29; k++) { Color color = subsurfaceColor[k] * new Color(1f, 1f, 1f, 0.333333343f); ref float scatterRadius = ref color.a; scatterRadius = scatterRadius * (item.ScatterRadius / 1024f); pixels[num2 + k] = color; } }
public int AddProfile(SubsurfaceProfileData data, SubsurfaceProfile profile) { int index1 = -1; for (int index2 = 0; index2 < this.entries.Count; ++index2) { if (Object.op_Equality((Object)this.entries[index2].profile, (Object)profile)) { index1 = index2; this.entries[index1] = new SubsurfaceProfileTexture.SubsurfaceProfileEntry(data, profile); break; } } if (index1 < 0) { index1 = this.entries.Count; this.entries.Add(new SubsurfaceProfileTexture.SubsurfaceProfileEntry(data, profile)); } this.ReleaseTexture(); return(index1); }