public static void SetKernel(ref SkinData data, List <Vector4> kernel) { Vector3 SSSC = new Vector3(data.SubsurfaceColor.r, data.SubsurfaceColor.g, data.SubsurfaceColor.b); Vector3 SSSFC = new Vector3(data.SubsurfaceFalloff.r, data.SubsurfaceFalloff.g, data.SubsurfaceFalloff.b); SeparableSSS.CalculateKernel(kernel, 11, SSSC, SSSFC); }
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;
void UpdateSubsurface() { ///SSS Color Vector3 SSSC = Vector3.Normalize(new Vector3(SubsurfaceColor.r, SubsurfaceColor.g, SubsurfaceColor.b)); Vector3 SSSFC = Vector3.Normalize(new Vector3(SubsurfaceFalloff.r, SubsurfaceFalloff.g, SubsurfaceFalloff.b)); SeparableSSS.CalculateKernel(KernelArray, 25, SSSC, SSSFC); SubsurfaceEffects.SetVectorArray(Kernel, KernelArray); SubsurfaceEffects.SetFloat(SSSScaler, SubsurfaceScaler); ///SSS Buffer SubsurfaceBuffer.Clear(); SubsurfaceBuffer.GetTemporaryRT(SceneColorID, RenderCamera.pixelWidth, RenderCamera.pixelHeight, 0, FilterMode.Trilinear, RenderTextureFormat.DefaultHDR); SubsurfaceBuffer.BlitStencil(BuiltinRenderTextureType.CameraTarget, SceneColorID, BuiltinRenderTextureType.CameraTarget, SubsurfaceEffects, 0); SubsurfaceBuffer.BlitSRT(SceneColorID, BuiltinRenderTextureType.CameraTarget, SubsurfaceEffects, 1); }
private void DrawSkinBlur() { SkinBlurCommandBuffer.Clear(); ///SSS Color /// 这里不应该normalize Vector3 SSSC = new Vector3(SubsurfaceColor.r, SubsurfaceColor.g, SubsurfaceColor.b); Vector3 SSSFC = new Vector3(SubsurfaceFalloff.r, SubsurfaceFalloff.g, SubsurfaceFalloff.b); SeparableSSS.CalculateKernel(KernelArray, 25, SSSC, SSSFC); SkinBlurEffect.SetVectorArray(Kernel, KernelArray); SkinBlurEffect.SetFloat(SSSScaler, SubsurfaceScaler); SkinBlurCommandBuffer.GetTemporaryRT(SkinBlurRT_TMP_ID, Screen.width, Screen.height, 0, FilterMode.Trilinear, RenderTextureFormat.DefaultHDR); SkinBlurCommandBuffer.BlitStencil(BuiltinRenderTextureType.CameraTarget, SkinBlurRT_TMP_ID, BuiltinRenderTextureType.CameraTarget, SkinBlurEffect, 0); SkinBlurCommandBuffer.BlitStencil(SkinBlurRT_TMP_ID, SkinBlurRT, BuiltinRenderTextureType.CameraTarget, SkinBlurEffect, 1); }
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 void Execute() { SeparableSSS.CalculateKernel(kernel, 11, sssc, sssfc); }