├── Assembly-CSharp-Editor.csproj ├── Assembly-CSharp.csproj ├── Assets ├── Demo.meta ├── Demo │ ├── Jade.mat │ ├── Jade.mat.meta │ ├── jiji - skin.mat │ ├── jiji - skin.mat.meta │ ├── jiji diffuse.png │ ├── jiji diffuse.png.meta │ ├── jiji displace.png │ ├── jiji displace.png.meta │ ├── jiji normal.png │ ├── jiji normal.png.meta │ ├── jiji sgd.png │ ├── jiji sgd.png.meta │ ├── jijiBackup.FBX │ └── jijiBackup.FBX.meta ├── Editor.meta ├── Editor │ ├── CubeMapCapture.cs │ ├── CubeMapCapture.cs.meta │ ├── SnowShaderEditor.cs │ ├── SnowShaderEditor.cs.meta │ ├── SpecularShaderEditor.cs │ ├── SpecularShaderEditor.cs.meta │ ├── TextureMixer.cs │ ├── TextureMixer.cs.meta │ ├── WaterShader.cs │ └── WaterShader.cs.meta ├── Shader.meta ├── Shader │ ├── SkinShader.meta │ └── SkinShader │ │ ├── DiffuseScatteringOnRing.png │ │ ├── DiffuseScatteringOnRing.png.meta │ │ ├── Scripts.meta │ │ ├── Scripts │ │ ├── SSSSSCamera.cs │ │ ├── SSSSSCamera.cs.meta │ │ ├── SSSSSDepthCamera.cs │ │ ├── SSSSSDepthCamera.cs.meta │ │ ├── SSSSSDepthCullCam.cs │ │ ├── SSSSSDepthCullCam.cs.meta │ │ ├── SSSSSSkinRenderer.cs │ │ └── SSSSSSkinRenderer.cs.meta │ │ ├── Shaders.meta │ │ └── Shaders │ │ ├── Depth.shader │ │ ├── Depth.shader.meta │ │ ├── DepthCull.shader │ │ ├── DepthCull.shader.meta │ │ ├── DepthCullFront.shader │ │ ├── DepthCullFront.shader.meta │ │ ├── SSSSS.shader │ │ ├── SSSSS.shader.meta │ │ ├── Tess-SSS.shader │ │ ├── Tess-SSS.shader.meta │ │ ├── Tess-Skin.shader │ │ └── Tess-Skin.shader.meta ├── SkinDemo.unity ├── SkinDemo.unity.meta ├── Subsurface Jade Demo.unity └── Subsurface Jade Demo.unity.meta ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── PresetManager.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset └── UnityConnectSettings.asset ├── README.md ├── Subsurface Skin.sln ├── Subsurface Skin.userprefs └── UnityPackageManager └── manifest.json /Assembly-CSharp-Editor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 6 5 | 6 | 7 | Debug 8 | AnyCPU 9 | 10.0.20506 10 | 2.0 11 | 12 | {A2B4F519-8932-863A-5BC4-5C8A9E6BC10F} 13 | Library 14 | Properties 15 | Assembly-CSharp-Editor 16 | v4.6 17 | 512 18 | Assets 19 | 20 | 21 | true 22 | full 23 | false 24 | Temp\bin\Debug\ 25 | DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_6_OR_NEWER;UNITY_2017_1_OR_NEWER;UNITY_2017_2_OR_NEWER;UNITY_2017_3_OR_NEWER;UNITY_2017_3_1;UNITY_2017_3;UNITY_2017;PLATFORM_ARCH_64;UNITY_64;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_GENERICS;ENABLE_PVR_GI;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_GRID;ENABLE_TILEMAP;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_DIRECTOR;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_HUB;ENABLE_EDITOR_HUB_LICENSE;ENABLE_WEBSOCKET_CLIENT;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_TIMELINE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;ENABLE_NATIVE_ARRAY;ENABLE_SPRITE_MASKING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;ENABLE_MONO_BDWGC;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;INCLUDE_PUBNUB;ENABLE_PLAYMODE_TESTS_RUNNER;ENABLE_VIDEO;ENABLE_RMGUI;ENABLE_PACKMAN;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_STYLE_SHEETS;ENABLE_LOCALIZATION;PLATFORM_STANDALONE_WIN;PLATFORM_STANDALONE;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_VR;ENABLE_AR;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;NET_4_6;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;ENABLE_NATIVE_ARRAY_CHECKS;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE;AMPLIFY_SHADER_EDITOR;CROSS_PLATFORM_INPUT;UNITY_POST_PROCESSING_STACK_V2 26 | prompt 27 | 4 28 | 0169 29 | true 30 | 31 | 32 | pdbonly 33 | true 34 | Temp\bin\Release\ 35 | prompt 36 | 4 37 | 0169 38 | true 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | C:\Unity\Editor\Data\Managed\UnityEngine.dll 48 | 49 | 50 | C:/Unity/Editor/Data/Managed/UnityEditor.dll 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | C:/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll 61 | 62 | 63 | C:/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/Editor/UnityEditor.UI.dll 64 | 65 | 66 | C:/Unity/Editor/Data/UnityExtensions/Unity/Networking/UnityEngine.Networking.dll 67 | 68 | 69 | C:/Unity/Editor/Data/UnityExtensions/Unity/Networking/Editor/UnityEditor.Networking.dll 70 | 71 | 72 | C:/Unity/Editor/Data/UnityExtensions/Unity/TestRunner/Editor/UnityEditor.TestRunner.dll 73 | 74 | 75 | C:/Unity/Editor/Data/UnityExtensions/Unity/TestRunner/UnityEngine.TestRunner.dll 76 | 77 | 78 | C:/Unity/Editor/Data/UnityExtensions/Unity/TestRunner/net35/unity-custom/nunit.framework.dll 79 | 80 | 81 | C:/Unity/Editor/Data/UnityExtensions/Unity/Timeline/RuntimeEditor/UnityEngine.Timeline.dll 82 | 83 | 84 | C:/Unity/Editor/Data/UnityExtensions/Unity/Timeline/Editor/UnityEditor.Timeline.dll 85 | 86 | 87 | C:/Unity/Editor/Data/UnityExtensions/Unity/TreeEditor/Editor/UnityEditor.TreeEditor.dll 88 | 89 | 90 | C:/Unity/Editor/Data/UnityExtensions/Unity/UIAutomation/UnityEngine.UIAutomation.dll 91 | 92 | 93 | C:/Unity/Editor/Data/UnityExtensions/Unity/UIAutomation/Editor/UnityEditor.UIAutomation.dll 94 | 95 | 96 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnityGoogleAudioSpatializer/Editor/UnityEditor.GoogleAudioSpatializer.dll 97 | 98 | 99 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnityGoogleAudioSpatializer/RuntimeEditor/UnityEngine.GoogleAudioSpatializer.dll 100 | 101 | 102 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/Editor/UnityEditor.HoloLens.dll 103 | 104 | 105 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll 106 | 107 | 108 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnitySpatialTracking/Editor/UnityEditor.SpatialTracking.dll 109 | 110 | 111 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnitySpatialTracking/RuntimeEditor/UnityEngine.SpatialTracking.dll 112 | 113 | 114 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/Editor/UnityEditor.VR.dll 115 | 116 | 117 | C:/Unity/Editor/Data/Managed/UnityEditor.Graphs.dll 118 | 119 | 120 | C:/Unity/Editor/Data/PlaybackEngines/AndroidPlayer/UnityEditor.Android.Extensions.dll 121 | 122 | 123 | C:/Unity/Editor/Data/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.dll 124 | 125 | 126 | C:/Unity/Editor/Data/PlaybackEngines/LinuxStandaloneSupport/UnityEditor.LinuxStandalone.Extensions.dll 127 | 128 | 129 | C:/Unity/Editor/Data/PlaybackEngines/windowsstandalonesupport/UnityEditor.WindowsStandalone.Extensions.dll 130 | 131 | 132 | C:/Unity/Editor/Data/PlaybackEngines/MacStandaloneSupport/UnityEditor.OSXStandalone.Extensions.dll 133 | 134 | 135 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.ads@2.0.3/UnityEngine.Advertisements.dll 136 | 137 | 138 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.ads@2.0.3/Editor/UnityEditor.Advertisements.dll 139 | 140 | 141 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.analytics@2.0.13/UnityEngine.Analytics.dll 142 | 143 | 144 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.analytics@2.0.13/Editor/UnityEditor.Analytics.dll 145 | 146 | 147 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.purchasing@0.0.19/UnityEngine.Purchasing.dll 148 | 149 | 150 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.purchasing@0.0.19/Editor/UnityEditor.Purchasing.dll 151 | 152 | 153 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.standardevents@1.0.10/UnityEngine.StandardEvents.dll 154 | 155 | 156 | C:/Unity/Editor/Data/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.Xcode.dll 157 | 158 | 159 | C:/Unity/Editor/Data/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.Common.dll 160 | 161 | 162 | 163 | 164 | {37D3C424-42C5-A773-D4EA-A048BF8BEEEC} Assembly-CSharp 165 | 166 | 167 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /Assembly-CSharp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 6 5 | 6 | 7 | Debug 8 | AnyCPU 9 | 10.0.20506 10 | 2.0 11 | 12 | {37D3C424-42C5-A773-D4EA-A048BF8BEEEC} 13 | Library 14 | Properties 15 | Assembly-CSharp 16 | v4.6 17 | 512 18 | Assets 19 | 20 | 21 | true 22 | full 23 | false 24 | Temp\bin\Debug\ 25 | DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_6_OR_NEWER;UNITY_2017_1_OR_NEWER;UNITY_2017_2_OR_NEWER;UNITY_2017_3_OR_NEWER;UNITY_2017_3_1;UNITY_2017_3;UNITY_2017;PLATFORM_ARCH_64;UNITY_64;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_GENERICS;ENABLE_PVR_GI;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_GRID;ENABLE_TILEMAP;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_DIRECTOR;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_COLLAB_SOFTLOCKS;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_USE_WEBREQUEST;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_HUB;ENABLE_EDITOR_HUB_LICENSE;ENABLE_WEBSOCKET_CLIENT;ENABLE_DIRECTOR_AUDIO;ENABLE_DIRECTOR_TEXTURE;ENABLE_TIMELINE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;ENABLE_NATIVE_ARRAY;ENABLE_SPRITE_MASKING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;ENABLE_MONO_BDWGC;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;INCLUDE_PUBNUB;ENABLE_PLAYMODE_TESTS_RUNNER;ENABLE_VIDEO;ENABLE_RMGUI;ENABLE_PACKMAN;ENABLE_CUSTOM_RENDER_TEXTURE;ENABLE_STYLE_SHEETS;ENABLE_LOCALIZATION;PLATFORM_STANDALONE_WIN;PLATFORM_STANDALONE;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_VR;ENABLE_AR;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;NET_4_6;ENABLE_PROFILER;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;ENABLE_NATIVE_ARRAY_CHECKS;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE;AMPLIFY_SHADER_EDITOR;CROSS_PLATFORM_INPUT;UNITY_POST_PROCESSING_STACK_V2 26 | prompt 27 | 4 28 | 0169 29 | true 30 | 31 | 32 | pdbonly 33 | true 34 | Temp\bin\Release\ 35 | prompt 36 | 4 37 | 0169 38 | true 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | C:\Unity\Editor\Data\Managed\UnityEngine.dll 48 | 49 | 50 | C:/Unity/Editor/Data/Managed/UnityEditor.dll 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | C:/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/UnityEngine.UI.dll 66 | 67 | 68 | C:/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/Editor/UnityEditor.UI.dll 69 | 70 | 71 | C:/Unity/Editor/Data/UnityExtensions/Unity/Networking/UnityEngine.Networking.dll 72 | 73 | 74 | C:/Unity/Editor/Data/UnityExtensions/Unity/Networking/Editor/UnityEditor.Networking.dll 75 | 76 | 77 | C:/Unity/Editor/Data/UnityExtensions/Unity/TestRunner/Editor/UnityEditor.TestRunner.dll 78 | 79 | 80 | C:/Unity/Editor/Data/UnityExtensions/Unity/TestRunner/UnityEngine.TestRunner.dll 81 | 82 | 83 | C:/Unity/Editor/Data/UnityExtensions/Unity/TestRunner/net35/unity-custom/nunit.framework.dll 84 | 85 | 86 | C:/Unity/Editor/Data/UnityExtensions/Unity/Timeline/RuntimeEditor/UnityEngine.Timeline.dll 87 | 88 | 89 | C:/Unity/Editor/Data/UnityExtensions/Unity/Timeline/Editor/UnityEditor.Timeline.dll 90 | 91 | 92 | C:/Unity/Editor/Data/UnityExtensions/Unity/TreeEditor/Editor/UnityEditor.TreeEditor.dll 93 | 94 | 95 | C:/Unity/Editor/Data/UnityExtensions/Unity/UIAutomation/UnityEngine.UIAutomation.dll 96 | 97 | 98 | C:/Unity/Editor/Data/UnityExtensions/Unity/UIAutomation/Editor/UnityEditor.UIAutomation.dll 99 | 100 | 101 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnityGoogleAudioSpatializer/Editor/UnityEditor.GoogleAudioSpatializer.dll 102 | 103 | 104 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnityGoogleAudioSpatializer/RuntimeEditor/UnityEngine.GoogleAudioSpatializer.dll 105 | 106 | 107 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/Editor/UnityEditor.HoloLens.dll 108 | 109 | 110 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnityHoloLens/RuntimeEditor/UnityEngine.HoloLens.dll 111 | 112 | 113 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnitySpatialTracking/Editor/UnityEditor.SpatialTracking.dll 114 | 115 | 116 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnitySpatialTracking/RuntimeEditor/UnityEngine.SpatialTracking.dll 117 | 118 | 119 | C:/Unity/Editor/Data/UnityExtensions/Unity/UnityVR/Editor/UnityEditor.VR.dll 120 | 121 | 122 | C:/Unity/Editor/Data/Managed/UnityEditor.Graphs.dll 123 | 124 | 125 | C:/Unity/Editor/Data/PlaybackEngines/AndroidPlayer/UnityEditor.Android.Extensions.dll 126 | 127 | 128 | C:/Unity/Editor/Data/PlaybackEngines/iOSSupport/UnityEditor.iOS.Extensions.dll 129 | 130 | 131 | C:/Unity/Editor/Data/PlaybackEngines/LinuxStandaloneSupport/UnityEditor.LinuxStandalone.Extensions.dll 132 | 133 | 134 | C:/Unity/Editor/Data/PlaybackEngines/windowsstandalonesupport/UnityEditor.WindowsStandalone.Extensions.dll 135 | 136 | 137 | C:/Unity/Editor/Data/PlaybackEngines/MacStandaloneSupport/UnityEditor.OSXStandalone.Extensions.dll 138 | 139 | 140 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.ads@2.0.3/UnityEngine.Advertisements.dll 141 | 142 | 143 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.ads@2.0.3/Editor/UnityEditor.Advertisements.dll 144 | 145 | 146 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.analytics@2.0.13/UnityEngine.Analytics.dll 147 | 148 | 149 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.analytics@2.0.13/Editor/UnityEditor.Analytics.dll 150 | 151 | 152 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.purchasing@0.0.19/UnityEngine.Purchasing.dll 153 | 154 | 155 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.purchasing@0.0.19/Editor/UnityEditor.Purchasing.dll 156 | 157 | 158 | C:/Users/User/AppData/LocalLow/Unity/cache/packages/packages.unity.com/com.unity.standardevents@1.0.10/UnityEngine.StandardEvents.dll 159 | 160 | 161 | 162 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /Assets/Demo.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3e309bc3932f414cba220597b8b5c60 3 | folderAsset: yes 4 | timeCreated: 1521672893 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Demo/Jade.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/Assets/Demo/Jade.mat -------------------------------------------------------------------------------- /Assets/Demo/Jade.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d39a0dca8cd247843b2ea3e8456b50db 3 | timeCreated: 1521673287 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | externalObjects: {} 7 | mainObjectFileID: 2100000 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Demo/jiji - skin.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/Assets/Demo/jiji - skin.mat -------------------------------------------------------------------------------- /Assets/Demo/jiji - skin.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2bf585c3ef856bf448694125c966fe89 3 | timeCreated: 18446744011573954816 4 | NativeFormatImporter: 5 | externalObjects: {} 6 | mainObjectFileID: 0 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Demo/jiji diffuse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/Assets/Demo/jiji diffuse.png -------------------------------------------------------------------------------- /Assets/Demo/jiji diffuse.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 73a682f299b1bd64a90eb98a58d43df2 3 | timeCreated: 18446744011573954816 4 | TextureImporter: 5 | fileIDToRecycleName: {} 6 | externalObjects: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapsPreserveCoverage: 0 16 | alphaTestReferenceValue: 0.5 17 | mipMapFadeDistanceStart: 1 18 | mipMapFadeDistanceEnd: 3 19 | bumpmap: 20 | convertToNormalMap: 0 21 | externalNormalMap: 0 22 | heightScale: 0.25 23 | normalMapFilter: 0 24 | isReadable: 0 25 | grayScaleToAlpha: 0 26 | generateCubemap: 6 27 | cubemapConvolution: 0 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 4096 31 | textureSettings: 32 | serializedVersion: 2 33 | filterMode: -1 34 | aniso: -1 35 | mipBias: -1 36 | wrapU: 1 37 | wrapV: 1 38 | wrapW: 1 39 | nPOTScale: 1 40 | lightmap: 0 41 | compressionQuality: 50 42 | spriteMode: 0 43 | spriteExtrude: 1 44 | spriteMeshType: 1 45 | alignment: 0 46 | spritePivot: {x: 0.5, y: 0.5} 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spritePixelsToUnits: 100 49 | alphaUsage: 1 50 | alphaIsTransparency: 0 51 | spriteTessellationDetail: -1 52 | textureType: 0 53 | textureShape: 1 54 | maxTextureSizeSet: 0 55 | compressionQualitySet: 0 56 | textureFormatSet: 0 57 | platformSettings: 58 | - buildTarget: DefaultTexturePlatform 59 | maxTextureSize: 4096 60 | resizeAlgorithm: 0 61 | textureFormat: -1 62 | textureCompression: 1 63 | compressionQuality: 50 64 | crunchedCompression: 0 65 | allowsAlphaSplitting: 0 66 | overridden: 0 67 | androidETC2FallbackOverride: 0 68 | spriteSheet: 69 | serializedVersion: 2 70 | sprites: [] 71 | outline: [] 72 | physicsShape: [] 73 | spritePackingTag: 74 | userData: 75 | assetBundleName: 76 | assetBundleVariant: 77 | -------------------------------------------------------------------------------- /Assets/Demo/jiji displace.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/Assets/Demo/jiji displace.png -------------------------------------------------------------------------------- /Assets/Demo/jiji displace.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 647be0c0462523d4ea09db0cef05550a 3 | timeCreated: 18446744011573954816 4 | TextureImporter: 5 | fileIDToRecycleName: {} 6 | externalObjects: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 0 12 | linearTexture: 1 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapsPreserveCoverage: 0 16 | alphaTestReferenceValue: 0.5 17 | mipMapFadeDistanceStart: 1 18 | mipMapFadeDistanceEnd: 3 19 | bumpmap: 20 | convertToNormalMap: 0 21 | externalNormalMap: 0 22 | heightScale: 0.25 23 | normalMapFilter: 0 24 | isReadable: 0 25 | grayScaleToAlpha: 0 26 | generateCubemap: 6 27 | cubemapConvolution: 0 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 4096 31 | textureSettings: 32 | serializedVersion: 2 33 | filterMode: -1 34 | aniso: -1 35 | mipBias: -1 36 | wrapU: 1 37 | wrapV: 1 38 | wrapW: 1 39 | nPOTScale: 1 40 | lightmap: 0 41 | compressionQuality: 50 42 | spriteMode: 0 43 | spriteExtrude: 1 44 | spriteMeshType: 1 45 | alignment: 0 46 | spritePivot: {x: 0.5, y: 0.5} 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spritePixelsToUnits: 100 49 | alphaUsage: 1 50 | alphaIsTransparency: 0 51 | spriteTessellationDetail: -1 52 | textureType: 0 53 | textureShape: 1 54 | maxTextureSizeSet: 0 55 | compressionQualitySet: 0 56 | textureFormatSet: 0 57 | platformSettings: 58 | - buildTarget: DefaultTexturePlatform 59 | maxTextureSize: 4096 60 | resizeAlgorithm: 0 61 | textureFormat: -1 62 | textureCompression: 1 63 | compressionQuality: 50 64 | crunchedCompression: 0 65 | allowsAlphaSplitting: 0 66 | overridden: 0 67 | androidETC2FallbackOverride: 0 68 | spriteSheet: 69 | serializedVersion: 2 70 | sprites: [] 71 | outline: [] 72 | physicsShape: [] 73 | spritePackingTag: 74 | userData: 75 | assetBundleName: 76 | assetBundleVariant: 77 | -------------------------------------------------------------------------------- /Assets/Demo/jiji normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/Assets/Demo/jiji normal.png -------------------------------------------------------------------------------- /Assets/Demo/jiji normal.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 877052f5e0a416a4e95d632452245701 3 | timeCreated: 18446744011573954816 4 | TextureImporter: 5 | fileIDToRecycleName: {} 6 | externalObjects: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 0 12 | linearTexture: 1 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapsPreserveCoverage: 0 16 | alphaTestReferenceValue: 0.5 17 | mipMapFadeDistanceStart: 1 18 | mipMapFadeDistanceEnd: 3 19 | bumpmap: 20 | convertToNormalMap: 0 21 | externalNormalMap: 1 22 | heightScale: 0.25 23 | normalMapFilter: 0 24 | isReadable: 0 25 | grayScaleToAlpha: 0 26 | generateCubemap: 6 27 | cubemapConvolution: 0 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 4096 31 | textureSettings: 32 | serializedVersion: 2 33 | filterMode: -1 34 | aniso: -1 35 | mipBias: -1 36 | wrapU: 1 37 | wrapV: 1 38 | wrapW: 1 39 | nPOTScale: 1 40 | lightmap: 0 41 | compressionQuality: 50 42 | spriteMode: 0 43 | spriteExtrude: 1 44 | spriteMeshType: 1 45 | alignment: 0 46 | spritePivot: {x: 0.5, y: 0.5} 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spritePixelsToUnits: 100 49 | alphaUsage: 1 50 | alphaIsTransparency: 0 51 | spriteTessellationDetail: -1 52 | textureType: 1 53 | textureShape: 1 54 | maxTextureSizeSet: 0 55 | compressionQualitySet: 0 56 | textureFormatSet: 0 57 | platformSettings: 58 | - buildTarget: DefaultTexturePlatform 59 | maxTextureSize: 4096 60 | resizeAlgorithm: 0 61 | textureFormat: -1 62 | textureCompression: 0 63 | compressionQuality: 50 64 | crunchedCompression: 0 65 | allowsAlphaSplitting: 0 66 | overridden: 0 67 | androidETC2FallbackOverride: 0 68 | spriteSheet: 69 | serializedVersion: 2 70 | sprites: [] 71 | outline: [] 72 | physicsShape: [] 73 | spritePackingTag: 74 | userData: 75 | assetBundleName: 76 | assetBundleVariant: 77 | -------------------------------------------------------------------------------- /Assets/Demo/jiji sgd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/Assets/Demo/jiji sgd.png -------------------------------------------------------------------------------- /Assets/Demo/jiji sgd.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b7e067110c074a46ae27bebf1eccf46 3 | timeCreated: 18446744011573954816 4 | TextureImporter: 5 | fileIDToRecycleName: {} 6 | externalObjects: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 0 12 | linearTexture: 1 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapsPreserveCoverage: 0 16 | alphaTestReferenceValue: 0.5 17 | mipMapFadeDistanceStart: 1 18 | mipMapFadeDistanceEnd: 3 19 | bumpmap: 20 | convertToNormalMap: 0 21 | externalNormalMap: 0 22 | heightScale: 0.25 23 | normalMapFilter: 0 24 | isReadable: 0 25 | grayScaleToAlpha: 0 26 | generateCubemap: 6 27 | cubemapConvolution: 0 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 4096 31 | textureSettings: 32 | serializedVersion: 2 33 | filterMode: -1 34 | aniso: -1 35 | mipBias: -1 36 | wrapU: 1 37 | wrapV: 1 38 | wrapW: 1 39 | nPOTScale: 1 40 | lightmap: 0 41 | compressionQuality: 50 42 | spriteMode: 0 43 | spriteExtrude: 1 44 | spriteMeshType: 1 45 | alignment: 0 46 | spritePivot: {x: 0.5, y: 0.5} 47 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 48 | spritePixelsToUnits: 100 49 | alphaUsage: 1 50 | alphaIsTransparency: 0 51 | spriteTessellationDetail: -1 52 | textureType: 0 53 | textureShape: 1 54 | maxTextureSizeSet: 0 55 | compressionQualitySet: 0 56 | textureFormatSet: 0 57 | platformSettings: 58 | - buildTarget: DefaultTexturePlatform 59 | maxTextureSize: 4096 60 | resizeAlgorithm: 0 61 | textureFormat: -1 62 | textureCompression: 1 63 | compressionQuality: 50 64 | crunchedCompression: 0 65 | allowsAlphaSplitting: 0 66 | overridden: 0 67 | androidETC2FallbackOverride: 0 68 | spriteSheet: 69 | serializedVersion: 2 70 | sprites: [] 71 | outline: [] 72 | physicsShape: [] 73 | spritePackingTag: 74 | userData: 75 | assetBundleName: 76 | assetBundleVariant: 77 | -------------------------------------------------------------------------------- /Assets/Demo/jijiBackup.FBX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/Assets/Demo/jijiBackup.FBX -------------------------------------------------------------------------------- /Assets/Demo/jijiBackup.FBX.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93679d38af7a4404fb78219edbbe1d26 3 | timeCreated: 1520732934 4 | licenseType: Pro 5 | ModelImporter: 6 | serializedVersion: 22 7 | fileIDToRecycleName: 8 | 100000: //RootNode 9 | 400000: //RootNode 10 | 2100000: No Name 11 | 2300000: //RootNode 12 | 3300000: //RootNode 13 | 4300000: Retoped_diffuse 14 | externalObjects: {} 15 | materials: 16 | importMaterials: 1 17 | materialName: 0 18 | materialSearch: 1 19 | materialLocation: 1 20 | animations: 21 | legacyGenerateAnimations: 4 22 | bakeSimulation: 0 23 | resampleCurves: 1 24 | optimizeGameObjects: 0 25 | motionNodeName: 26 | rigImportErrors: 27 | rigImportWarnings: 28 | animationImportErrors: 29 | animationImportWarnings: 30 | animationRetargetingWarnings: 31 | animationDoRetargetingWarnings: 0 32 | importAnimatedCustomProperties: 0 33 | animationCompression: 1 34 | animationRotationError: 0.5 35 | animationPositionError: 0.5 36 | animationScaleError: 0.5 37 | animationWrapMode: 0 38 | extraExposedTransformPaths: [] 39 | extraUserProperties: [] 40 | clipAnimations: [] 41 | isReadable: 0 42 | meshes: 43 | lODScreenPercentages: [] 44 | globalScale: 1 45 | meshCompression: 0 46 | addColliders: 0 47 | importVisibility: 1 48 | importBlendShapes: 1 49 | importCameras: 1 50 | importLights: 1 51 | swapUVChannels: 0 52 | generateSecondaryUV: 0 53 | useFileUnits: 1 54 | optimizeMeshForGPU: 1 55 | keepQuads: 0 56 | weldVertices: 1 57 | preserveHierarchy: 0 58 | indexFormat: 0 59 | secondaryUVAngleDistortion: 8 60 | secondaryUVAreaDistortion: 15.000001 61 | secondaryUVHardAngle: 88 62 | secondaryUVPackMargin: 4 63 | useFileScale: 1 64 | tangentSpace: 65 | normalSmoothAngle: 60 66 | normalImportMode: 0 67 | tangentImportMode: 3 68 | normalCalculationMode: 4 69 | importAnimation: 1 70 | copyAvatar: 0 71 | humanDescription: 72 | serializedVersion: 2 73 | human: [] 74 | skeleton: [] 75 | armTwist: 0.5 76 | foreArmTwist: 0.5 77 | upperLegTwist: 0.5 78 | legTwist: 0.5 79 | armStretch: 0.05 80 | legStretch: 0.05 81 | feetSpacing: 0 82 | rootMotionBoneName: 83 | rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} 84 | hasTranslationDoF: 0 85 | hasExtraRoot: 0 86 | skeletonHasParents: 1 87 | lastHumanDescriptionAvatarSource: {instanceID: 0} 88 | animationType: 0 89 | humanoidOversampling: 1 90 | additionalBone: 0 91 | userData: 92 | assetBundleName: 93 | assetBundleVariant: 94 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7573cb8b588660741b0f6647fb94d488 3 | folderAsset: yes 4 | timeCreated: 1521673427 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Editor/CubeMapCapture.cs: -------------------------------------------------------------------------------- 1 | /// 2 | /// 将某相机所看渲染到CubeMap,并选择性的保存此CubeMap贴图 3 | /// 4 | using UnityEngine; 5 | using UnityEditor; 6 | 7 | /// 8 | /// CubeMap 六个面 9 | /// 10 | enum CubeMapFaces 11 | { 12 | right = 0, 13 | left, 14 | top, 15 | bottom, 16 | front, 17 | back 18 | } 19 | 20 | public class RenderToCubeMapTool : EditorWindow 21 | { 22 | 23 | [MenuItem ("Window/CubeMapTool %m")] 24 | static void AddWindow () 25 | { 26 | //创建窗口 27 | Rect wr = new Rect (0, 0, 100, 100); 28 | RenderToCubeMapTool window = (RenderToCubeMapTool)EditorWindow.GetWindowWithRect (typeof(RenderToCubeMapTool), wr, false, "CubeMapTool"); 29 | window.Show (); 30 | 31 | } 32 | 33 | private Renderer targetObj; 34 | private Camera renderCamera; 35 | private Cubemap renderCubeMap; 36 | CubeMapFaces faces; 37 | private CubemapFace offcialFaces; 38 | 39 | void OnGUI () 40 | { 41 | GUILayout.BeginVertical (); 42 | GUILayout.Space (10f); 43 | targetObj = EditorGUILayout.ObjectField ("渲染物体", targetObj, typeof(Renderer), true) as Renderer; 44 | renderCamera = EditorGUILayout.ObjectField ("摄像机", renderCamera, typeof(Camera), true) as Camera; 45 | GUILayout.Space (10f); 46 | renderCubeMap = EditorGUILayout.ObjectField ("CubeMap", renderCubeMap, typeof(Cubemap), false) as Cubemap; 47 | GUILayout.Space (10f); 48 | if (GUILayout.Button ("渲染") && CheckCamAndCubeMap ()) { 49 | renderCamera.transform.position = targetObj.transform.position; 50 | int camLayerMask = renderCamera.cullingMask; 51 | renderCamera.cullingMask = ~(1 << 31) & camLayerMask; 52 | int layer = targetObj.gameObject.layer; 53 | targetObj.gameObject.layer = 31; 54 | if (renderCamera.RenderToCubemap (renderCubeMap)) { 55 | Debug.LogWarningFormat ("渲染完成!"); 56 | CheckSingleCubeMapFaces (); 57 | 58 | } else { 59 | Debug.LogWarningFormat ("渲染失败!"); 60 | } 61 | targetObj.gameObject.layer = layer; 62 | renderCamera.cullingMask = camLayerMask; 63 | } 64 | 65 | GUILayout.Space (10f); 66 | 67 | GUILayout.BeginHorizontal (); 68 | faces = (CubeMapFaces)EditorGUILayout.EnumPopup ("保存CubeMap某个面", faces); 69 | 70 | 71 | 72 | if (GUILayout.Button ("保存") && CheckCamAndCubeMap ()) { 73 | 74 | 75 | CheckSingleCubeMapFaces (); 76 | SaveSingelTexture (); 77 | 78 | } 79 | 80 | GUILayout.EndHorizontal (); 81 | GUILayout.Space (10f); 82 | if (GUILayout.Button ("全部保存")) { 83 | 84 | 85 | SaveMultiTexture (); 86 | } 87 | 88 | GUILayout.Space (10f); 89 | 90 | EditorGUILayout.HelpBox ("请务必确认要渲染的CubeMap可以读写!\n (属性面板中的 Readable 勾上即可)", MessageType.Warning); 91 | 92 | 93 | GUILayout.EndVertical (); 94 | 95 | } 96 | 97 | bool CheckCamAndCubeMap () 98 | { 99 | if (renderCamera == null || renderCubeMap == null) { 100 | Debug.LogError ("渲染相机和CubeMap不能为空!"); 101 | return false; 102 | } else { 103 | return true; 104 | } 105 | } 106 | 107 | #region 检测单张保存时对应cubemap面 108 | /// 109 | /// Checks the cube map faces. 110 | /// 111 | void CheckSingleCubeMapFaces () 112 | { 113 | switch (faces) { 114 | case CubeMapFaces.right: 115 | offcialFaces = CubemapFace.PositiveX; 116 | break; 117 | case CubeMapFaces.left: 118 | offcialFaces = CubemapFace.NegativeX; 119 | break; 120 | case CubeMapFaces.top: 121 | offcialFaces = CubemapFace.PositiveY; 122 | break; 123 | case CubeMapFaces.bottom: 124 | offcialFaces = CubemapFace.NegativeY; 125 | break; 126 | case CubeMapFaces.front: 127 | offcialFaces = CubemapFace.PositiveZ; 128 | break; 129 | case CubeMapFaces.back: 130 | offcialFaces = CubemapFace.NegativeZ; 131 | break; 132 | 133 | } 134 | } 135 | #endregion 136 | 137 | #region 检测多张保存时对应的cubemap面 138 | /// 139 | /// Checks the multi cube map faces. 140 | /// 141 | void CheckMultiCubeMapFaces (int index) 142 | { 143 | switch (index) { 144 | case (int)CubeMapFaces.right: 145 | offcialFaces = CubemapFace.PositiveX; 146 | break; 147 | case (int)CubeMapFaces.left: 148 | offcialFaces = CubemapFace.NegativeX; 149 | break; 150 | case (int)CubeMapFaces.top: 151 | offcialFaces = CubemapFace.PositiveY; 152 | break; 153 | case (int)CubeMapFaces.bottom: 154 | offcialFaces = CubemapFace.NegativeY; 155 | break; 156 | case (int)CubeMapFaces.front: 157 | offcialFaces = CubemapFace.PositiveZ; 158 | break; 159 | case (int)CubeMapFaces.back: 160 | offcialFaces = CubemapFace.NegativeZ; 161 | break; 162 | 163 | } 164 | } 165 | 166 | #endregion 167 | 168 | #region 由cubemap 朝向反推前后左右方向 169 | string CheckDir () 170 | { 171 | string name = "TestTexture"; 172 | switch (offcialFaces) { 173 | case CubemapFace.PositiveX: 174 | name = "right"; 175 | break; 176 | case CubemapFace.NegativeX: 177 | name = "left"; 178 | break; 179 | case CubemapFace.PositiveY: 180 | name = "top"; 181 | break; 182 | case CubemapFace.NegativeY: 183 | name = "bottom"; 184 | break; 185 | case CubemapFace.PositiveZ: 186 | name = "front"; 187 | break; 188 | case CubemapFace.NegativeZ: 189 | name = "back"; 190 | break; 191 | 192 | } 193 | return name; 194 | } 195 | 196 | #endregion 197 | 198 | #region 保存单张图片 199 | /// 200 | ///保存单张图片 201 | /// 202 | private void SaveSingelTexture () 203 | { 204 | 205 | Texture2D screenShot = new Texture2D (renderCubeMap.width, 206 | renderCubeMap.height, 207 | TextureFormat.ARGB32, 208 | false); 209 | for (int i = 0; i< renderCubeMap.width; i++) { 210 | for (int j = 0; j < renderCubeMap.height; j++) { 211 | screenShot.SetPixel (i, j, renderCubeMap.GetPixel (offcialFaces, renderCubeMap.width - i, renderCubeMap.height - j)); 212 | } 213 | } 214 | 215 | screenShot.Apply (); 216 | byte[] bytes = screenShot.EncodeToPNG (); 217 | 218 | string path = EditorUtility.SaveFilePanel ("图片保存", Application.dataPath, faces.ToString (), "png"); 219 | 220 | System.IO.File.WriteAllBytes (path, bytes); 221 | 222 | AssetDatabase.Refresh (); 223 | } 224 | #endregion 225 | 226 | #region 保存多张图片 227 | /// 228 | ///保存单张图片 229 | /// 230 | private void SaveMultiTexture () 231 | { 232 | 233 | Texture2D screenShot; 234 | string path = Application.dataPath + "/" + "CubeMapTextures/"; 235 | for (int k = 0; k< 6; k++) { 236 | 237 | screenShot = new Texture2D (renderCubeMap.width, 238 | renderCubeMap.height, 239 | TextureFormat.ARGB32, 240 | false); 241 | CheckMultiCubeMapFaces (k); 242 | for (int i = 0; i< renderCubeMap.width; i++) { 243 | for (int j = 0; j < renderCubeMap.height; j++) { 244 | screenShot.SetPixel (i, j, renderCubeMap.GetPixel (offcialFaces, renderCubeMap.width - i, renderCubeMap.height - j)); 245 | } 246 | } 247 | 248 | screenShot.Apply (); 249 | byte[] bytes = screenShot.EncodeToPNG (); 250 | 251 | if (!System.IO.Directory.Exists (path)) { 252 | System.IO.Directory.CreateDirectory (path); 253 | } 254 | System.IO.File.WriteAllBytes (path + CheckDir () + ".png", bytes); 255 | 256 | } 257 | 258 | AssetDatabase.Refresh (); 259 | 260 | Debug.LogWarning ("六张图片已经保存在 " + path + " 下!"); 261 | 262 | } 263 | #endregion 264 | 265 | void OnInspectorUpdate () 266 | { 267 | this.Repaint (); 268 | } 269 | 270 | } -------------------------------------------------------------------------------- /Assets/Editor/CubeMapCapture.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9793d2a886881246b98c8cec40b739b 3 | timeCreated: 1519448468 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Editor/SnowShaderEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Collections; 6 | 7 | public class SnowShaderEditor : ShaderGUI 8 | { 9 | bool init = false; 10 | bool lastAlbedo = true; 11 | bool lastBump = true; 12 | bool lastSpecular = true; 13 | bool lastOcclusion = true; 14 | bool lastPhong = true; 15 | 16 | bool lastDetailAlbedo = true; 17 | bool lastDetailNormal = true; 18 | bool bump; 19 | bool specular; 20 | 21 | bool phong; 22 | bool occlusion; 23 | bool albedo; 24 | bool detailAlbedo; 25 | bool detailNormal; 26 | Dictionary propDict = new Dictionary (17); 27 | public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] properties) 28 | { 29 | Material targetMat = materialEditor.target as Material; 30 | bool USE_FILTER = Array.IndexOf(targetMat.shaderKeywords, "USE_FILTER") != -1; 31 | 32 | EditorGUI.BeginChangeCheck(); 33 | USE_FILTER = EditorGUILayout.Toggle("Use Tess Filter", USE_FILTER); 34 | 35 | if (EditorGUI.EndChangeCheck()) 36 | { 37 | // enable or disable the keyword based on checkbox 38 | if (USE_FILTER) 39 | targetMat.EnableKeyword("USE_FILTER"); 40 | else 41 | targetMat.DisableKeyword("USE_FILTER"); 42 | } 43 | // render the default gui 44 | base.OnGUI (materialEditor, properties); 45 | 46 | 47 | // see if redify is set, and show a checkbox 48 | // bool CS_BOOL = Array.IndexOf(targetMat.shaderKeywords, "CS_BOOL") != -1; 49 | propDict.Clear(); 50 | for (int i = 0; i < properties.Length; ++i) { 51 | propDict.Add (properties [i].name, properties [i]); 52 | } 53 | // CS_BOOL = EditorGUILayout.Toggle("CS_BOOL", CS_BOOL); 54 | bump = propDict ["_BumpMap"].textureValue != null; 55 | specular = propDict ["_SpecularMap"].textureValue != null; 56 | phong = propDict ["_Phong"].floatValue != 0; 57 | occlusion = propDict ["_OcclusionMap"].textureValue != null; 58 | albedo = propDict ["_MainTex"].textureValue != null; 59 | detailAlbedo = propDict ["_DetailAlbedo"].textureValue != null; 60 | detailNormal = propDict ["_DetailBump"].textureValue != null; 61 | if (!init) { 62 | init = true; 63 | if (albedo) 64 | targetMat.EnableKeyword ("USE_ALBEDO"); 65 | else 66 | targetMat.DisableKeyword ("USE_ALBEDO"); 67 | if (bump) 68 | targetMat.EnableKeyword ("USE_NORMAL"); 69 | else 70 | targetMat.DisableKeyword ("USE_NORMAL"); 71 | if (specular) 72 | targetMat.EnableKeyword ("USE_SPECULAR"); 73 | else 74 | targetMat.DisableKeyword ("USE_SPECULAR"); 75 | if (phong) 76 | targetMat.EnableKeyword ("USE_PHONG"); 77 | else 78 | targetMat.DisableKeyword ("USE_PHONG"); 79 | if (occlusion) 80 | targetMat.EnableKeyword ("USE_OCCLUSION"); 81 | else 82 | targetMat.DisableKeyword ("USE_OCCLUSION"); 83 | if (detailAlbedo) 84 | targetMat.EnableKeyword ("USE_DETAILALBEDO"); 85 | else 86 | targetMat.DisableKeyword ("USE_DETAILALBEDO"); 87 | if (detailNormal) 88 | targetMat.EnableKeyword ("USE_DETAILNORMAL"); 89 | else 90 | targetMat.DisableKeyword ("USE_DETAILNORMAL"); 91 | } 92 | if (lastBump != bump) { 93 | lastBump = bump; 94 | if (bump) 95 | targetMat.EnableKeyword ("USE_NORMAL"); 96 | else 97 | targetMat.DisableKeyword ("USE_NORMAL"); 98 | } 99 | 100 | if (lastAlbedo != albedo) { 101 | lastAlbedo = albedo; 102 | if (albedo) 103 | targetMat.EnableKeyword ("USE_ALBEDO"); 104 | else 105 | targetMat.DisableKeyword ("USE_ALBEDO"); 106 | } 107 | 108 | if (lastOcclusion != occlusion) { 109 | lastOcclusion = occlusion; 110 | if (occlusion) 111 | targetMat.EnableKeyword ("USE_OCCLUSION"); 112 | else 113 | targetMat.DisableKeyword ("USE_OCCLUSION"); 114 | } 115 | 116 | if (lastSpecular != specular) { 117 | lastSpecular = specular; 118 | if (specular) 119 | targetMat.EnableKeyword ("USE_SPECULAR"); 120 | else 121 | targetMat.DisableKeyword ("USE_SPECULAR"); 122 | } 123 | 124 | if (lastPhong != phong) { 125 | lastPhong = phong; 126 | if (phong) 127 | targetMat.EnableKeyword ("USE_PHONG"); 128 | else 129 | targetMat.DisableKeyword ("USE_PHONG"); 130 | } 131 | 132 | if (lastDetailAlbedo != detailAlbedo) { 133 | lastDetailAlbedo = detailAlbedo; 134 | if (detailAlbedo) 135 | targetMat.EnableKeyword ("USE_DETAILALBEDO"); 136 | else 137 | targetMat.DisableKeyword ("USE_DETAILALBEDO"); 138 | } 139 | 140 | if (lastDetailNormal != detailNormal) { 141 | lastDetailNormal = detailNormal; 142 | if (detailNormal) 143 | targetMat.EnableKeyword ("USE_DETAILNORMAL"); 144 | else 145 | targetMat.DisableKeyword ("USE_DETAILNORMAL"); 146 | } 147 | } 148 | } -------------------------------------------------------------------------------- /Assets/Editor/SnowShaderEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8f1c1767436c103479f8a09f0b6db3e1 3 | timeCreated: 1521635942 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Editor/SpecularShaderEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Collections; 6 | 7 | public class SpecularShaderEditor : ShaderGUI 8 | { 9 | bool init = false; 10 | bool lastAlbedo = true; 11 | bool lastBump = true; 12 | bool lastSpecular = true; 13 | bool lastOcclusion = true; 14 | bool lastPhong = true; 15 | bool lastVertex = true; 16 | bool lastDetailAlbedo = true; 17 | bool lastDetailNormal = true; 18 | bool bump; 19 | bool specular; 20 | bool vertex; 21 | bool phong; 22 | bool occlusion; 23 | bool albedo; 24 | bool detailAlbedo; 25 | bool detailNormal; 26 | Dictionary propDict = new Dictionary (17); 27 | public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] properties) 28 | { 29 | Material targetMat = materialEditor.target as Material; 30 | bool USE_FILTER = Array.IndexOf(targetMat.shaderKeywords, "USE_FILTER") != -1; 31 | 32 | EditorGUI.BeginChangeCheck(); 33 | USE_FILTER = EditorGUILayout.Toggle("Use Tess Filter", USE_FILTER); 34 | 35 | if (EditorGUI.EndChangeCheck()) 36 | { 37 | // enable or disable the keyword based on checkbox 38 | if (USE_FILTER) 39 | targetMat.EnableKeyword("USE_FILTER"); 40 | else 41 | targetMat.DisableKeyword("USE_FILTER"); 42 | } 43 | // render the default gui 44 | base.OnGUI (materialEditor, properties); 45 | 46 | 47 | // see if redify is set, and show a checkbox 48 | // bool CS_BOOL = Array.IndexOf(targetMat.shaderKeywords, "CS_BOOL") != -1; 49 | propDict.Clear(); 50 | for (int i = 0; i < properties.Length; ++i) { 51 | propDict.Add (properties [i].name, properties [i]); 52 | } 53 | // CS_BOOL = EditorGUILayout.Toggle("CS_BOOL", CS_BOOL); 54 | bump = propDict ["_BumpMap"].textureValue != null; 55 | specular = propDict ["_SpecularMap"].textureValue != null; 56 | vertex = propDict ["_HeightMap"].textureValue != null; 57 | phong = propDict ["_Phong"].floatValue != 0; 58 | occlusion = propDict ["_OcclusionMap"].textureValue != null; 59 | albedo = propDict ["_MainTex"].textureValue != null; 60 | detailAlbedo = propDict ["_DetailAlbedo"].textureValue != null; 61 | detailNormal = propDict ["_DetailBump"].textureValue != null; 62 | if (!init) { 63 | init = true; 64 | if (albedo) 65 | targetMat.EnableKeyword ("USE_ALBEDO"); 66 | else 67 | targetMat.DisableKeyword ("USE_ALBEDO"); 68 | if (bump) 69 | targetMat.EnableKeyword ("USE_NORMAL"); 70 | else 71 | targetMat.DisableKeyword ("USE_NORMAL"); 72 | if (specular) 73 | targetMat.EnableKeyword ("USE_SPECULAR"); 74 | else 75 | targetMat.DisableKeyword ("USE_SPECULAR"); 76 | if (vertex) 77 | targetMat.EnableKeyword ("USE_VERTEX"); 78 | else 79 | targetMat.DisableKeyword ("USE_VERTEX"); 80 | if (phong) 81 | targetMat.EnableKeyword ("USE_PHONG"); 82 | else 83 | targetMat.DisableKeyword ("USE_PHONG"); 84 | if (occlusion) 85 | targetMat.EnableKeyword ("USE_OCCLUSION"); 86 | else 87 | targetMat.DisableKeyword ("USE_OCCLUSION"); 88 | if (detailAlbedo) 89 | targetMat.EnableKeyword ("USE_DETAILALBEDO"); 90 | else 91 | targetMat.DisableKeyword ("USE_DETAILALBEDO"); 92 | if (detailNormal) 93 | targetMat.EnableKeyword ("USE_DETAILNORMAL"); 94 | else 95 | targetMat.DisableKeyword ("USE_DETAILNORMAL"); 96 | } 97 | if (lastBump != bump) { 98 | lastBump = bump; 99 | if (bump) 100 | targetMat.EnableKeyword ("USE_NORMAL"); 101 | else 102 | targetMat.DisableKeyword ("USE_NORMAL"); 103 | } 104 | 105 | if (lastAlbedo != albedo) { 106 | lastAlbedo = albedo; 107 | if (albedo) 108 | targetMat.EnableKeyword ("USE_ALBEDO"); 109 | else 110 | targetMat.DisableKeyword ("USE_ALBEDO"); 111 | } 112 | 113 | if (lastOcclusion != occlusion) { 114 | lastOcclusion = occlusion; 115 | if (occlusion) 116 | targetMat.EnableKeyword ("USE_OCCLUSION"); 117 | else 118 | targetMat.DisableKeyword ("USE_OCCLUSION"); 119 | } 120 | 121 | if (lastSpecular != specular) { 122 | lastSpecular = specular; 123 | if (specular) 124 | targetMat.EnableKeyword ("USE_SPECULAR"); 125 | else 126 | targetMat.DisableKeyword ("USE_SPECULAR"); 127 | } 128 | 129 | if (lastPhong != phong) { 130 | lastPhong = phong; 131 | if (phong) 132 | targetMat.EnableKeyword ("USE_PHONG"); 133 | else 134 | targetMat.DisableKeyword ("USE_PHONG"); 135 | } 136 | 137 | if (lastVertex != vertex) { 138 | if (vertex) 139 | targetMat.EnableKeyword ("USE_VERTEX"); 140 | else 141 | targetMat.DisableKeyword ("USE_VERTEX"); 142 | lastVertex = vertex; 143 | } 144 | 145 | if (lastDetailAlbedo != detailAlbedo) { 146 | lastDetailAlbedo = detailAlbedo; 147 | if (detailAlbedo) 148 | targetMat.EnableKeyword ("USE_DETAILALBEDO"); 149 | else 150 | targetMat.DisableKeyword ("USE_DETAILALBEDO"); 151 | } 152 | 153 | if (lastDetailNormal != detailNormal) { 154 | lastDetailNormal = detailNormal; 155 | if (detailNormal) 156 | targetMat.EnableKeyword ("USE_DETAILNORMAL"); 157 | else 158 | targetMat.DisableKeyword ("USE_DETAILNORMAL"); 159 | } 160 | } 161 | } -------------------------------------------------------------------------------- /Assets/Editor/SpecularShaderEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 989502c49ef7d1641bcf4b63a9ee4732 3 | timeCreated: 1519024720 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Editor/TextureMixer.cs: -------------------------------------------------------------------------------- 1 | // Creates a simple wizard that lets you create a Light GameObject 2 | // or if the user clicks in "Apply", it will set the color of the currently 3 | // object selected to red 4 | 5 | using UnityEditor; 6 | using System.IO; 7 | using UnityEngine; 8 | using System.Collections; 9 | using System.Collections.Generic; 10 | 11 | public class MixTexture : ScriptableWizard 12 | { 13 | public string path = "Arts"; 14 | public string fileName = "mixedTexture"; 15 | public Texture2D RGB; 16 | public Texture2D A; 17 | 18 | 19 | [MenuItem ("Tools/Mix Texture")] 20 | static void CreateWizard () 21 | { 22 | ScriptableWizard.DisplayWizard ("Mix Texture", "Quit", "Create"); 23 | } 24 | 25 | void OnWizardOtherButton () 26 | {/* 27 | if (RGB.texelSize == A.texelSize) { 28 | Texture2D example = new Texture2D (RGB.width, RGB.height, TextureFormat.RGBA32, true); 29 | var RGBColors = RGB.GetPixels (); 30 | var AColors = A.GetPixels (); 31 | var colors = new Color[RGBColors.Length]; 32 | 33 | for (int i = 0; i < colors.Length; ++i) { 34 | colors [i] = new Color (RGBColors [i].r, RGBColors [i].g, RGBColors [i].b, AColors [i].a); 35 | } 36 | 37 | example.SetPixels (colors); 38 | example.Apply (); 39 | SaveFileToPng (example, fileName); 40 | Debug.Log ("Success!"); 41 | } else { 42 | Debug.LogWarning ("Unable To mix the texture because the size is different"); 43 | }*/ 44 | Texture2D ramp = new Texture2D (128, 1, TextureFormat.RGBA32, false); 45 | Color[] colors = new Color[128]; 46 | for (int i = 0; i < colors.Length; ++i) { 47 | Color c = Color.Lerp (Color.black, Color.white, i / 128f); 48 | float lerpV = Mathf.Abs (c.r - 0.5f) * 2; 49 | c = Color.Lerp (new Color (1, 0.46666666f, 0f), c, lerpV); 50 | colors [i] = c; 51 | } 52 | ramp.SetPixels (colors); 53 | ramp.Apply (); 54 | SaveFileToPng (ramp, fileName); 55 | } 56 | 57 | void SaveFileToPng (Texture2D picture, string fileName) 58 | { 59 | string path1 = Application.dataPath + "/" + path + "/" + fileName + ".png"; 60 | var binary = new BinaryWriter (new FileStream (path1, FileMode.Create)); 61 | var bytes = picture.EncodeToPNG (); 62 | binary.Write (bytes); 63 | binary.Dispose (); 64 | } 65 | } 66 | 67 | public class SetTessMesh : ScriptableWizard 68 | { 69 | public Mesh mesh; 70 | [MenuItem ("Tools/Set TessMesh")] 71 | static void CreateWizard () 72 | { 73 | ScriptableWizard.DisplayWizard ("SetTessMesh", "Set"); 74 | } 75 | 76 | void SetMesh(){ 77 | Vector3[] allVertex = mesh.vertices; 78 | bool[] vertIsIndependent = new bool[allVertex.Length]; 79 | for (int i = 0; i < vertIsIndependent.Length; ++i) { 80 | vertIsIndependent [i] = true; 81 | } 82 | int[] triangle = mesh.triangles; 83 | Vector3[] normals = mesh.normals; 84 | for (int i = 0; (i + 2) < triangle.Length; i += 3) { 85 | int x = triangle[i]; 86 | int y = triangle[i + 1]; 87 | int z = triangle[i + 2]; 88 | bool independent = normals [x] == normals [y] && normals [x] == normals [z] && normals [y] == normals [z]; 89 | vertIsIndependent [x] &= independent; 90 | vertIsIndependent [y] &= independent; 91 | vertIsIndependent [z] &= independent; 92 | } 93 | Color[] colors = new Color[allVertex.Length]; 94 | for (int i = 0; i < colors.Length; ++i) { 95 | colors [i] = Color.black; 96 | } 97 | for (int i = 0; i < vertIsIndependent.Length; ++i) { 98 | colors [i].a = vertIsIndependent [i] ? 0 : 1; 99 | } 100 | mesh.colors = colors; 101 | } 102 | 103 | void OnWizardCreate () 104 | { 105 | SetMesh (); 106 | Debug.Log ("Success"); 107 | } 108 | } 109 | 110 | public class CleanMesh : ScriptableWizard 111 | { 112 | public Mesh mesh; 113 | public bool normal = true; 114 | public bool uv1 = true; 115 | public bool uv2 = true; 116 | public bool uv3 = false; 117 | public bool uv4 = false; 118 | public bool color = false; 119 | [MenuItem ("Tools/Clean Mesh")] 120 | static void CreateWizard () 121 | { 122 | ScriptableWizard.DisplayWizard ("CleanMesh", "Set"); 123 | } 124 | 125 | void SetMesh(){ 126 | if (!uv1) 127 | mesh.uv = new Vector2[0]; 128 | if (!uv2) 129 | mesh.uv2 = new Vector2[0]; 130 | if (!uv3) 131 | mesh.uv3 = new Vector2[0]; 132 | if (!uv4) 133 | mesh.uv4 = new Vector2[0]; 134 | if (!color) 135 | mesh.colors = new Color[0]; 136 | if (!normal) { 137 | mesh.normals = new Vector3[0]; 138 | mesh.tangents = new Vector4[0]; 139 | } 140 | } 141 | 142 | void OnWizardCreate () 143 | { 144 | SetMesh (); 145 | Debug.Log ("Success"); 146 | } 147 | } 148 | 149 | -------------------------------------------------------------------------------- /Assets/Editor/TextureMixer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 42e4614b924daf746aa31a886476619d 3 | timeCreated: 1520512442 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Editor/WaterShader.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Collections; 6 | 7 | public class WaterShader : ShaderGUI 8 | { 9 | bool init = false; 10 | bool lastAlbedo = true; 11 | bool lastBump = true; 12 | bool lastPhong = true; 13 | bool lastVertex = true; 14 | 15 | bool bump; 16 | 17 | bool vertex; 18 | bool phong; 19 | 20 | bool albedo; 21 | 22 | Dictionary propDict = new Dictionary (17); 23 | public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] properties) 24 | { 25 | Material targetMat = materialEditor.target as Material; 26 | // render the default gui 27 | base.OnGUI (materialEditor, properties); 28 | 29 | 30 | // see if redify is set, and show a checkbox 31 | // bool CS_BOOL = Array.IndexOf(targetMat.shaderKeywords, "CS_BOOL") != -1; 32 | propDict.Clear(); 33 | for (int i = 0; i < properties.Length; ++i) { 34 | propDict.Add (properties [i].name, properties [i]); 35 | } 36 | bump = propDict ["_BumpMap"].textureValue != null; 37 | vertex = propDict ["_HeightMap"].textureValue != null; 38 | phong = propDict ["_Phong"].floatValue != 0; 39 | albedo = propDict ["_MainTex"].textureValue != null; 40 | 41 | if (!init) { 42 | init = true; 43 | if (albedo) 44 | targetMat.EnableKeyword ("USE_ALBEDO"); 45 | else 46 | targetMat.DisableKeyword ("USE_ALBEDO"); 47 | if (bump) 48 | targetMat.EnableKeyword ("USE_NORMAL"); 49 | else 50 | targetMat.DisableKeyword ("USE_NORMAL"); 51 | 52 | if (vertex) 53 | targetMat.EnableKeyword ("USE_VERTEX"); 54 | else 55 | targetMat.DisableKeyword ("USE_VERTEX"); 56 | if (phong) 57 | targetMat.EnableKeyword ("USE_PHONG"); 58 | else 59 | targetMat.DisableKeyword ("USE_PHONG"); 60 | 61 | } 62 | if (lastBump != bump) { 63 | lastBump = bump; 64 | if (bump) 65 | targetMat.EnableKeyword ("USE_NORMAL"); 66 | else 67 | targetMat.DisableKeyword ("USE_NORMAL"); 68 | } 69 | 70 | if (lastAlbedo != albedo) { 71 | lastAlbedo = albedo; 72 | if (albedo) 73 | targetMat.EnableKeyword ("USE_ALBEDO"); 74 | else 75 | targetMat.DisableKeyword ("USE_ALBEDO"); 76 | } 77 | 78 | 79 | if (lastPhong != phong) { 80 | lastPhong = phong; 81 | if (phong) 82 | targetMat.EnableKeyword ("USE_PHONG"); 83 | else 84 | targetMat.DisableKeyword ("USE_PHONG"); 85 | } 86 | 87 | if (lastVertex != vertex) { 88 | if (vertex) 89 | targetMat.EnableKeyword ("USE_VERTEX"); 90 | else 91 | targetMat.DisableKeyword ("USE_VERTEX"); 92 | lastVertex = vertex; 93 | } 94 | 95 | } 96 | } -------------------------------------------------------------------------------- /Assets/Editor/WaterShader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6f8f39e2faf7844ca2d892a95c346d7 3 | timeCreated: 1521150496 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b02a1ee7a4bcf3418b223de4a93ed6e 3 | folderAsset: yes 4 | timeCreated: 1521672893 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7b162cf4442c654583a51f948dc3645 3 | folderAsset: yes 4 | timeCreated: 1521672893 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/DiffuseScatteringOnRing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/Assets/Shader/SkinShader/DiffuseScatteringOnRing.png -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/DiffuseScatteringOnRing.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 43721d2a1a9c49b4585a8dd6dfab0a40 3 | timeCreated: 1521376319 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | externalObjects: {} 8 | serializedVersion: 4 9 | mipmaps: 10 | mipMapMode: 0 11 | enableMipMap: 0 12 | sRGBTexture: 0 13 | linearTexture: 0 14 | fadeOut: 0 15 | borderMipMap: 0 16 | mipMapsPreserveCoverage: 0 17 | alphaTestReferenceValue: 0.5 18 | mipMapFadeDistanceStart: 1 19 | mipMapFadeDistanceEnd: 3 20 | bumpmap: 21 | convertToNormalMap: 0 22 | externalNormalMap: 0 23 | heightScale: 0.25 24 | normalMapFilter: 0 25 | isReadable: 0 26 | grayScaleToAlpha: 0 27 | generateCubemap: 6 28 | cubemapConvolution: 0 29 | seamlessCubemap: 0 30 | textureFormat: 1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | serializedVersion: 2 34 | filterMode: 1 35 | aniso: -1 36 | mipBias: -1 37 | wrapU: 1 38 | wrapV: 1 39 | wrapW: 1 40 | nPOTScale: 1 41 | lightmap: 0 42 | compressionQuality: 50 43 | spriteMode: 0 44 | spriteExtrude: 1 45 | spriteMeshType: 1 46 | alignment: 0 47 | spritePivot: {x: 0.5, y: 0.5} 48 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 49 | spritePixelsToUnits: 100 50 | alphaUsage: 1 51 | alphaIsTransparency: 0 52 | spriteTessellationDetail: -1 53 | textureType: 0 54 | textureShape: 1 55 | maxTextureSizeSet: 0 56 | compressionQualitySet: 0 57 | textureFormatSet: 0 58 | platformSettings: 59 | - buildTarget: DefaultTexturePlatform 60 | maxTextureSize: 8192 61 | resizeAlgorithm: 1 62 | textureFormat: -1 63 | textureCompression: 0 64 | compressionQuality: 50 65 | crunchedCompression: 0 66 | allowsAlphaSplitting: 0 67 | overridden: 0 68 | androidETC2FallbackOverride: 0 69 | - buildTarget: Standalone 70 | maxTextureSize: 8192 71 | resizeAlgorithm: 1 72 | textureFormat: -1 73 | textureCompression: 0 74 | compressionQuality: 50 75 | crunchedCompression: 0 76 | allowsAlphaSplitting: 0 77 | overridden: 0 78 | androidETC2FallbackOverride: 0 79 | - buildTarget: iPhone 80 | maxTextureSize: 8192 81 | resizeAlgorithm: 1 82 | textureFormat: -1 83 | textureCompression: 0 84 | compressionQuality: 50 85 | crunchedCompression: 0 86 | allowsAlphaSplitting: 0 87 | overridden: 0 88 | androidETC2FallbackOverride: 0 89 | - buildTarget: Android 90 | maxTextureSize: 8192 91 | resizeAlgorithm: 1 92 | textureFormat: -1 93 | textureCompression: 0 94 | compressionQuality: 50 95 | crunchedCompression: 0 96 | allowsAlphaSplitting: 0 97 | overridden: 0 98 | androidETC2FallbackOverride: 0 99 | spriteSheet: 100 | serializedVersion: 2 101 | sprites: [] 102 | outline: [] 103 | physicsShape: [] 104 | spritePackingTag: 105 | userData: 106 | assetBundleName: 107 | assetBundleVariant: 108 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6e9ab0ccd69bc944a993d97f6ce22f2 3 | folderAsset: yes 4 | timeCreated: 1521672893 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Scripts/SSSSSCamera.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | 6 | [RequireComponent(typeof(Camera))] 7 | public class SSSSSCamera : MonoBehaviour { 8 | #region MASK_SPACE 9 | public static Shader depthCullShader; 10 | public static Material depthCullFrontMaterial; 11 | public static CommandBuffer currentCommandBuffer; 12 | public static bool isCommandBufferReady; 13 | public bool useBlur = true; 14 | [System.NonSerialized] 15 | public bool isScreenChanged; 16 | [System.NonSerialized] 17 | public int width; 18 | [System.NonSerialized] 19 | public int height; 20 | CommandBuffer commandBuffer; 21 | Camera cam; 22 | Camera depthCam; 23 | Camera depthCullCam; 24 | Shader depthShader; 25 | Material mat; 26 | [Range(0.02f, 100)] 27 | public float blurRange = 20; 28 | 29 | [Range(0,10)] 30 | public float offset = 0.5f; 31 | public LayerMask skinLayer = 1<<31; 32 | RenderTexture cullFrontDepthTex; 33 | int tempID1; 34 | int tempID2; 35 | // Use this for initialization 36 | void Awake () { 37 | if (depthCullShader == null) { 38 | depthCullShader = Shader.Find ("Hidden/DepthCull"); 39 | } 40 | if (depthCullFrontMaterial == null) { 41 | depthCullFrontMaterial = new Material(Shader.Find ("Hidden/DepthCullFront")); 42 | } 43 | width = Screen.width; 44 | height = Screen.height; 45 | cam = GetComponent (); 46 | var camG = new GameObject ("Depth Camera", typeof(Camera)); 47 | depthCam = camG.GetComponent (); 48 | depthCam.CopyFrom (cam); 49 | camG.transform.SetParent (transform); 50 | camG.transform.localPosition = Vector3.zero; 51 | camG.transform.localRotation = Quaternion.identity; 52 | camG.transform.localScale = Vector3.one; 53 | camG.hideFlags = HideFlags.HideAndDontSave; 54 | depthCam.renderingPath = RenderingPath.Forward; 55 | depthCam.SetReplacementShader (Shader.Find ("Hidden/Depth"),"RenderType"); 56 | depthCam.farClipPlane = blurRange; 57 | depthCam.clearFlags = CameraClearFlags.Color; 58 | depthCam.backgroundColor = Color.red; 59 | depthCam.cullingMask = (~skinLayer) & depthCam.cullingMask; 60 | depthCam.depthTextureMode = DepthTextureMode.None; 61 | depthCam.enabled = false; 62 | var depthCullObj = Instantiate (camG, camG.transform.position, camG.transform.rotation, camG.transform.parent) as GameObject; 63 | depthCullCam = depthCullObj.GetComponent (); 64 | depthCullCam.backgroundColor = Color.black; 65 | depthCullCam.cullingMask = cam.cullingMask & skinLayer; 66 | depthCullCam.enabled = false; 67 | 68 | depthCullObj.hideFlags = HideFlags.HideAndDontSave; 69 | originMapID = Shader.PropertyToID ("_OriginTex"); 70 | blendTexID = Shader.PropertyToID ("_BlendTex"); 71 | mat = new Material (Shader.Find ("Hidden/SSSSS")); 72 | blendWeightID = Shader.PropertyToID ("_BlendWeight"); 73 | offsetID = Shader.PropertyToID ("_Offset"); 74 | mat.SetFloat (offsetID, offset); 75 | camG.AddComponent ().current = this; 76 | var dcc = depthCullObj.AddComponent (); 77 | dcc.mat = mat; 78 | dcc.current = this; 79 | commandBuffer = new CommandBuffer (); 80 | cullFrontDepthTex = new RenderTexture (Screen.width, Screen.height, 24, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear); 81 | if (cam.actualRenderingPath == RenderingPath.DeferredShading) 82 | cam.AddCommandBuffer (CameraEvent.BeforeGBuffer, commandBuffer); 83 | else 84 | cam.AddCommandBuffer (CameraEvent.BeforeForwardOpaque, commandBuffer); 85 | tempID1 = Shader.PropertyToID ("_CullFrontDepthTex"); 86 | tempID2 = Shader.PropertyToID ("_Temp2"); 87 | } 88 | 89 | void OnPreCull(){ 90 | isScreenChanged = (width != Screen.width) || (height != Screen.height); 91 | if (isScreenChanged) { 92 | width = Screen.width; 93 | height = Screen.height; 94 | cullFrontDepthTex.Release (); 95 | cullFrontDepthTex.width = width; 96 | cullFrontDepthTex.height = height; 97 | } 98 | if (useBlur) { 99 | depthCam.Render (); 100 | depthCullCam.Render (); 101 | } 102 | commandBuffer.SetRenderTarget (cullFrontDepthTex); 103 | commandBuffer.ClearRenderTarget (true, true, Color.red); 104 | 105 | 106 | commandBuffer.ReleaseTemporaryRT (tempID1); 107 | currentCommandBuffer = commandBuffer; 108 | isCommandBufferReady = true; 109 | } 110 | 111 | void OnPreRender(){ 112 | var dest = cullFrontDepthTex.descriptor; 113 | commandBuffer.GetTemporaryRT (tempID1, dest); 114 | commandBuffer.GetTemporaryRT (tempID2, dest); 115 | commandBuffer.Blit (BuiltinRenderTextureType.CurrentActive, tempID1); 116 | commandBuffer.Blit (tempID1, tempID2, mat, 5); 117 | commandBuffer.Blit (tempID2, tempID1, mat, 5); 118 | 119 | } 120 | 121 | void OnPostRender(){ 122 | isCommandBufferReady = false; 123 | commandBuffer.Clear (); 124 | } 125 | 126 | void OnDestroy(){ 127 | if(depthCam) 128 | Destroy (depthCam.gameObject); 129 | if (depthCullCam) 130 | Destroy (depthCullCam.gameObject); 131 | if (cam.actualRenderingPath == RenderingPath.DeferredShading) 132 | cam.RemoveCommandBuffer (CameraEvent.BeforeGBuffer, commandBuffer); 133 | else 134 | cam.RemoveCommandBuffer (CameraEvent.BeforeForwardOpaque, commandBuffer); 135 | commandBuffer.Dispose (); 136 | } 137 | 138 | #endregion 139 | 140 | #region POST_PROCESS 141 | int originMapID; 142 | int blendTexID; 143 | int blendWeightID; 144 | int offsetID; 145 | 146 | void OnRenderImage(RenderTexture src, RenderTexture dest){ 147 | if (useBlur) { 148 | #if UNITY_EDITOR 149 | mat.SetFloat (offsetID, offset); 150 | #endif 151 | RenderTexture origin = RenderTexture.GetTemporary (src.descriptor); 152 | RenderTexture copyOri = RenderTexture.GetTemporary (src.descriptor); 153 | Graphics.Blit (src, origin); 154 | mat.SetTexture (originMapID, src); 155 | RenderTexture blur1 = RenderTexture.GetTemporary (src.descriptor); 156 | RenderTexture blur2 = RenderTexture.GetTemporary (src.descriptor); 157 | 158 | mat.SetTexture (blendTexID, origin); 159 | mat.SetVector (blendWeightID, new Vector4 (0.33f, 0.45f, 0.36f)); 160 | Graphics.Blit (origin, blur1, mat, 0); 161 | Graphics.Blit (blur1, blur2, mat, 1); 162 | Graphics.Blit (blur2, copyOri, mat, 2); 163 | 164 | mat.SetTexture (blendTexID, copyOri); 165 | mat.SetVector (blendWeightID, new Vector4 (0.34f, 0.19f)); 166 | Graphics.Blit (copyOri, blur1, mat, 0); 167 | Graphics.Blit (blur1, blur2, mat, 1); 168 | Graphics.Blit (blur2, origin, mat, 2); 169 | 170 | mat.SetTexture (blendTexID, origin); 171 | mat.SetVector (blendWeightID, new Vector4 (0.46f, 0f, 0.04f)); 172 | Graphics.Blit (origin, blur1, mat, 0); 173 | Graphics.Blit (blur1, blur2, mat, 1); 174 | Graphics.Blit (blur2, copyOri, mat, 2); 175 | 176 | Graphics.Blit (copyOri, dest, mat, 3); 177 | RenderTexture.ReleaseTemporary (blur1); 178 | RenderTexture.ReleaseTemporary (blur2); 179 | RenderTexture.ReleaseTemporary (origin); 180 | RenderTexture.ReleaseTemporary (copyOri); 181 | } else { 182 | Graphics.Blit (src, dest); 183 | } 184 | } 185 | 186 | #endregion 187 | } 188 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Scripts/SSSSSCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6de97b53c69fb844d9876b28a01cf529 3 | timeCreated: 1521241271 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Scripts/SSSSSDepthCamera.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Rendering; 5 | using System.Threading.Tasks; 6 | 7 | public class SSSSSDepthCamera : MonoBehaviour { 8 | public SSSSSCamera current; 9 | Camera cam; 10 | RenderTexture depthRT; 11 | int depthID; 12 | 13 | void Awake(){ 14 | cam = GetComponent (); 15 | depthID = Shader.PropertyToID ("_CameraDepthTextureWithoutSkin"); 16 | depthRT = new RenderTexture (Screen.width, Screen.height, 24, RenderTextureFormat.ARGBFloat); 17 | cam.targetTexture = depthRT; 18 | } 19 | 20 | void OnPreRender(){ 21 | if (current.isScreenChanged) { 22 | depthRT.Release (); 23 | depthRT.width = current.width; 24 | depthRT.height = current.height; 25 | } 26 | Shader.SetGlobalTexture (depthID, depthRT); 27 | } 28 | 29 | void OnDestroy(){ 30 | Destroy (depthRT); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Scripts/SSSSSDepthCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 753304a0050b67047bfa2f5f0bf1641f 3 | timeCreated: 1521305488 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Scripts/SSSSSDepthCullCam.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class SSSSSDepthCullCam : MonoBehaviour { 6 | public SSSSSCamera current; 7 | Camera cam; 8 | RenderTexture maskRT; 9 | [System.NonSerialized] 10 | public Material mat; 11 | int maskID; 12 | // Use this for initialization 13 | void Awake () { 14 | cam = GetComponent (); 15 | cam.SetReplacementShader (SSSSSCamera.depthCullShader, "RenderType"); 16 | maskRT = new RenderTexture (Screen.width, Screen.height, 0, RenderTextureFormat.RFloat,RenderTextureReadWrite.Linear); 17 | cam.targetTexture = maskRT; 18 | maskID = Shader.PropertyToID ("_SSMaskTex"); 19 | } 20 | 21 | void OnDestroy(){ 22 | Destroy (maskRT); 23 | } 24 | 25 | void OnPreRender(){ 26 | if (current.isScreenChanged) { 27 | maskRT.Release (); 28 | maskRT.width = current.width; 29 | maskRT.height = current.height; 30 | } 31 | Shader.SetGlobalTexture (maskID, maskRT); 32 | } 33 | 34 | void OnRenderImage(RenderTexture src, RenderTexture dest){ 35 | RenderTexture blur1 = RenderTexture.GetTemporary (src.descriptor); 36 | Graphics.Blit (src, blur1,mat,4); 37 | Graphics.Blit (blur1, dest, mat, 4); 38 | RenderTexture.ReleaseTemporary (blur1); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Scripts/SSSSSDepthCullCam.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4ceae45d4f6366429990260f6375d21 3 | timeCreated: 1521389095 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Scripts/SSSSSSkinRenderer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | [RequireComponent(typeof(MeshFilter))] 5 | public class SSSSSSkinRenderer : MonoBehaviour { 6 | Mesh mesh; 7 | void Awake(){ 8 | mesh = GetComponent ().sharedMesh; 9 | } 10 | 11 | void OnWillRenderObject(){ 12 | 13 | if (SSSSSCamera.isCommandBufferReady) { 14 | SSSSSCamera.currentCommandBuffer.DrawMesh (mesh, transform.localToWorldMatrix, SSSSSCamera.depthCullFrontMaterial); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Scripts/SSSSSSkinRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d947702d48871464596570e1bebfa672 3 | timeCreated: 1521416182 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 159ca8a0ef90b714c95aad97d9775353 3 | folderAsset: yes 4 | timeCreated: 1521672893 5 | licenseType: Pro 6 | DefaultImporter: 7 | externalObjects: {} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/Depth.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 2 | 3 | Shader "Hidden/Depth" { 4 | SubShader { 5 | Tags { "RenderType"="Opaque" } 6 | Pass { 7 | 8 | CGPROGRAM 9 | #pragma vertex vert 10 | #pragma fragment frag 11 | #include "UnityCG.cginc" 12 | 13 | struct v2f { 14 | float4 pos : SV_POSITION; 15 | }; 16 | 17 | v2f vert (appdata_base v) { 18 | v2f o; 19 | o.pos = UnityObjectToClipPos (v.vertex); 20 | return o; 21 | } 22 | 23 | float4 frag(v2f i) : COLOR { 24 | return EncodeFloatRGBA(Linear01Depth(i.pos.z / i.pos.w)); 25 | 26 | } 27 | ENDCG 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/Depth.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ceca7095004f7b64f95a20d9ba7571eb 3 | timeCreated: 1521278185 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/DepthCull.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/DepthCull" 2 | { 3 | SubShader 4 | { 5 | Tags { "RenderType"="Opaque"} 6 | ZTest always 7 | ZWrite off 8 | Pass 9 | { 10 | 11 | CGPROGRAM 12 | #pragma vertex vert 13 | #pragma fragment frag 14 | #include "UnityCG.cginc" 15 | 16 | uniform sampler2D _CameraDepthTextureWithoutSkin; 17 | struct appdata 18 | { 19 | float4 vertex : POSITION; 20 | }; 21 | 22 | struct v2f 23 | { 24 | 25 | float4 pos : SV_POSITION; 26 | float4 screenPos : TEXCOORD1; 27 | 28 | }; 29 | 30 | v2f vert (appdata v) 31 | { 32 | v2f o; 33 | o.pos = UnityObjectToClipPos(v.vertex); 34 | 35 | o.screenPos = ComputeScreenPos(o.pos); 36 | 37 | return o; 38 | } 39 | 40 | float4 frag (v2f i) : SV_Target 41 | { 42 | float currentDepth = Linear01Depth(i.pos.z / i.pos.w); 43 | float depth = DecodeFloatRGBA(tex2Dproj(_CameraDepthTextureWithoutSkin, i.screenPos)); 44 | clip(depth - currentDepth); 45 | return 1; 46 | } 47 | ENDCG 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/DepthCull.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a360b58df37403c4aa6f10f251c36de7 3 | timeCreated: 1521230777 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/DepthCullFront.shader: -------------------------------------------------------------------------------- 1 | // Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld' 2 | 3 | // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)' 4 | 5 | Shader "Hidden/DepthCullFront" { 6 | SubShader { 7 | Tags { "RenderType"="Opaque" } 8 | Pass { 9 | Cull Front 10 | CGPROGRAM 11 | #pragma vertex vert 12 | #pragma fragment frag 13 | #include "UnityCG.cginc" 14 | 15 | struct v2f { 16 | float4 pos : SV_POSITION; 17 | float3 worldPos : TEXCOORD0; 18 | }; 19 | 20 | v2f vert (appdata_base v) { 21 | v2f o; 22 | v.vertex.xyz += v.normal * 0.005; 23 | o.pos = UnityObjectToClipPos (v.vertex); 24 | o.worldPos = mul(unity_ObjectToWorld, v.vertex) - _WorldSpaceCameraPos; 25 | return o; 26 | } 27 | 28 | float4 frag(v2f i) : COLOR { 29 | return EncodeFloatRGBA(length(i.worldPos) / 255); 30 | } 31 | ENDCG 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/DepthCullFront.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3da68a6116db2934388d26460da72567 3 | timeCreated: 1521415872 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/SSSSS.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/SSSSS" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Tex", 2D) = "white" {} 6 | } 7 | SubShader 8 | { 9 | CGINCLUDE 10 | #include "UnityCG.cginc" 11 | 12 | sampler2D _MainTex; 13 | float4 _MainTex_TexelSize; 14 | float _Offset; 15 | 16 | inline float4 getWeightedColor(float2 uv, float2 offset){ 17 | float4 c = tex2D(_MainTex, uv) * 0.324; 18 | float2 offsetM3 = offset * 3; 19 | float2 offsetM2 = offset * 2; 20 | c += tex2D(_MainTex, uv + offsetM3) * 0.0205; 21 | c += tex2D(_MainTex, uv + offsetM2) * 0.0855; 22 | c += tex2D(_MainTex, uv + offset) * 0.232; 23 | c += tex2D(_MainTex, uv - offsetM3) * 0.0205; 24 | c += tex2D(_MainTex, uv - offsetM2) * 0.0855; 25 | c += tex2D(_MainTex, uv - offset) * 0.232; 26 | return c; 27 | } 28 | struct v2f_mg 29 | { 30 | float2 uv : TEXCOORD0; 31 | float4 vertex : SV_POSITION; 32 | float2 offset : TEXCOORD1; 33 | }; 34 | inline float4 frag_blur (v2f_mg i) : SV_Target 35 | { 36 | return getWeightedColor(i.uv, i.offset); 37 | } 38 | 39 | ENDCG 40 | //0. vert 1. hori 2. blend 3. mask 41 | // No culling or depth 42 | Cull Off ZWrite Off ZTest Always 43 | 44 | Pass 45 | { 46 | //Vertical 47 | CGPROGRAM 48 | #pragma vertex vert 49 | #pragma fragment frag_blur 50 | 51 | 52 | struct appdata 53 | { 54 | float4 vertex : POSITION; 55 | float2 uv : TEXCOORD0; 56 | }; 57 | 58 | 59 | 60 | inline v2f_mg vert (appdata v) 61 | { 62 | v2f_mg o; 63 | o.vertex = UnityObjectToClipPos(v.vertex); 64 | o.uv = v.uv; 65 | o.offset = _MainTex_TexelSize.xy * float2(0,_Offset); 66 | return o; 67 | } 68 | ENDCG 69 | } 70 | 71 | Pass 72 | { 73 | //Horizontal 74 | CGPROGRAM 75 | #pragma vertex vert 76 | #pragma fragment frag_blur 77 | 78 | 79 | struct appdata 80 | { 81 | float4 vertex : POSITION; 82 | float2 uv : TEXCOORD0; 83 | }; 84 | 85 | 86 | inline v2f_mg vert (appdata v) 87 | { 88 | v2f_mg o; 89 | o.vertex = UnityObjectToClipPos(v.vertex); 90 | o.uv = v.uv; 91 | o.offset = _MainTex_TexelSize.xy * float2(_Offset,0); 92 | return o; 93 | } 94 | ENDCG 95 | } 96 | 97 | Pass{ 98 | //Blend 99 | CGPROGRAM 100 | #pragma vertex vert 101 | #pragma fragment frag 102 | 103 | sampler2D _BlendTex; 104 | float4 _BlendWeight; 105 | struct appdata 106 | { 107 | float4 vertex : POSITION; 108 | float2 uv : TEXCOORD0; 109 | }; 110 | 111 | struct v2f 112 | { 113 | float2 uv : TEXCOORD0; 114 | float4 vertex : SV_POSITION; 115 | float4 oneMinusWeight : TEXCOORD1; 116 | }; 117 | 118 | inline v2f vert (appdata v) 119 | { 120 | v2f o; 121 | o.vertex = UnityObjectToClipPos(v.vertex); 122 | o.uv = v.uv; 123 | o.oneMinusWeight = float4(1,1,1,1) - _BlendWeight; 124 | return o; 125 | } 126 | 127 | inline float4 frag (v2f i) : SV_Target 128 | { 129 | return tex2D(_MainTex, i.uv) * i.oneMinusWeight + tex2D(_BlendTex, i.uv) * _BlendWeight; 130 | } 131 | ENDCG 132 | } 133 | 134 | Pass{ 135 | //Mask 136 | CGPROGRAM 137 | #pragma vertex vert 138 | #pragma fragment frag 139 | 140 | sampler2D _OriginTex; 141 | uniform sampler2D _SSMaskTex; 142 | struct appdata 143 | { 144 | float4 vertex : POSITION; 145 | float2 uv : TEXCOORD0; 146 | }; 147 | 148 | struct v2f 149 | { 150 | float2 uv : TEXCOORD0; 151 | float4 vertex : SV_POSITION; 152 | }; 153 | 154 | inline v2f vert (appdata v) 155 | { 156 | v2f o; 157 | o.vertex = UnityObjectToClipPos(v.vertex); 158 | o.uv = v.uv; 159 | return o; 160 | } 161 | 162 | inline float4 frag (v2f i) : SV_Target 163 | { 164 | return lerp(tex2D(_OriginTex, i.uv), tex2D(_MainTex, i.uv), tex2D(_SSMaskTex,i.uv).r); 165 | } 166 | ENDCG 167 | } 168 | 169 | Pass 170 | { 171 | //DownSample 172 | CGPROGRAM 173 | #pragma vertex vert 174 | #pragma fragment frag 175 | 176 | 177 | struct appdata 178 | { 179 | float4 vertex : POSITION; 180 | float2 uv : TEXCOORD0; 181 | }; 182 | 183 | struct v2f 184 | { 185 | float2 uv : TEXCOORD0; 186 | float4 vertex : SV_POSITION; 187 | float4 offset : TEXCOORD1; 188 | }; 189 | 190 | inline v2f vert (appdata v) 191 | { 192 | v2f o; 193 | o.vertex = UnityObjectToClipPos(v.vertex); 194 | o.uv = v.uv; 195 | o.offset = float4(_MainTex_TexelSize.x,0,0,_MainTex_TexelSize.y); 196 | return o; 197 | } 198 | 199 | inline float4 frag (v2f i) : SV_Target{ 200 | float2 offset = _MainTex_TexelSize; 201 | float4 c = tex2D(_MainTex, i.uv + i.offset.xy); 202 | c += tex2D(_MainTex, i.uv + i.offset.zw); 203 | c += tex2D(_MainTex, i.uv - i.offset.xy); 204 | c += tex2D(_MainTex, i.uv - i.offset.zw); 205 | c.r = saturate(c.r); 206 | return c; 207 | } 208 | ENDCG 209 | } 210 | 211 | Pass 212 | { 213 | //DownSample 214 | CGPROGRAM 215 | #pragma vertex vert 216 | #pragma fragment frag 217 | 218 | 219 | struct appdata 220 | { 221 | float4 vertex : POSITION; 222 | float2 uv : TEXCOORD0; 223 | }; 224 | 225 | struct v2f 226 | { 227 | float2 uv : TEXCOORD0; 228 | float4 vertex : SV_POSITION; 229 | float4 offset : TEXCOORD1; 230 | }; 231 | 232 | inline v2f vert (appdata v) 233 | { 234 | v2f o; 235 | o.vertex = UnityObjectToClipPos(v.vertex); 236 | o.uv = v.uv; 237 | o.offset = float4(_MainTex_TexelSize.x,0,0,_MainTex_TexelSize.y); 238 | return o; 239 | } 240 | 241 | inline float4 frag (v2f i) : SV_Target{ 242 | float4 c = tex2D(_MainTex, i.uv + i.offset.xy); 243 | c += tex2D(_MainTex, i.uv + i.offset.zw); 244 | c += tex2D(_MainTex, i.uv - i.offset.xy); 245 | c += tex2D(_MainTex, i.uv - i.offset.zw); 246 | return c / 4; 247 | } 248 | ENDCG 249 | } 250 | } 251 | } 252 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/SSSSS.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5deb2072cb99ebc4b9992720834fe5e9 3 | timeCreated: 1521288277 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/Tess-SSS.shader: -------------------------------------------------------------------------------- 1 | Shader "Tessellation/SSS" { 2 | Properties { 3 | _MinDist("Tess Min Distance", float) = 10 4 | _MaxDist("Tess Max Distance", float) = 25 5 | _Tessellation("Tessellation", Range(1,63)) = 1 6 | _Phong ("Phong Strengh", Range(0,1)) = 0.5 7 | _Color ("Color", Color) = (1,1,1,1) 8 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 9 | _BumpMap("Normal Map", 2D) = "bump" {} 10 | _NormalScale("Normal Scale", float) = 1 11 | _SpecularMap("Specular Map", 2D) = "white"{} 12 | _HeightMap("Vertex Map", 2D) = "black"{} 13 | //_HeightScale("Height Scale", Range(-4,4)) = 1 14 | _Glossiness ("Smoothness", Range(0,1)) = 0.5 15 | _OcclusionMap("Occlusion Map", 2D) = "white"{} 16 | _Occlusion("Occlusion Scale", Range(0,1)) = 1 17 | _SpecularColor("Specular Color",Color) = (0.2,0.2,0.2,1) 18 | _EmissionColor("Emission Color", Color) = (0,0,0,1) 19 | _VertexScale("Vertex Scale", Range(-3,3)) = 0.1 20 | _VertexOffset("Vertex Offset", float) = 0 21 | _DetailAlbedo("Detail Albedo(RGB) Mask(A)", 2D) = "black"{} 22 | _AlbedoBlend("Albedo Blend Rate", Range(0,1)) = 0.3 23 | _DetailBump("Detail Bump(RGB) Mask(A)", 2D) = "bump"{} 24 | _BumpBlend("Bump Blend Rate", Range(0,1)) = 0.3 25 | _Power("Power of SSS", Range(0.1,10)) = 1 26 | _SSColor("SSS Color", Color) = (1,1,1,1) 27 | _Thickness("Thickness", float) = 1 28 | _MinDistance("Min SSS transparent Distance", Range(0,2)) = 0.001 29 | _Distortion("Normal Distortion", Range(0,6)) = 1 30 | } 31 | SubShader { 32 | Tags { "RenderType"="Opaque" } 33 | LOD 200 34 | 35 | 36 | // ------------------------------------------------------------ 37 | // Surface shader code generated out of a CGPROGRAM block: 38 | CGINCLUDE 39 | 40 | #include "HLSLSupport.cginc" 41 | #include "UnityShaderVariables.cginc" 42 | #include "UnityShaderUtilities.cginc" 43 | #include "UnityCG.cginc" 44 | #include "Lighting.cginc" 45 | #include "UnityPBSLighting.cginc" 46 | #include "UnityMetaPass.cginc" 47 | #include "AutoLight.cginc" 48 | #pragma shader_feature USE_FILTER 49 | #pragma shader_feature USE_NORMAL 50 | #pragma shader_feature USE_SPECULAR 51 | #pragma shader_feature USE_VERTEX 52 | #pragma shader_feature USE_PHONG 53 | #pragma shader_feature USE_OCCLUSION 54 | #pragma shader_feature USE_ALBEDO 55 | #pragma shader_feature USE_DETAILALBEDO 56 | #pragma shader_feature USE_DETAILNORMAL 57 | 58 | #ifdef POINT 59 | #define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \ 60 | unityShadowCoord3 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(worldPos, 1)).xyz; \ 61 | float shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \ 62 | float destName = tex2D(_LightTexture0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL * shadow; 63 | 64 | //inline void unity_attenuation(inout float atten, inout float attenNoShadow, v2f_surf input, float3 worldPos){ 65 | 66 | #endif 67 | 68 | #ifdef SPOT 69 | #define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \ 70 | unityShadowCoord4 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(worldPos, 1)); \ 71 | float shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \ 72 | float destName = step(0,lightCoord.z) * UnitySpotCookie(lightCoord) * UnitySpotAttenuate(lightCoord.xyz) * shadow; 73 | #endif 74 | 75 | #ifdef DIRECTIONAL 76 | #define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) float destName = UNITY_SHADOW_ATTENUATION(input, worldPos); 77 | #endif 78 | 79 | #ifdef POINT_COOKIE 80 | 81 | #define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \ 82 | unityShadowCoord3 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(worldPos, 1)).xyz; \ 83 | float shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \ 84 | float destName = tex2D(_LightTextureB0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL * texCUBE(_LightTexture0, lightCoord).w * shadow; 85 | #endif 86 | 87 | #ifdef DIRECTIONAL_COOKIE 88 | 89 | #define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \ 90 | unityShadowCoord2 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(worldPos, 1)).xy; \ 91 | float shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \ 92 | float destName = tex2D(_LightTexture0, lightCoord).w * shadow; 93 | #endif 94 | 95 | 96 | 97 | 98 | struct Input { 99 | float2 uv_MainTex; 100 | #if USE_DETAILALBEDO 101 | float2 uv_DetailAlbedo; 102 | #endif 103 | #if USE_DETAILNORMAL 104 | float2 uv_DetailNormal; 105 | #endif 106 | }; 107 | 108 | float4 _SpecularColor; 109 | float4 _EmissionColor; 110 | float _MinDist; 111 | float _MaxDist; 112 | float _Tessellation; 113 | float _HeightScale; 114 | float _Phong; 115 | float _NormalScale; 116 | float _Occlusion; 117 | float _VertexScale; 118 | float _VertexOffset; 119 | float _Power; 120 | float _Thickness; 121 | float4 _SSColor; 122 | float _MinDistance; 123 | sampler2D _DetailAlbedo; 124 | float _AlbedoBlend; 125 | sampler2D _DetailBump; 126 | float _Distortion; 127 | float _BumpBlend; 128 | float4 _DetailAlbedo_ST; 129 | float4 _DetailBump_ST; 130 | float4 _FrustArray[4]; 131 | 132 | sampler2D _BumpMap; 133 | sampler2D _SpecularMap; 134 | sampler2D _HeightMap; 135 | sampler2D _OcclusionMap; 136 | sampler2D _MainTex; 137 | uniform sampler2D _CullFrontDepthTex; 138 | half _Glossiness; 139 | float4 _Color; 140 | 141 | inline void surf (Input IN, inout SurfaceOutputStandardSpecular o) { 142 | // Albedo comes from a texture tinted by color 143 | float2 uv = IN.uv_MainTex;// - parallax_mapping(IN.uv_MainTex,IN.viewDir); 144 | #if USE_ALBEDO 145 | float4 c = tex2D (_MainTex, uv) * _Color; 146 | 147 | #if USE_DETAILALBEDO 148 | float4 dA = tex2D(_DetailAlbedo, IN.uv_DetailAlbedo); 149 | c.rgb = lerp(c.rgb, dA.rgb, _AlbedoBlend); 150 | #endif 151 | o.Albedo = c.rgb; 152 | o.Alpha = c.a; 153 | #else 154 | #if USE_DETAILALBEDO 155 | float4 dA = tex2D(_DetailAlbedo, IN.uv_DetailAlbedo); 156 | o.Albedo.rgb = lerp(1, dA.rgb, _AlbedoBlend) * _Color; 157 | #else 158 | o.Albedo = _Color.rgb; 159 | o.Alpha = _Color.a; 160 | #endif 161 | #endif 162 | 163 | #if USE_OCCLUSION 164 | o.Occlusion = lerp(1, tex2D(_OcclusionMap, IN.uv_MainTex).r, _Occlusion); 165 | #else 166 | o.Occlusion = 1; 167 | #endif 168 | 169 | #if USE_SPECULAR 170 | float4 spec = tex2D(_SpecularMap, IN.uv_MainTex); 171 | o.Specular = _SpecularColor * spec.rgb; 172 | o.Smoothness = _Glossiness * spec.a; 173 | #else 174 | o.Specular = _SpecularColor; 175 | o.Smoothness = _Glossiness; 176 | #endif 177 | 178 | 179 | #if USE_NORMAL 180 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex)); 181 | #if USE_DETAILNORMAL 182 | float4 dN = tex2D(_DetailBump,IN.uv_DetailNormal); 183 | o.Normal = lerp(o.Normal, UnpackNormal(dN), _BumpBlend); 184 | #endif 185 | o.Normal.xy *= _NormalScale; 186 | 187 | #else 188 | o.Normal = float3(0,0,1); 189 | #endif 190 | #if UNITY_PASS_FORWARDBASE 191 | o.Emission = _EmissionColor; 192 | #endif 193 | } 194 | struct InternalTessInterp_appdata_full { 195 | float4 vertex : INTERNALTESSPOS; 196 | float4 tangent : TANGENT; 197 | float3 normal : NORMAL; 198 | float4 texcoord : TEXCOORD0; 199 | float4 texcoord1 : TEXCOORD1; 200 | float4 texcoord2 : TEXCOORD2; 201 | float4 color : COLOR; 202 | }; 203 | inline InternalTessInterp_appdata_full tessvert_surf (appdata_full v) { 204 | InternalTessInterp_appdata_full o; 205 | o.vertex = v.vertex; 206 | o.tangent = v.tangent; 207 | o.normal = v.normal; 208 | o.texcoord = v.texcoord; 209 | o.texcoord1 = v.texcoord1; 210 | o.texcoord2 = v.texcoord2; 211 | o.color = v.color; 212 | return o; 213 | } 214 | 215 | inline float3 SubTransparentColor(float3 lightDir, float3 normal, float3 viewDir, float3 lightColor, float3 pointDepth){ 216 | float VdotH = pow(saturate(dot(viewDir, -normalize(lightDir + normal * _Distortion)) + 0.5), _Power); 217 | return lightColor * VdotH * _SSColor.rgb * pointDepth; 218 | } 219 | 220 | inline void vert(inout appdata_full v){ 221 | v.vertex.xyz += v.normal *( (tex2Dlod(_HeightMap, v.texcoord).r - 0.5) * _VertexScale + _VertexOffset); 222 | } 223 | 224 | inline float near1 (float x){ 225 | return x / (x + 0.5); 226 | } 227 | 228 | inline float3 UnityCalcTriEdgeTessFactors (float3 triVertexFactors) 229 | { 230 | float3 tess; 231 | tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z); 232 | tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z); 233 | tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y); 234 | return tess; 235 | } 236 | 237 | 238 | inline float UnityCalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess) 239 | { 240 | float3 wpos = mul(unity_ObjectToWorld,vertex).xyz; 241 | float dist = distance (wpos, _WorldSpaceCameraPos); 242 | float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess; 243 | return f; 244 | } 245 | 246 | inline float3 tessDist (float4 v0, float4 v1, float4 v2) 247 | { 248 | float3 f; 249 | f.x = UnityCalcDistanceTessFactor (v0,_MinDist,_MaxDist,_Tessellation); 250 | f.y = UnityCalcDistanceTessFactor (v1,_MinDist,_MaxDist,_Tessellation); 251 | f.z = UnityCalcDistanceTessFactor (v2,_MinDist,_MaxDist,_Tessellation); 252 | return UnityCalcTriEdgeTessFactors (f); 253 | } 254 | //TODO 255 | //Calculate thickness 256 | 257 | inline UnityTessellationFactors hsconst_surf (InputPatch v) { 258 | UnityTessellationFactors o; 259 | #if USE_FILTER 260 | float3 tf = (tessDist(v[0].vertex, v[1].vertex, v[2].vertex) - 1); 261 | o.edge[0] = tf.x * v[0].color.a + 1; 262 | o.edge[1] = tf.y * v[1].color.a + 1; 263 | o.edge[2] = tf.z * v[2].color.a + 1; 264 | o.inside = (o.edge[0] + o.edge[1] + o.edge[2]) * 0.33333333; 265 | #else 266 | float3 tf = (tessDist(v[0].vertex, v[1].vertex, v[2].vertex)); 267 | o.edge[0] = tf.x; 268 | o.edge[1] = tf.y; 269 | o.edge[2] = tf.z; 270 | o.inside = (tf.x + tf.y + tf.z) * 0.33333333; 271 | #endif 272 | return o; 273 | } 274 | 275 | [UNITY_domain("tri")] 276 | [UNITY_partitioning("fractional_odd")] 277 | [UNITY_outputtopology("triangle_cw")] 278 | [UNITY_patchconstantfunc("hsconst_surf")] 279 | [UNITY_outputcontrolpoints(3)] 280 | inline InternalTessInterp_appdata_full hs_surf (InputPatch v, uint id : SV_OutputControlPointID) { 281 | return v[id]; 282 | } 283 | ENDCG 284 | // ---- forward rendering base pass: 285 | Pass { 286 | Name "FORWARD" 287 | Tags { "LightMode" = "ForwardBase" } 288 | 289 | CGPROGRAM 290 | // compile directives 291 | #pragma vertex tessvert_surf 292 | #pragma fragment frag_surf 293 | #pragma hull hs_surf 294 | #pragma domain ds_surf 295 | #pragma target 5.0 296 | 297 | #pragma multi_compile_fog 298 | #pragma multi_compile_fwdbase 299 | 300 | // -------- variant for: 301 | #if !defined(INSTANCING_ON) 302 | // Surface shader code generated based on: 303 | // vertex modifier: 'disp' 304 | // writes to per-pixel normal: YES 305 | // writes to emission: YES 306 | // writes to occlusion: YES 307 | // needs world space reflection vector: no 308 | // needs world space normal vector: no 309 | // needs screen space position: no 310 | // needs world space position: no 311 | // needs view direction: no 312 | // needs world space view direction: no 313 | // needs world space position for lighting: YES 314 | // needs world space view direction for lighting: YES 315 | // needs world space view direction for lightmaps: no 316 | // needs vertex color: no 317 | // needs VFACE: no 318 | // passes tangent-to-world matrix to pixel shader: YES 319 | // reads from normal: no 320 | // 1 texcoords actually used 321 | // float2 _MainTex 322 | #define UNITY_PASS_FORWARDBASE 323 | 324 | 325 | #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2; 326 | #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))) 327 | #define WorldNormalVector(data,normal) float3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)) 328 | 329 | // Original surface shader snippet: 330 | #line 22 "" 331 | #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING 332 | #endif 333 | 334 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 335 | 336 | // tessellation vertex shader 337 | 338 | 339 | // tessellation hull constant shader 340 | 341 | 342 | // tessellation hull shader 343 | 344 | 345 | #endif // UNITY_CAN_COMPILE_TESSELLATION 346 | 347 | 348 | // vertex-to-fragment interpolation data 349 | // no lightmaps: 350 | #ifndef LIGHTMAP_ON 351 | struct v2f_surf { 352 | UNITY_POSITION(pos); 353 | float2 pack0 : TEXCOORD0; // _MainTex 354 | float4 tSpace0 : TEXCOORD1; 355 | float4 tSpace1 : TEXCOORD2; 356 | float4 tSpace2 : TEXCOORD3; 357 | 358 | #if UNITY_SHOULD_SAMPLE_SH 359 | half3 sh : TEXCOORD4; // SH 360 | #endif 361 | UNITY_SHADOW_COORDS(5) 362 | UNITY_FOG_COORDS(6) 363 | #if SHADER_TARGET >= 30 364 | float4 lmap : TEXCOORD7; 365 | #endif 366 | 367 | #if USE_DETAILALBEDO 368 | float2 pack1 : TEXCOORD8; 369 | #endif 370 | 371 | #if USE_DETAILNORMAL 372 | float2 pack2 : TEXCOORD9; 373 | #endif 374 | float3 worldViewDir : TEXCOORD10; 375 | float3 lightDir : TEXCOORD11; 376 | float4 screenPos : TEXCOORD12; 377 | }; 378 | #endif 379 | // with lightmaps: 380 | #ifdef LIGHTMAP_ON 381 | struct v2f_surf { 382 | UNITY_POSITION(pos); 383 | float2 pack0 : TEXCOORD0; // _MainTex 384 | float4 tSpace0 : TEXCOORD1; 385 | float4 tSpace1 : TEXCOORD2; 386 | float4 tSpace2 : TEXCOORD3; 387 | 388 | float4 lmap : TEXCOORD4; 389 | UNITY_SHADOW_COORDS(5) 390 | UNITY_FOG_COORDS(6) 391 | 392 | 393 | #if USE_DETAILALBEDO 394 | float2 pack1 : TEXCOORD7; 395 | #endif 396 | 397 | #if USE_DETAILNORMAL 398 | float2 pack2 : TEXCOORD8; 399 | #endif 400 | float3 worldViewDir : TEXCOORD9; 401 | float3 lightDir : TEXCOORD10; 402 | float4 screenPos : TEXCOORD11; 403 | }; 404 | #endif 405 | float4 _MainTex_ST; 406 | 407 | // vertex shader 408 | inline v2f_surf vert_surf (appdata_full v) { 409 | UNITY_SETUP_INSTANCE_ID(v); 410 | v2f_surf o; 411 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 412 | 413 | 414 | o.pos = UnityObjectToClipPos(v.vertex); 415 | o.screenPos = ComputeScreenPos(o.pos); 416 | o.pack0.xy = TRANSFORM_TEX(v.texcoord, _MainTex); 417 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 418 | o.worldViewDir = (UnityWorldSpaceViewDir(worldPos)); 419 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 420 | float3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz); 421 | float tangentSign = v.tangent.w * unity_WorldTransformParams.w; 422 | float3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign; 423 | #if USE_DETAILALBEDO 424 | o.pack1 = TRANSFORM_TEX(v.texcoord,_DetailAlbedo); 425 | #endif 426 | #if USE_DETAILNORMAL 427 | o.pack2 = TRANSFORM_TEX(v.texcoord, _DetailBump); 428 | #endif 429 | o.tSpace0 = (float4(worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x)); 430 | o.tSpace1 = (float4(worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y)); 431 | o.tSpace2 = (float4(worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z)); 432 | 433 | #ifdef DYNAMICLIGHTMAP_ON 434 | o.lmap.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; 435 | #endif 436 | #ifdef LIGHTMAP_ON 437 | o.lmap.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 438 | #endif 439 | 440 | // SH/ambient and vertex lights 441 | #ifndef LIGHTMAP_ON 442 | #if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL 443 | o.sh = 0; 444 | // Approximated illumination from non-important point lights 445 | #ifdef VERTEXLIGHT_ON 446 | o.sh += Shade4PointLights ( 447 | unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, 448 | unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb, 449 | unity_4LightAtten0, worldPos, worldNormal); 450 | #endif 451 | o.sh = ShadeSHPerVertex (worldNormal, o.sh); 452 | #endif 453 | #endif // !LIGHTMAP_ON 454 | 455 | UNITY_TRANSFER_SHADOW(o,v.texcoord1.xy); // pass shadow coordinates to pixel shader 456 | UNITY_TRANSFER_FOG(o,o.pos); // pass fog coordinates to pixel shader 457 | #ifndef USING_DIRECTIONAL_LIGHT 458 | o.lightDir = (UnityWorldSpaceLightDir(worldPos)); 459 | #else 460 | o.lightDir = _WorldSpaceLightPos0.xyz; 461 | #endif 462 | return o; 463 | } 464 | 465 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 466 | 467 | // tessellation domain shader 468 | [UNITY_domain("tri")] 469 | inline v2f_surf ds_surf (UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) { 470 | appdata_full v; 471 | v.vertex = vi[0].vertex*bary.x + vi[1].vertex*bary.y + vi[2].vertex*bary.z; 472 | 473 | #if USE_PHONG 474 | float3 pp[3]; 475 | pp[0] = v.vertex.xyz - vi[0].normal * (dot(v.vertex.xyz, vi[0].normal) - dot(vi[0].vertex.xyz, vi[0].normal)); 476 | pp[1] = v.vertex.xyz - vi[1].normal * (dot(v.vertex.xyz, vi[1].normal) - dot(vi[1].vertex.xyz, vi[1].normal)); 477 | pp[2] = v.vertex.xyz - vi[2].normal * (dot(v.vertex.xyz, vi[2].normal) - dot(vi[2].vertex.xyz, vi[2].normal)); 478 | v.vertex.xyz = _Phong * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-_Phong) * v.vertex.xyz; 479 | #endif 480 | 481 | v.tangent = vi[0].tangent*bary.x + vi[1].tangent*bary.y + vi[2].tangent*bary.z; 482 | v.normal = vi[0].normal*bary.x + vi[1].normal*bary.y + vi[2].normal*bary.z; 483 | v.texcoord = vi[0].texcoord*bary.x + vi[1].texcoord*bary.y + vi[2].texcoord*bary.z; 484 | v.texcoord1 = vi[0].texcoord1*bary.x + vi[1].texcoord1*bary.y + vi[2].texcoord1*bary.z; 485 | v.texcoord2 = vi[0].texcoord2*bary.x + vi[1].texcoord2*bary.y + vi[2].texcoord2*bary.z; 486 | v.texcoord3 = 0; 487 | v.color = 0; 488 | #if USE_VERTEX 489 | vert(v); 490 | #endif 491 | v2f_surf o = vert_surf (v); 492 | return o; 493 | } 494 | 495 | #endif // UNITY_CAN_COMPILE_TESSELLATION 496 | 497 | 498 | // fragment shader 499 | inline float4 frag_surf (v2f_surf IN) : SV_Target { 500 | UNITY_SETUP_INSTANCE_ID(IN); 501 | // prepare and unpack data 502 | Input surfIN; 503 | UNITY_INITIALIZE_OUTPUT(Input,surfIN); 504 | surfIN.uv_MainTex.x = 1.0; 505 | 506 | surfIN.uv_MainTex = IN.pack0.xy; 507 | #if USE_DETAILALBEDO 508 | surfIN.uv_DetailAlbedo = IN.pack1; 509 | #endif 510 | 511 | #if USE_DETAILNORMAL 512 | surfIN.uv_DetailNormal = IN.pack2; 513 | #endif 514 | float3 worldPos = float3(IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w); 515 | float3 lightDir = normalize(IN.lightDir); 516 | float3 worldViewDir = normalize(IN.worldViewDir); 517 | #ifdef UNITY_COMPILER_HLSL 518 | SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0; 519 | #else 520 | SurfaceOutputStandardSpecular o; 521 | #endif 522 | float3x3 wdMatrix= float3x3( normalize(IN.tSpace0.xyz), normalize(IN.tSpace1.xyz), normalize(IN.tSpace2.xyz)); 523 | // call surface function 524 | surf (surfIN, o); 525 | 526 | // compute lighting & shadowing factor 527 | UNITY_LIGHT_ATTENUATION(atten, IN, worldPos) 528 | float4 c = 0; 529 | 530 | o.Normal = normalize(mul(wdMatrix, o.Normal)); 531 | float fragDepth = length(worldPos - _WorldSpaceCameraPos); 532 | float backDepth = DecodeFloatRGBA(tex2Dproj(_CullFrontDepthTex, IN.screenPos)) * 255; 533 | float thickness = saturate(1 - tanh(max(backDepth - fragDepth, _MinDistance) * _Thickness)); 534 | // Setup lighting environment 535 | UnityGI gi; 536 | UNITY_INITIALIZE_OUTPUT(UnityGI, gi); 537 | gi.light.color = _LightColor0.rgb; 538 | gi.light.dir = lightDir; 539 | float3 transparentColor = SubTransparentColor(lightDir, o.Normal, worldViewDir, _LightColor0.rgb, thickness); 540 | // Call GI (lightmaps/SH/reflections) lighting function 541 | UnityGIInput giInput; 542 | UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput); 543 | giInput.light = gi.light; 544 | giInput.worldPos = worldPos; 545 | giInput.worldViewDir = worldViewDir; 546 | giInput.atten = atten; 547 | #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) 548 | giInput.lightmapUV = IN.lmap; 549 | #else 550 | giInput.lightmapUV = 0.0; 551 | #endif 552 | #if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL 553 | giInput.ambient = IN.sh; 554 | #else 555 | giInput.ambient.rgb = 0.0; 556 | #endif 557 | giInput.probeHDR[0] = unity_SpecCube0_HDR; 558 | giInput.probeHDR[1] = unity_SpecCube1_HDR; 559 | #if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION) 560 | giInput.boxMin[0] = unity_SpecCube0_BoxMin; // .w holds lerp value for blending 561 | #endif 562 | #ifdef UNITY_SPECCUBE_BOX_PROJECTION 563 | giInput.boxMax[0] = unity_SpecCube0_BoxMax; 564 | giInput.probePosition[0] = unity_SpecCube0_ProbePosition; 565 | giInput.boxMax[1] = unity_SpecCube1_BoxMax; 566 | giInput.boxMin[1] = unity_SpecCube1_BoxMin; 567 | giInput.probePosition[1] = unity_SpecCube1_ProbePosition; 568 | #endif 569 | LightingStandardSpecular_GI(o, giInput, gi); 570 | 571 | // realtime lighting: call lighting function 572 | c += LightingStandardSpecular (o, worldViewDir, gi); 573 | c.rgb += o.Emission + transparentColor; 574 | UNITY_APPLY_FOG(IN.fogCoord, c); // apply fog 575 | UNITY_OPAQUE_ALPHA(c.a); 576 | return c; 577 | } 578 | 579 | 580 | #endif 581 | 582 | ENDCG 583 | 584 | } 585 | 586 | // ---- forward rendering additive lights pass: 587 | Pass { 588 | Name "FORWARD" 589 | Tags { "LightMode" = "ForwardAdd" } 590 | ZWrite Off Blend One One 591 | 592 | CGPROGRAM 593 | // compile directives 594 | #pragma vertex tessvert_surf 595 | #pragma fragment frag_surf 596 | #pragma hull hs_surf 597 | #pragma domain ds_surf 598 | #pragma target 5.0 599 | 600 | #pragma multi_compile_fog 601 | #pragma skip_variants INSTANCING_ON 602 | #pragma multi_compile_fwdadd_fullshadows 603 | 604 | // -------- variant for: 605 | #if !defined(INSTANCING_ON) 606 | // Surface shader code generated based on: 607 | // vertex modifier: 'disp' 608 | // writes to per-pixel normal: YES 609 | // writes to emission: YES 610 | // writes to occlusion: YES 611 | // needs world space reflection vector: no 612 | // needs world space normal vector: no 613 | // needs screen space position: no 614 | // needs world space position: no 615 | // needs view direction: no 616 | // needs world space view direction: no 617 | // needs world space position for lighting: YES 618 | // needs world space view direction for lighting: YES 619 | // needs world space view direction for lightmaps: no 620 | // needs vertex color: no 621 | // needs VFACE: no 622 | // passes tangent-to-world matrix to pixel shader: YES 623 | // reads from normal: no 624 | // 1 texcoords actually used 625 | // float2 _MainTex 626 | #define UNITY_PASS_FORWARDADD 627 | 628 | 629 | #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2; 630 | #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))) 631 | #define WorldNormalVector(data,normal) float3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)) 632 | 633 | // Original surface shader snippet: 634 | #line 22 "" 635 | #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING 636 | #endif 637 | 638 | 639 | 640 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 641 | 642 | // tessellation vertex shader 643 | 644 | 645 | // tessellation hull constant shader 646 | 647 | 648 | // tessellation hull shader 649 | 650 | 651 | #endif // UNITY_CAN_COMPILE_TESSELLATION 652 | 653 | 654 | // vertex-to-fragment interpolation data 655 | struct v2f_surf { 656 | UNITY_POSITION(pos); 657 | float2 pack0 : TEXCOORD0; // _MainTex 658 | float3 tSpace0 : TEXCOORD1; 659 | float3 tSpace1 : TEXCOORD2; 660 | float3 tSpace2 : TEXCOORD3; 661 | float3 worldPos : TEXCOORD4; 662 | UNITY_SHADOW_COORDS(5) 663 | UNITY_FOG_COORDS(6) 664 | 665 | #if USE_DETAILALBEDO 666 | float2 pack1 : TEXCOORD7; 667 | #endif 668 | 669 | #if USE_DETAILNORMAL 670 | float2 pack2 : TEXCOORD8; 671 | #endif 672 | float3 worldViewDir : TEXCOORD9; 673 | float3 lightDir : TEXCOORD10; 674 | float4 screenPos : TEXCOORD11; 675 | 676 | }; 677 | float4 _MainTex_ST; 678 | 679 | // vertex shader 680 | inline v2f_surf vert_surf (appdata_full v) { 681 | UNITY_SETUP_INSTANCE_ID(v); 682 | v2f_surf o; 683 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 684 | 685 | o.pos = UnityObjectToClipPos(v.vertex); 686 | o.screenPos = ComputeScreenPos(o.pos); 687 | o.pack0.xy = TRANSFORM_TEX(v.texcoord, _MainTex); 688 | #if USE_DETAILALBEDO 689 | o.pack1 = TRANSFORM_TEX(v.texcoord,_DetailAlbedo); 690 | #endif 691 | #if USE_DETAILNORMAL 692 | o.pack2 = TRANSFORM_TEX(v.texcoord, _DetailBump); 693 | #endif 694 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 695 | o.worldViewDir = (UnityWorldSpaceViewDir(worldPos)); 696 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 697 | float3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz); 698 | float tangentSign = v.tangent.w * unity_WorldTransformParams.w; 699 | float3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign; 700 | o.tSpace0 = (float3(worldTangent.x, worldBinormal.x, worldNormal.x)); 701 | o.tSpace1 = (float3(worldTangent.y, worldBinormal.y, worldNormal.y)); 702 | o.tSpace2 = (float3(worldTangent.z, worldBinormal.z, worldNormal.z)); 703 | 704 | o.worldPos = worldPos; 705 | #ifndef USING_DIRECTIONAL_LIGHT 706 | o.lightDir = (UnityWorldSpaceLightDir(worldPos)); 707 | #else 708 | o.lightDir = _WorldSpaceLightPos0.xyz; 709 | #endif 710 | UNITY_TRANSFER_SHADOW(o,v.texcoord1.xy); // pass shadow coordinates to pixel shader 711 | UNITY_TRANSFER_FOG(o,o.pos); // pass fog coordinates to pixel shader 712 | return o; 713 | } 714 | 715 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 716 | 717 | // tessellation domain shader 718 | [UNITY_domain("tri")] 719 | inline v2f_surf ds_surf (UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) { 720 | appdata_full v; 721 | v.vertex = vi[0].vertex*bary.x + vi[1].vertex*bary.y + vi[2].vertex*bary.z; 722 | #if USE_PHONG 723 | float3 pp[3]; 724 | pp[0] = v.vertex.xyz - vi[0].normal * (dot(v.vertex.xyz, vi[0].normal) - dot(vi[0].vertex.xyz, vi[0].normal)); 725 | pp[1] = v.vertex.xyz - vi[1].normal * (dot(v.vertex.xyz, vi[1].normal) - dot(vi[1].vertex.xyz, vi[1].normal)); 726 | pp[2] = v.vertex.xyz - vi[2].normal * (dot(v.vertex.xyz, vi[2].normal) - dot(vi[2].vertex.xyz, vi[2].normal)); 727 | v.vertex.xyz = _Phong * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-_Phong) * v.vertex.xyz; 728 | #endif 729 | v.tangent = vi[0].tangent*bary.x + vi[1].tangent*bary.y + vi[2].tangent*bary.z; 730 | v.normal = vi[0].normal*bary.x + vi[1].normal*bary.y + vi[2].normal*bary.z; 731 | v.texcoord = vi[0].texcoord*bary.x + vi[1].texcoord*bary.y + vi[2].texcoord*bary.z; 732 | v.texcoord1 = vi[0].texcoord1*bary.x + vi[1].texcoord1*bary.y + vi[2].texcoord1*bary.z; 733 | v.texcoord2 = 0; 734 | v.texcoord3 = 0; 735 | v.color = 0; 736 | #if USE_VERTEX 737 | vert(v); 738 | #endif 739 | v2f_surf o = vert_surf (v); 740 | return o; 741 | } 742 | 743 | #endif // UNITY_CAN_COMPILE_TESSELLATION 744 | 745 | 746 | // fragment shader 747 | inline float4 frag_surf (v2f_surf IN) : SV_Target { 748 | UNITY_SETUP_INSTANCE_ID(IN); 749 | // prepare and unpack data 750 | Input surfIN; 751 | UNITY_INITIALIZE_OUTPUT(Input,surfIN); 752 | surfIN.uv_MainTex.x = 1.0; 753 | 754 | surfIN.uv_MainTex = IN.pack0.xy; 755 | #if USE_DETAILALBEDO 756 | surfIN.uv_DetailAlbedo = IN.pack1; 757 | #endif 758 | 759 | #if USE_DETAILNORMAL 760 | surfIN.uv_DetailNormal = IN.pack2; 761 | #endif 762 | float3 worldPos = (IN.worldPos); 763 | float3 lightDir = normalize(IN.lightDir); 764 | float3 worldViewDir = normalize(IN.worldViewDir); 765 | #ifdef UNITY_COMPILER_HLSL 766 | SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0; 767 | #else 768 | SurfaceOutputStandardSpecular o; 769 | #endif 770 | float3x3 wdMatrix= float3x3( normalize(IN.tSpace0.xyz), normalize(IN.tSpace1.xyz), normalize(IN.tSpace2.xyz)); 771 | // call surface function 772 | surf (surfIN, o); 773 | UNITY_LIGHT_ATTENUATION(atten, IN, worldPos) 774 | float4 c = 0; 775 | 776 | o.Normal = normalize(mul(wdMatrix, o.Normal)); 777 | float fragDepth = length(worldPos - _WorldSpaceCameraPos); 778 | float backDepth = DecodeFloatRGBA(tex2Dproj(_CullFrontDepthTex, IN.screenPos)) * 255; 779 | float thickness = saturate(1 - tanh(max(backDepth - fragDepth, _MinDistance) * _Thickness)); 780 | // Setup lighting environment 781 | UnityGI gi; 782 | UNITY_INITIALIZE_OUTPUT(UnityGI, gi); 783 | gi.light.color = _LightColor0.rgb * atten; 784 | gi.light.dir = lightDir; 785 | float3 transparentColor = SubTransparentColor(lightDir, o.Normal, worldViewDir, _LightColor0.rgb, thickness); 786 | c += LightingStandardSpecular (o, worldViewDir, gi); 787 | c.rgb += transparentColor; 788 | c.a = 0.0; 789 | UNITY_APPLY_FOG(IN.fogCoord, c); // apply fog 790 | UNITY_OPAQUE_ALPHA(c.a); 791 | return c; 792 | } 793 | 794 | 795 | #endif 796 | 797 | 798 | ENDCG 799 | 800 | } 801 | Pass { 802 | Name "ShadowCaster" 803 | Tags { "LightMode" = "ShadowCaster" } 804 | ZWrite On ZTest LEqual 805 | 806 | CGPROGRAM 807 | // compile directives 808 | #pragma vertex tessvert_surf_shadowCaster 809 | #pragma fragment frag_surf 810 | #pragma hull hs_surf 811 | #pragma domain ds_surf 812 | #pragma target 5.0 813 | 814 | #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2 815 | #pragma multi_compile_shadowcaster 816 | 817 | // -------- variant for: 818 | #if !defined(INSTANCING_ON) 819 | #define UNITY_PASS_SHADOWCASTER 820 | 821 | #define INTERNAL_DATA 822 | #define WorldReflectionVector(data,normal) data.worldRefl 823 | #define WorldNormalVector(data,normal) normal 824 | 825 | // Original surface shader snippet: 826 | #line 10 "" 827 | #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING 828 | #endif 829 | 830 | struct v2f_surf { 831 | V2F_SHADOW_CASTER; 832 | 833 | UNITY_VERTEX_INPUT_INSTANCE_ID 834 | UNITY_VERTEX_OUTPUT_STEREO 835 | }; 836 | 837 | // vertex shader 838 | inline v2f_surf vert_surf (appdata_full v) { 839 | v2f_surf o; 840 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 841 | TRANSFER_SHADOW_CASTER_NORMALOFFSET(o) 842 | return o; 843 | } 844 | 845 | inline InternalTessInterp_appdata_full tessvert_surf_shadowCaster (appdata_full v) { 846 | InternalTessInterp_appdata_full o; 847 | o.vertex = v.vertex; 848 | o.normal = v.normal; 849 | o.texcoord = v.texcoord; 850 | return o; 851 | } 852 | 853 | [UNITY_domain("tri")] 854 | inline v2f_surf ds_surf (UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) { 855 | appdata_full v; 856 | v.vertex = vi[0].vertex*bary.x + vi[1].vertex*bary.y + vi[2].vertex*bary.z; 857 | #if USE_PHONG 858 | float3 pp[3]; 859 | pp[0] = v.vertex.xyz - vi[0].normal * (dot(v.vertex.xyz, vi[0].normal) - dot(vi[0].vertex.xyz, vi[0].normal)); 860 | pp[1] = v.vertex.xyz - vi[1].normal * (dot(v.vertex.xyz, vi[1].normal) - dot(vi[1].vertex.xyz, vi[1].normal)); 861 | pp[2] = v.vertex.xyz - vi[2].normal * (dot(v.vertex.xyz, vi[2].normal) - dot(vi[2].vertex.xyz, vi[2].normal)); 862 | v.vertex.xyz = _Phong * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-_Phong) * v.vertex.xyz; 863 | #endif 864 | v.tangent = 0; 865 | v.normal = vi[0].normal*bary.x + vi[1].normal*bary.y + vi[2].normal*bary.z; 866 | v.texcoord = vi[0].texcoord*bary.x + vi[1].texcoord*bary.y + vi[2].texcoord*bary.z; 867 | v.texcoord1 = 0; 868 | v.texcoord2 = 0; 869 | v.texcoord3 = 0; 870 | v.color = 0; 871 | #if USE_VERTEX 872 | vert(v); 873 | #endif 874 | v2f_surf o = vert_surf (v); 875 | return o; 876 | } 877 | 878 | // fragment shader 879 | inline float4 frag_surf (v2f_surf IN) : SV_Target { 880 | return 1; 881 | } 882 | 883 | 884 | #endif 885 | 886 | ENDCG 887 | 888 | } 889 | // ---- meta information extraction pass: 890 | Pass { 891 | Name "Meta" 892 | Tags { "LightMode" = "Meta" } 893 | Cull Off 894 | 895 | CGPROGRAM 896 | // compile directives 897 | #pragma vertex tessvert_surf 898 | #pragma fragment frag_surf 899 | #pragma hull hs_surf 900 | #pragma domain ds_surf 901 | #pragma target 5.0 902 | 903 | #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2 904 | #pragma skip_variants INSTANCING_ON 905 | #pragma shader_feature EDITOR_VISUALIZATION 906 | 907 | 908 | // -------- variant for: 909 | #if !defined(INSTANCING_ON) 910 | // Surface shader code generated based on: 911 | // vertex modifier: 'disp' 912 | // writes to per-pixel normal: YES 913 | // writes to emission: YES 914 | // writes to occlusion: YES 915 | // needs world space reflection vector: no 916 | // needs world space normal vector: no 917 | // needs screen space position: no 918 | // needs world space position: no 919 | // needs view direction: no 920 | // needs world space view direction: no 921 | // needs world space position for lighting: YES 922 | // needs world space view direction for lighting: YES 923 | // needs world space view direction for lightmaps: no 924 | // needs vertex color: no 925 | // needs VFACE: no 926 | // passes tangent-to-world matrix to pixel shader: YES 927 | // reads from normal: no 928 | // 1 texcoords actually used 929 | // float2 _MainTex 930 | #define UNITY_PASS_META 931 | 932 | #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2; 933 | #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))) 934 | #define WorldNormalVector(data,normal) float3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)) 935 | 936 | // Original surface shader snippet: 937 | #line 22 "" 938 | #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING 939 | #endif 940 | 941 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 942 | 943 | // tessellation vertex shader 944 | 945 | 946 | // tessellation hull constant shader 947 | 948 | // tessellation hull shader 949 | 950 | 951 | #endif // UNITY_CAN_COMPILE_TESSELLATION 952 | 953 | 954 | 955 | // vertex-to-fragment interpolation data 956 | struct v2f_surf { 957 | UNITY_POSITION(pos); 958 | float2 pack0 : TEXCOORD0; // _MainTex 959 | float4 tSpace0 : TEXCOORD1; 960 | float4 tSpace1 : TEXCOORD2; 961 | float4 tSpace2 : TEXCOORD3; 962 | UNITY_VERTEX_INPUT_INSTANCE_ID 963 | UNITY_VERTEX_OUTPUT_STEREO 964 | }; 965 | float4 _MainTex_ST; 966 | 967 | // vertex shader 968 | inline v2f_surf vert_surf (appdata_full v) { 969 | UNITY_SETUP_INSTANCE_ID(v); 970 | v2f_surf o; 971 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 972 | 973 | o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST); 974 | o.pack0.xy = TRANSFORM_TEX(v.texcoord, _MainTex); 975 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 976 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 977 | float3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz); 978 | float tangentSign = v.tangent.w * unity_WorldTransformParams.w; 979 | float3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign; 980 | 981 | return o; 982 | } 983 | 984 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 985 | 986 | // tessellation domain shader 987 | [UNITY_domain("tri")] 988 | inline v2f_surf ds_surf (UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) { 989 | appdata_full v; 990 | v.vertex = vi[0].vertex*bary.x + vi[1].vertex*bary.y + vi[2].vertex*bary.z; 991 | #if USE_PHONG 992 | float3 pp[3]; 993 | pp[0] = v.vertex.xyz - vi[0].normal * (dot(v.vertex.xyz, vi[0].normal) - dot(vi[0].vertex.xyz, vi[0].normal)); 994 | pp[1] = v.vertex.xyz - vi[1].normal * (dot(v.vertex.xyz, vi[1].normal) - dot(vi[1].vertex.xyz, vi[1].normal)); 995 | pp[2] = v.vertex.xyz - vi[2].normal * (dot(v.vertex.xyz, vi[2].normal) - dot(vi[2].vertex.xyz, vi[2].normal)); 996 | v.vertex.xyz = _Phong * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-_Phong) * v.vertex.xyz; 997 | #endif 998 | v.tangent = vi[0].tangent*bary.x + vi[1].tangent*bary.y + vi[2].tangent*bary.z; 999 | v.normal = vi[0].normal*bary.x + vi[1].normal*bary.y + vi[2].normal*bary.z; 1000 | v.texcoord = vi[0].texcoord*bary.x + vi[1].texcoord*bary.y + vi[2].texcoord*bary.z; 1001 | v.texcoord1 = vi[0].texcoord1*bary.x + vi[1].texcoord1*bary.y + vi[2].texcoord1*bary.z; 1002 | v.texcoord2 = vi[0].texcoord2*bary.x + vi[1].texcoord2*bary.y + vi[2].texcoord2*bary.z; 1003 | v.texcoord3 = 0; 1004 | v.color = 0; 1005 | #if USE_VERTEX 1006 | vert(v); 1007 | #endif 1008 | v2f_surf o = vert_surf (v); 1009 | return o; 1010 | } 1011 | 1012 | #endif // UNITY_CAN_COMPILE_TESSELLATION 1013 | 1014 | 1015 | // fragment shader 1016 | inline float4 frag_surf (v2f_surf IN) : SV_Target { 1017 | UNITY_SETUP_INSTANCE_ID(IN); 1018 | // prepare and unpack data 1019 | Input surfIN; 1020 | UNITY_INITIALIZE_OUTPUT(Input,surfIN); 1021 | surfIN.uv_MainTex.x = 1.0; 1022 | 1023 | surfIN.uv_MainTex = IN.pack0.xy; 1024 | float3 worldPos = float3(IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w); 1025 | #ifdef UNITY_COMPILER_HLSL 1026 | SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0; 1027 | #else 1028 | SurfaceOutputStandardSpecular o; 1029 | #endif 1030 | 1031 | 1032 | 1033 | // call surface function 1034 | surf (surfIN, o); 1035 | UnityMetaInput metaIN; 1036 | UNITY_INITIALIZE_OUTPUT(UnityMetaInput, metaIN); 1037 | metaIN.Albedo = o.Albedo; 1038 | metaIN.Emission = o.Emission; 1039 | metaIN.SpecularColor = o.Specular; 1040 | return UnityMetaFragment(metaIN); 1041 | } 1042 | 1043 | 1044 | #endif 1045 | 1046 | 1047 | ENDCG 1048 | 1049 | } 1050 | 1051 | // ---- end of surface shader generated code 1052 | 1053 | #LINE 90 1054 | 1055 | } 1056 | CustomEditor "SpecularShaderEditor" 1057 | } 1058 | 1059 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/Tess-SSS.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bee32d95281289f47b2966ce3f7c0224 3 | timeCreated: 1521584193 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: [] 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/Tess-Skin.shader: -------------------------------------------------------------------------------- 1 | Shader "Tessellation/Skin" { 2 | Properties { 3 | _MinDist("Tess Min Distance", float) = 10 4 | _MaxDist("Tess Max Distance", float) = 25 5 | _Tessellation("Tessellation", Range(1,63)) = 1 6 | _Phong ("Phong Strengh", Range(0,1)) = 0.5 7 | _Color ("Color", Color) = (1,1,1,1) 8 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 9 | _BumpMap("Normal Map", 2D) = "bump" {} 10 | _NormalScale("Normal Scale", float) = 1 11 | _SpecularMap("Specular Map", 2D) = "white"{} 12 | _HeightMap("Vertex Map", 2D) = "black"{} 13 | //_HeightScale("Height Scale", Range(-4,4)) = 1 14 | _Glossiness ("Smoothness", Range(0,1)) = 0.5 15 | _OcclusionMap("Occlusion Map", 2D) = "white"{} 16 | _Occlusion("Occlusion Scale", Range(0,1)) = 1 17 | _SpecularColor("Specular Color",Color) = (0.2,0.2,0.2,1) 18 | _EmissionColor("Emission Color", Color) = (0,0,0,1) 19 | _VertexScale("Vertex Scale", Range(-3,3)) = 0.1 20 | _VertexOffset("Vertex Offset", float) = 0 21 | _DetailAlbedo("Detail Albedo(RGB) Mask(A)", 2D) = "black"{} 22 | _AlbedoBlend("Albedo Blend Rate", Range(0,1)) = 0.3 23 | _DetailBump("Detail Bump(RGB) Mask(A)", 2D) = "bump"{} 24 | _BumpBlend("Bump Blend Rate", Range(0,1)) = 0.3 25 | _RampTex("Ramp light texture", 2D) = "white"{} 26 | _BloodValue("Blood Value", Range(0.01, 1)) = 0.5 27 | _Power("Power of SSS", Range(0.1,10)) = 1 28 | _SSColor("SSS Color", Color) = (1,1,1,1) 29 | _Thickness("Thickness", float) = 1 30 | _MinDistance("Min SSS transparent Distance", Range(0,2)) = 0.001 31 | } 32 | SubShader { 33 | Tags { "RenderType"="Opaque" } 34 | LOD 200 35 | 36 | 37 | // ------------------------------------------------------------ 38 | // Surface shader code generated out of a CGPROGRAM block: 39 | CGINCLUDE 40 | 41 | #include "HLSLSupport.cginc" 42 | #include "UnityShaderVariables.cginc" 43 | #include "UnityShaderUtilities.cginc" 44 | #include "UnityCG.cginc" 45 | #include "Lighting.cginc" 46 | #include "UnityPBSLighting.cginc" 47 | #include "UnityMetaPass.cginc" 48 | #include "AutoLight.cginc" 49 | #pragma shader_feature USE_FILTER 50 | #pragma shader_feature USE_NORMAL 51 | #pragma shader_feature USE_SPECULAR 52 | #pragma shader_feature USE_VERTEX 53 | #pragma shader_feature USE_PHONG 54 | #pragma shader_feature USE_OCCLUSION 55 | #pragma shader_feature USE_ALBEDO 56 | #pragma shader_feature USE_DETAILALBEDO 57 | #pragma shader_feature USE_DETAILNORMAL 58 | 59 | #ifdef POINT 60 | #define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \ 61 | unityShadowCoord3 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(worldPos, 1)).xyz; \ 62 | float shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \ 63 | float destName = tex2D(_LightTexture0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL * shadow; 64 | 65 | //inline void unity_attenuation(inout float atten, inout float attenNoShadow, v2f_surf input, float3 worldPos){ 66 | 67 | #endif 68 | 69 | #ifdef SPOT 70 | #define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \ 71 | unityShadowCoord4 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(worldPos, 1)); \ 72 | float shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \ 73 | float destName = step(0,lightCoord.z) * UnitySpotCookie(lightCoord) * UnitySpotAttenuate(lightCoord.xyz) * shadow; 74 | #endif 75 | 76 | #ifdef DIRECTIONAL 77 | #define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) float destName = UNITY_SHADOW_ATTENUATION(input, worldPos); 78 | #endif 79 | 80 | #ifdef POINT_COOKIE 81 | 82 | #define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \ 83 | unityShadowCoord3 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(worldPos, 1)).xyz; \ 84 | float shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \ 85 | float destName = tex2D(_LightTextureB0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL * texCUBE(_LightTexture0, lightCoord).w * shadow; 86 | #endif 87 | 88 | #ifdef DIRECTIONAL_COOKIE 89 | 90 | #define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \ 91 | unityShadowCoord2 lightCoord = mul(unity_WorldToLight, unityShadowCoord4(worldPos, 1)).xy; \ 92 | float shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \ 93 | float destName = tex2D(_LightTexture0, lightCoord).w * shadow; 94 | #endif 95 | 96 | 97 | 98 | 99 | struct Input { 100 | float2 uv_MainTex; 101 | #if USE_DETAILALBEDO 102 | float2 uv_DetailAlbedo; 103 | #endif 104 | #if USE_DETAILNORMAL 105 | float2 uv_DetailNormal; 106 | #endif 107 | }; 108 | 109 | float4 _SpecularColor; 110 | float4 _EmissionColor; 111 | float _MinDist; 112 | float _MaxDist; 113 | float _Tessellation; 114 | float _HeightScale; 115 | float _Phong; 116 | float _NormalScale; 117 | float _Occlusion; 118 | float _VertexScale; 119 | float _VertexOffset; 120 | float _BloodValue; 121 | float _Power; 122 | float _Thickness; 123 | float4 _SSColor; 124 | float _MinDistance; 125 | sampler2D _DetailAlbedo; 126 | float _AlbedoBlend; 127 | sampler2D _DetailBump; 128 | float _BumpBlend; 129 | float4 _DetailAlbedo_ST; 130 | float4 _DetailBump_ST; 131 | float4 _FrustArray[4]; 132 | 133 | sampler2D _BumpMap; 134 | sampler2D _SpecularMap; 135 | sampler2D _HeightMap; 136 | sampler2D _OcclusionMap; 137 | sampler2D _RampTex; 138 | sampler2D _MainTex; 139 | uniform sampler2D _CullFrontDepthTex; 140 | half _Glossiness; 141 | float4 _Color; 142 | 143 | inline void surf (Input IN, inout SurfaceOutputStandardSpecular o) { 144 | // Albedo comes from a texture tinted by color 145 | float2 uv = IN.uv_MainTex;// - parallax_mapping(IN.uv_MainTex,IN.viewDir); 146 | #if USE_ALBEDO 147 | float4 c = tex2D (_MainTex, uv) * _Color; 148 | 149 | #if USE_DETAILALBEDO 150 | float4 dA = tex2D(_DetailAlbedo, IN.uv_DetailAlbedo); 151 | c.rgb = lerp(c.rgb, dA.rgb, _AlbedoBlend); 152 | #endif 153 | o.Albedo = c.rgb; 154 | o.Alpha = c.a; 155 | #else 156 | #if USE_DETAILALBEDO 157 | float4 dA = tex2D(_DetailAlbedo, IN.uv_DetailAlbedo); 158 | o.Albedo.rgb = lerp(1, dA.rgb, _AlbedoBlend) * _Color; 159 | #else 160 | o.Albedo = _Color.rgb; 161 | o.Alpha = _Color.a; 162 | #endif 163 | #endif 164 | 165 | #if USE_OCCLUSION 166 | o.Occlusion = lerp(1, tex2D(_OcclusionMap, IN.uv_MainTex).r, _Occlusion); 167 | #else 168 | o.Occlusion = 1; 169 | #endif 170 | 171 | #if USE_SPECULAR 172 | float4 spec = tex2D(_SpecularMap, IN.uv_MainTex); 173 | o.Specular = _SpecularColor * spec.rgb; 174 | o.Smoothness = _Glossiness * spec.a; 175 | #else 176 | o.Specular = _SpecularColor; 177 | o.Smoothness = _Glossiness; 178 | #endif 179 | 180 | 181 | #if USE_NORMAL 182 | o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_MainTex)); 183 | #if USE_DETAILNORMAL 184 | float4 dN = tex2D(_DetailBump,IN.uv_DetailNormal); 185 | o.Normal = lerp(o.Normal, UnpackNormal(dN), _BumpBlend); 186 | #endif 187 | o.Normal.xy *= _NormalScale; 188 | 189 | #else 190 | o.Normal = float3(0,0,1); 191 | #endif 192 | #if UNITY_PASS_FORWARDBASE 193 | o.Emission = _EmissionColor; 194 | #endif 195 | } 196 | struct InternalTessInterp_appdata_full { 197 | float4 vertex : INTERNALTESSPOS; 198 | float4 tangent : TANGENT; 199 | float3 normal : NORMAL; 200 | float4 texcoord : TEXCOORD0; 201 | float4 texcoord1 : TEXCOORD1; 202 | float4 texcoord2 : TEXCOORD2; 203 | float4 color : COLOR; 204 | }; 205 | inline InternalTessInterp_appdata_full tessvert_surf (appdata_full v) { 206 | InternalTessInterp_appdata_full o; 207 | o.vertex = v.vertex; 208 | o.tangent = v.tangent; 209 | o.normal = v.normal; 210 | o.texcoord = v.texcoord; 211 | o.texcoord1 = v.texcoord1; 212 | o.texcoord2 = v.texcoord2; 213 | o.color = v.color; 214 | return o; 215 | } 216 | 217 | inline float3 SubTransparentColor(float3 lightDir, float3 viewDir, float3 lightColor, float3 pointDepth){ 218 | float VdotH = pow(saturate(dot(viewDir, -lightDir) + 0.5), _Power); 219 | return lightColor * VdotH * _SSColor.rgb * pointDepth; 220 | } 221 | 222 | inline void vert(inout appdata_full v){ 223 | v.vertex.xyz += v.normal *( (tex2Dlod(_HeightMap, v.texcoord).r - 0.5) * _VertexScale + _VertexOffset); 224 | } 225 | 226 | inline float3 UnityCalcTriEdgeTessFactors (float3 triVertexFactors) 227 | { 228 | float3 tess; 229 | tess.x = 0.5 * (triVertexFactors.y + triVertexFactors.z); 230 | tess.y = 0.5 * (triVertexFactors.x + triVertexFactors.z); 231 | tess.z = 0.5 * (triVertexFactors.x + triVertexFactors.y); 232 | return tess; 233 | } 234 | 235 | 236 | inline float UnityCalcDistanceTessFactor (float4 vertex, float minDist, float maxDist, float tess) 237 | { 238 | float3 wpos = mul(unity_ObjectToWorld,vertex).xyz; 239 | float dist = distance (wpos, _WorldSpaceCameraPos); 240 | float f = clamp(1.0 - (dist - minDist) / (maxDist - minDist), 0.01, 1.0) * tess; 241 | return f; 242 | } 243 | 244 | inline float3 tessDist (float4 v0, float4 v1, float4 v2) 245 | { 246 | float3 f; 247 | f.x = UnityCalcDistanceTessFactor (v0,_MinDist,_MaxDist,_Tessellation); 248 | f.y = UnityCalcDistanceTessFactor (v1,_MinDist,_MaxDist,_Tessellation); 249 | f.z = UnityCalcDistanceTessFactor (v2,_MinDist,_MaxDist,_Tessellation); 250 | return UnityCalcTriEdgeTessFactors (f); 251 | } 252 | 253 | inline float3 BloodColor(float3 normal, float3 lightDir){ 254 | float NdotL = dot(normal, lightDir) * 0.5 + 0.5; 255 | return tex2D(_RampTex, float2(NdotL - 0.0, _BloodValue)); 256 | } 257 | //TODO 258 | //Calculate thickness 259 | 260 | inline UnityTessellationFactors hsconst_surf (InputPatch v) { 261 | UnityTessellationFactors o; 262 | #if USE_FILTER 263 | float3 tf = (tessDist(v[0].vertex, v[1].vertex, v[2].vertex) - 1); 264 | o.edge[0] = tf.x * v[0].color.a + 1; 265 | o.edge[1] = tf.y * v[1].color.a + 1; 266 | o.edge[2] = tf.z * v[2].color.a + 1; 267 | o.inside = (o.edge[0] + o.edge[1] + o.edge[2]) * 0.33333333; 268 | #else 269 | float3 tf = (tessDist(v[0].vertex, v[1].vertex, v[2].vertex)); 270 | o.edge[0] = tf.x; 271 | o.edge[1] = tf.y; 272 | o.edge[2] = tf.z; 273 | o.inside = (tf.x + tf.y + tf.z) * 0.33333333; 274 | #endif 275 | return o; 276 | } 277 | 278 | [UNITY_domain("tri")] 279 | [UNITY_partitioning("fractional_odd")] 280 | [UNITY_outputtopology("triangle_cw")] 281 | [UNITY_patchconstantfunc("hsconst_surf")] 282 | [UNITY_outputcontrolpoints(3)] 283 | inline InternalTessInterp_appdata_full hs_surf (InputPatch v, uint id : SV_OutputControlPointID) { 284 | return v[id]; 285 | } 286 | ENDCG 287 | // ---- forward rendering base pass: 288 | Pass { 289 | Name "FORWARD" 290 | Tags { "LightMode" = "ForwardBase" } 291 | 292 | CGPROGRAM 293 | // compile directives 294 | #pragma vertex tessvert_surf 295 | #pragma fragment frag_surf 296 | #pragma hull hs_surf 297 | #pragma domain ds_surf 298 | #pragma target 5.0 299 | 300 | #pragma multi_compile_fog 301 | #pragma multi_compile_fwdbase 302 | 303 | // -------- variant for: 304 | #if !defined(INSTANCING_ON) 305 | // Surface shader code generated based on: 306 | // vertex modifier: 'disp' 307 | // writes to per-pixel normal: YES 308 | // writes to emission: YES 309 | // writes to occlusion: YES 310 | // needs world space reflection vector: no 311 | // needs world space normal vector: no 312 | // needs screen space position: no 313 | // needs world space position: no 314 | // needs view direction: no 315 | // needs world space view direction: no 316 | // needs world space position for lighting: YES 317 | // needs world space view direction for lighting: YES 318 | // needs world space view direction for lightmaps: no 319 | // needs vertex color: no 320 | // needs VFACE: no 321 | // passes tangent-to-world matrix to pixel shader: YES 322 | // reads from normal: no 323 | // 1 texcoords actually used 324 | // float2 _MainTex 325 | #define UNITY_PASS_FORWARDBASE 326 | 327 | 328 | #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2; 329 | #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))) 330 | #define WorldNormalVector(data,normal) float3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)) 331 | 332 | // Original surface shader snippet: 333 | #line 22 "" 334 | #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING 335 | #endif 336 | 337 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 338 | 339 | // tessellation vertex shader 340 | 341 | 342 | // tessellation hull constant shader 343 | 344 | 345 | // tessellation hull shader 346 | 347 | 348 | #endif // UNITY_CAN_COMPILE_TESSELLATION 349 | 350 | 351 | // vertex-to-fragment interpolation data 352 | // no lightmaps: 353 | #ifndef LIGHTMAP_ON 354 | struct v2f_surf { 355 | UNITY_POSITION(pos); 356 | float2 pack0 : TEXCOORD0; // _MainTex 357 | float4 tSpace0 : TEXCOORD1; 358 | float4 tSpace1 : TEXCOORD2; 359 | float4 tSpace2 : TEXCOORD3; 360 | 361 | #if UNITY_SHOULD_SAMPLE_SH 362 | half3 sh : TEXCOORD4; // SH 363 | #endif 364 | UNITY_SHADOW_COORDS(5) 365 | UNITY_FOG_COORDS(6) 366 | #if SHADER_TARGET >= 30 367 | float4 lmap : TEXCOORD7; 368 | #endif 369 | 370 | #if USE_DETAILALBEDO 371 | float2 pack1 : TEXCOORD8; 372 | #endif 373 | 374 | #if USE_DETAILNORMAL 375 | float2 pack2 : TEXCOORD9; 376 | #endif 377 | float3 worldViewDir : TEXCOORD10; 378 | float3 lightDir : TEXCOORD11; 379 | float4 screenPos : TEXCOORD12; 380 | }; 381 | #endif 382 | // with lightmaps: 383 | #ifdef LIGHTMAP_ON 384 | struct v2f_surf { 385 | UNITY_POSITION(pos); 386 | float2 pack0 : TEXCOORD0; // _MainTex 387 | float4 tSpace0 : TEXCOORD1; 388 | float4 tSpace1 : TEXCOORD2; 389 | float4 tSpace2 : TEXCOORD3; 390 | 391 | float4 lmap : TEXCOORD4; 392 | UNITY_SHADOW_COORDS(5) 393 | UNITY_FOG_COORDS(6) 394 | 395 | 396 | #if USE_DETAILALBEDO 397 | float2 pack1 : TEXCOORD7; 398 | #endif 399 | 400 | #if USE_DETAILNORMAL 401 | float2 pack2 : TEXCOORD8; 402 | #endif 403 | float3 worldViewDir : TEXCOORD9; 404 | float3 lightDir : TEXCOORD10; 405 | float4 screenPos : TEXCOORD11; 406 | }; 407 | #endif 408 | float4 _MainTex_ST; 409 | 410 | // vertex shader 411 | inline v2f_surf vert_surf (appdata_full v) { 412 | UNITY_SETUP_INSTANCE_ID(v); 413 | v2f_surf o; 414 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 415 | 416 | 417 | o.pos = UnityObjectToClipPos(v.vertex); 418 | o.screenPos = ComputeScreenPos(o.pos); 419 | o.pack0.xy = TRANSFORM_TEX(v.texcoord, _MainTex); 420 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 421 | o.worldViewDir = (UnityWorldSpaceViewDir(worldPos)); 422 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 423 | float3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz); 424 | float tangentSign = v.tangent.w * unity_WorldTransformParams.w; 425 | float3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign; 426 | #if USE_DETAILALBEDO 427 | o.pack1 = TRANSFORM_TEX(v.texcoord,_DetailAlbedo); 428 | #endif 429 | #if USE_DETAILNORMAL 430 | o.pack2 = TRANSFORM_TEX(v.texcoord, _DetailBump); 431 | #endif 432 | o.tSpace0 = (float4(worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x)); 433 | o.tSpace1 = (float4(worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y)); 434 | o.tSpace2 = (float4(worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z)); 435 | 436 | #ifdef DYNAMICLIGHTMAP_ON 437 | o.lmap.zw = v.texcoord2.xy * unity_DynamicLightmapST.xy + unity_DynamicLightmapST.zw; 438 | #endif 439 | #ifdef LIGHTMAP_ON 440 | o.lmap.xy = v.texcoord1.xy * unity_LightmapST.xy + unity_LightmapST.zw; 441 | #endif 442 | 443 | // SH/ambient and vertex lights 444 | #ifndef LIGHTMAP_ON 445 | #if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL 446 | o.sh = 0; 447 | // Approximated illumination from non-important point lights 448 | #ifdef VERTEXLIGHT_ON 449 | o.sh += Shade4PointLights ( 450 | unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, 451 | unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb, 452 | unity_4LightAtten0, worldPos, worldNormal); 453 | #endif 454 | o.sh = ShadeSHPerVertex (worldNormal, o.sh); 455 | #endif 456 | #endif // !LIGHTMAP_ON 457 | 458 | UNITY_TRANSFER_SHADOW(o,v.texcoord1.xy); // pass shadow coordinates to pixel shader 459 | UNITY_TRANSFER_FOG(o,o.pos); // pass fog coordinates to pixel shader 460 | #ifndef USING_DIRECTIONAL_LIGHT 461 | o.lightDir = (UnityWorldSpaceLightDir(worldPos)); 462 | #else 463 | o.lightDir = _WorldSpaceLightPos0.xyz; 464 | #endif 465 | return o; 466 | } 467 | 468 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 469 | 470 | // tessellation domain shader 471 | [UNITY_domain("tri")] 472 | inline v2f_surf ds_surf (UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) { 473 | appdata_full v; 474 | v.vertex = vi[0].vertex*bary.x + vi[1].vertex*bary.y + vi[2].vertex*bary.z; 475 | 476 | #if USE_PHONG 477 | float3 pp[3]; 478 | pp[0] = v.vertex.xyz - vi[0].normal * (dot(v.vertex.xyz, vi[0].normal) - dot(vi[0].vertex.xyz, vi[0].normal)); 479 | pp[1] = v.vertex.xyz - vi[1].normal * (dot(v.vertex.xyz, vi[1].normal) - dot(vi[1].vertex.xyz, vi[1].normal)); 480 | pp[2] = v.vertex.xyz - vi[2].normal * (dot(v.vertex.xyz, vi[2].normal) - dot(vi[2].vertex.xyz, vi[2].normal)); 481 | v.vertex.xyz = _Phong * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-_Phong) * v.vertex.xyz; 482 | #endif 483 | 484 | v.tangent = vi[0].tangent*bary.x + vi[1].tangent*bary.y + vi[2].tangent*bary.z; 485 | v.normal = vi[0].normal*bary.x + vi[1].normal*bary.y + vi[2].normal*bary.z; 486 | v.texcoord = vi[0].texcoord*bary.x + vi[1].texcoord*bary.y + vi[2].texcoord*bary.z; 487 | v.texcoord1 = vi[0].texcoord1*bary.x + vi[1].texcoord1*bary.y + vi[2].texcoord1*bary.z; 488 | v.texcoord2 = vi[0].texcoord2*bary.x + vi[1].texcoord2*bary.y + vi[2].texcoord2*bary.z; 489 | v.texcoord3 = 0; 490 | v.color = 0; 491 | #if USE_VERTEX 492 | vert(v); 493 | #endif 494 | v2f_surf o = vert_surf (v); 495 | return o; 496 | } 497 | 498 | #endif // UNITY_CAN_COMPILE_TESSELLATION 499 | 500 | 501 | // fragment shader 502 | inline float4 frag_surf (v2f_surf IN) : SV_Target { 503 | UNITY_SETUP_INSTANCE_ID(IN); 504 | // prepare and unpack data 505 | Input surfIN; 506 | UNITY_INITIALIZE_OUTPUT(Input,surfIN); 507 | surfIN.uv_MainTex.x = 1.0; 508 | 509 | surfIN.uv_MainTex = IN.pack0.xy; 510 | #if USE_DETAILALBEDO 511 | surfIN.uv_DetailAlbedo = IN.pack1; 512 | #endif 513 | 514 | #if USE_DETAILNORMAL 515 | surfIN.uv_DetailNormal = IN.pack2; 516 | #endif 517 | float3 worldPos = float3(IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w); 518 | float3 lightDir = normalize(IN.lightDir); 519 | float3 worldViewDir = normalize(IN.worldViewDir); 520 | #ifdef UNITY_COMPILER_HLSL 521 | SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0; 522 | #else 523 | SurfaceOutputStandardSpecular o; 524 | #endif 525 | float3x3 wdMatrix= float3x3( normalize(IN.tSpace0.xyz), normalize(IN.tSpace1.xyz), normalize(IN.tSpace2.xyz)); 526 | // call surface function 527 | surf (surfIN, o); 528 | 529 | // compute lighting & shadowing factor 530 | UNITY_LIGHT_ATTENUATION(atten, IN, worldPos) 531 | float4 c = 0; 532 | 533 | o.Normal = normalize(mul(wdMatrix, o.Normal)); 534 | float fragDepth = length(worldPos - _WorldSpaceCameraPos); 535 | float backDepth = DecodeFloatRGBA(tex2Dproj(_CullFrontDepthTex, IN.screenPos)) * 255; 536 | float thickness = saturate(1 - max(backDepth - fragDepth, _MinDistance) * _Thickness); 537 | 538 | // Setup lighting environment 539 | UnityGI gi; 540 | UNITY_INITIALIZE_OUTPUT(UnityGI, gi); 541 | gi.light.color = _LightColor0.rgb * atten; 542 | float3 bloodColor = BloodColor(o.Normal, lightDir) * o.Albedo * gi.light.color; 543 | o.Albedo *= 0; 544 | gi.light.dir = lightDir; 545 | float3 transparentColor = SubTransparentColor(lightDir, worldViewDir, _LightColor0.rgb, thickness); 546 | // Call GI (lightmaps/SH/reflections) lighting function 547 | UnityGIInput giInput; 548 | UNITY_INITIALIZE_OUTPUT(UnityGIInput, giInput); 549 | giInput.light = gi.light; 550 | giInput.worldPos = worldPos; 551 | giInput.worldViewDir = worldViewDir; 552 | giInput.atten = atten; 553 | #if defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON) 554 | giInput.lightmapUV = IN.lmap; 555 | #else 556 | giInput.lightmapUV = 0.0; 557 | #endif 558 | #if UNITY_SHOULD_SAMPLE_SH && !UNITY_SAMPLE_FULL_SH_PER_PIXEL 559 | giInput.ambient = IN.sh; 560 | #else 561 | giInput.ambient.rgb = 0.0; 562 | #endif 563 | giInput.probeHDR[0] = unity_SpecCube0_HDR; 564 | giInput.probeHDR[1] = unity_SpecCube1_HDR; 565 | #if defined(UNITY_SPECCUBE_BLENDING) || defined(UNITY_SPECCUBE_BOX_PROJECTION) 566 | giInput.boxMin[0] = unity_SpecCube0_BoxMin; // .w holds lerp value for blending 567 | #endif 568 | #ifdef UNITY_SPECCUBE_BOX_PROJECTION 569 | giInput.boxMax[0] = unity_SpecCube0_BoxMax; 570 | giInput.probePosition[0] = unity_SpecCube0_ProbePosition; 571 | giInput.boxMax[1] = unity_SpecCube1_BoxMax; 572 | giInput.boxMin[1] = unity_SpecCube1_BoxMin; 573 | giInput.probePosition[1] = unity_SpecCube1_ProbePosition; 574 | #endif 575 | LightingStandardSpecular_GI(o, giInput, gi); 576 | 577 | // realtime lighting: call lighting function 578 | c += LightingStandardSpecular (o, worldViewDir, gi); 579 | c.rgb += o.Emission + bloodColor + transparentColor; 580 | UNITY_APPLY_FOG(IN.fogCoord, c); // apply fog 581 | UNITY_OPAQUE_ALPHA(c.a); 582 | return c; 583 | } 584 | 585 | 586 | #endif 587 | 588 | ENDCG 589 | 590 | } 591 | 592 | // ---- forward rendering additive lights pass: 593 | Pass { 594 | Name "FORWARD" 595 | Tags { "LightMode" = "ForwardAdd" } 596 | ZWrite Off Blend One One 597 | 598 | CGPROGRAM 599 | // compile directives 600 | #pragma vertex tessvert_surf 601 | #pragma fragment frag_surf 602 | #pragma hull hs_surf 603 | #pragma domain ds_surf 604 | #pragma target 5.0 605 | 606 | #pragma multi_compile_fog 607 | #pragma skip_variants INSTANCING_ON 608 | #pragma multi_compile_fwdadd_fullshadows 609 | 610 | // -------- variant for: 611 | #if !defined(INSTANCING_ON) 612 | // Surface shader code generated based on: 613 | // vertex modifier: 'disp' 614 | // writes to per-pixel normal: YES 615 | // writes to emission: YES 616 | // writes to occlusion: YES 617 | // needs world space reflection vector: no 618 | // needs world space normal vector: no 619 | // needs screen space position: no 620 | // needs world space position: no 621 | // needs view direction: no 622 | // needs world space view direction: no 623 | // needs world space position for lighting: YES 624 | // needs world space view direction for lighting: YES 625 | // needs world space view direction for lightmaps: no 626 | // needs vertex color: no 627 | // needs VFACE: no 628 | // passes tangent-to-world matrix to pixel shader: YES 629 | // reads from normal: no 630 | // 1 texcoords actually used 631 | // float2 _MainTex 632 | #define UNITY_PASS_FORWARDADD 633 | 634 | 635 | #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2; 636 | #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))) 637 | #define WorldNormalVector(data,normal) float3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)) 638 | 639 | // Original surface shader snippet: 640 | #line 22 "" 641 | #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING 642 | #endif 643 | 644 | 645 | 646 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 647 | 648 | // tessellation vertex shader 649 | 650 | 651 | // tessellation hull constant shader 652 | 653 | 654 | // tessellation hull shader 655 | 656 | 657 | #endif // UNITY_CAN_COMPILE_TESSELLATION 658 | 659 | 660 | // vertex-to-fragment interpolation data 661 | struct v2f_surf { 662 | UNITY_POSITION(pos); 663 | float2 pack0 : TEXCOORD0; // _MainTex 664 | float3 tSpace0 : TEXCOORD1; 665 | float3 tSpace1 : TEXCOORD2; 666 | float3 tSpace2 : TEXCOORD3; 667 | float3 worldPos : TEXCOORD4; 668 | UNITY_SHADOW_COORDS(5) 669 | UNITY_FOG_COORDS(6) 670 | 671 | #if USE_DETAILALBEDO 672 | float2 pack1 : TEXCOORD7; 673 | #endif 674 | 675 | #if USE_DETAILNORMAL 676 | float2 pack2 : TEXCOORD8; 677 | #endif 678 | float3 worldViewDir : TEXCOORD9; 679 | float3 lightDir : TEXCOORD10; 680 | float4 screenPos : TEXCOORD11; 681 | 682 | }; 683 | float4 _MainTex_ST; 684 | 685 | // vertex shader 686 | inline v2f_surf vert_surf (appdata_full v) { 687 | UNITY_SETUP_INSTANCE_ID(v); 688 | v2f_surf o; 689 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 690 | 691 | o.pos = UnityObjectToClipPos(v.vertex); 692 | o.screenPos = ComputeScreenPos(o.pos); 693 | o.pack0.xy = TRANSFORM_TEX(v.texcoord, _MainTex); 694 | #if USE_DETAILALBEDO 695 | o.pack1 = TRANSFORM_TEX(v.texcoord,_DetailAlbedo); 696 | #endif 697 | #if USE_DETAILNORMAL 698 | o.pack2 = TRANSFORM_TEX(v.texcoord, _DetailBump); 699 | #endif 700 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 701 | o.worldViewDir = (UnityWorldSpaceViewDir(worldPos)); 702 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 703 | float3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz); 704 | float tangentSign = v.tangent.w * unity_WorldTransformParams.w; 705 | float3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign; 706 | o.tSpace0 = (float3(worldTangent.x, worldBinormal.x, worldNormal.x)); 707 | o.tSpace1 = (float3(worldTangent.y, worldBinormal.y, worldNormal.y)); 708 | o.tSpace2 = (float3(worldTangent.z, worldBinormal.z, worldNormal.z)); 709 | 710 | o.worldPos = worldPos; 711 | #ifndef USING_DIRECTIONAL_LIGHT 712 | o.lightDir = (UnityWorldSpaceLightDir(worldPos)); 713 | #else 714 | o.lightDir = _WorldSpaceLightPos0.xyz; 715 | #endif 716 | UNITY_TRANSFER_SHADOW(o,v.texcoord1.xy); // pass shadow coordinates to pixel shader 717 | UNITY_TRANSFER_FOG(o,o.pos); // pass fog coordinates to pixel shader 718 | return o; 719 | } 720 | 721 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 722 | 723 | // tessellation domain shader 724 | [UNITY_domain("tri")] 725 | inline v2f_surf ds_surf (UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) { 726 | appdata_full v; 727 | v.vertex = vi[0].vertex*bary.x + vi[1].vertex*bary.y + vi[2].vertex*bary.z; 728 | #if USE_PHONG 729 | float3 pp[3]; 730 | pp[0] = v.vertex.xyz - vi[0].normal * (dot(v.vertex.xyz, vi[0].normal) - dot(vi[0].vertex.xyz, vi[0].normal)); 731 | pp[1] = v.vertex.xyz - vi[1].normal * (dot(v.vertex.xyz, vi[1].normal) - dot(vi[1].vertex.xyz, vi[1].normal)); 732 | pp[2] = v.vertex.xyz - vi[2].normal * (dot(v.vertex.xyz, vi[2].normal) - dot(vi[2].vertex.xyz, vi[2].normal)); 733 | v.vertex.xyz = _Phong * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-_Phong) * v.vertex.xyz; 734 | #endif 735 | v.tangent = vi[0].tangent*bary.x + vi[1].tangent*bary.y + vi[2].tangent*bary.z; 736 | v.normal = vi[0].normal*bary.x + vi[1].normal*bary.y + vi[2].normal*bary.z; 737 | v.texcoord = vi[0].texcoord*bary.x + vi[1].texcoord*bary.y + vi[2].texcoord*bary.z; 738 | v.texcoord1 = vi[0].texcoord1*bary.x + vi[1].texcoord1*bary.y + vi[2].texcoord1*bary.z; 739 | v.texcoord2 = 0; 740 | v.texcoord3 = 0; 741 | v.color = 0; 742 | #if USE_VERTEX 743 | vert(v); 744 | #endif 745 | v2f_surf o = vert_surf (v); 746 | return o; 747 | } 748 | 749 | #endif // UNITY_CAN_COMPILE_TESSELLATION 750 | 751 | 752 | // fragment shader 753 | inline float4 frag_surf (v2f_surf IN) : SV_Target { 754 | UNITY_SETUP_INSTANCE_ID(IN); 755 | // prepare and unpack data 756 | Input surfIN; 757 | UNITY_INITIALIZE_OUTPUT(Input,surfIN); 758 | surfIN.uv_MainTex.x = 1.0; 759 | 760 | surfIN.uv_MainTex = IN.pack0.xy; 761 | #if USE_DETAILALBEDO 762 | surfIN.uv_DetailAlbedo = IN.pack1; 763 | #endif 764 | 765 | #if USE_DETAILNORMAL 766 | surfIN.uv_DetailNormal = IN.pack2; 767 | #endif 768 | float3 worldPos = (IN.worldPos); 769 | float3 lightDir = normalize(IN.lightDir); 770 | float3 worldViewDir = normalize(IN.worldViewDir); 771 | #ifdef UNITY_COMPILER_HLSL 772 | SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0; 773 | #else 774 | SurfaceOutputStandardSpecular o; 775 | #endif 776 | float3x3 wdMatrix= float3x3( normalize(IN.tSpace0.xyz), normalize(IN.tSpace1.xyz), normalize(IN.tSpace2.xyz)); 777 | // call surface function 778 | surf (surfIN, o); 779 | UNITY_LIGHT_ATTENUATION(atten, IN, worldPos) 780 | float4 c = 0; 781 | 782 | o.Normal = normalize(mul(wdMatrix, o.Normal)); 783 | float fragDepth = length(worldPos - _WorldSpaceCameraPos); 784 | float backDepth = DecodeFloatRGBA(tex2Dproj(_CullFrontDepthTex, IN.screenPos)) * 255; 785 | float thickness = saturate(1 - max(backDepth - fragDepth, _MinDistance) * _Thickness); 786 | // Setup lighting environment 787 | UnityGI gi; 788 | UNITY_INITIALIZE_OUTPUT(UnityGI, gi); 789 | gi.light.color = _LightColor0.rgb * atten; 790 | gi.light.dir = lightDir; 791 | float3 transparentColor = SubTransparentColor(lightDir, worldViewDir, _LightColor0.rgb, thickness); 792 | float3 bloodColor = BloodColor(o.Normal, lightDir) * o.Albedo * gi.light.color; 793 | o.Albedo *= 0.04; 794 | c += LightingStandardSpecular (o, worldViewDir, gi); 795 | c.rgb += bloodColor + transparentColor; 796 | c.a = 0.0; 797 | UNITY_APPLY_FOG(IN.fogCoord, c); // apply fog 798 | UNITY_OPAQUE_ALPHA(c.a); 799 | return c; 800 | } 801 | 802 | 803 | #endif 804 | 805 | 806 | ENDCG 807 | 808 | } 809 | Pass { 810 | Name "ShadowCaster" 811 | Tags { "LightMode" = "ShadowCaster" } 812 | ZWrite On ZTest LEqual 813 | 814 | CGPROGRAM 815 | // compile directives 816 | #pragma vertex tessvert_surf_shadowCaster 817 | #pragma fragment frag_surf 818 | #pragma hull hs_surf 819 | #pragma domain ds_surf 820 | #pragma target 5.0 821 | 822 | #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2 823 | #pragma multi_compile_shadowcaster 824 | 825 | // -------- variant for: 826 | #if !defined(INSTANCING_ON) 827 | #define UNITY_PASS_SHADOWCASTER 828 | 829 | #define INTERNAL_DATA 830 | #define WorldReflectionVector(data,normal) data.worldRefl 831 | #define WorldNormalVector(data,normal) normal 832 | 833 | // Original surface shader snippet: 834 | #line 10 "" 835 | #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING 836 | #endif 837 | 838 | struct v2f_surf { 839 | V2F_SHADOW_CASTER; 840 | 841 | UNITY_VERTEX_INPUT_INSTANCE_ID 842 | UNITY_VERTEX_OUTPUT_STEREO 843 | }; 844 | 845 | // vertex shader 846 | inline v2f_surf vert_surf (appdata_full v) { 847 | v2f_surf o; 848 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 849 | TRANSFER_SHADOW_CASTER_NORMALOFFSET(o) 850 | return o; 851 | } 852 | 853 | inline InternalTessInterp_appdata_full tessvert_surf_shadowCaster (appdata_full v) { 854 | InternalTessInterp_appdata_full o; 855 | o.vertex = v.vertex; 856 | o.normal = v.normal; 857 | o.texcoord = v.texcoord; 858 | return o; 859 | } 860 | 861 | [UNITY_domain("tri")] 862 | inline v2f_surf ds_surf (UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) { 863 | appdata_full v; 864 | v.vertex = vi[0].vertex*bary.x + vi[1].vertex*bary.y + vi[2].vertex*bary.z; 865 | #if USE_PHONG 866 | float3 pp[3]; 867 | pp[0] = v.vertex.xyz - vi[0].normal * (dot(v.vertex.xyz, vi[0].normal) - dot(vi[0].vertex.xyz, vi[0].normal)); 868 | pp[1] = v.vertex.xyz - vi[1].normal * (dot(v.vertex.xyz, vi[1].normal) - dot(vi[1].vertex.xyz, vi[1].normal)); 869 | pp[2] = v.vertex.xyz - vi[2].normal * (dot(v.vertex.xyz, vi[2].normal) - dot(vi[2].vertex.xyz, vi[2].normal)); 870 | v.vertex.xyz = _Phong * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-_Phong) * v.vertex.xyz; 871 | #endif 872 | v.tangent = 0; 873 | v.normal = vi[0].normal*bary.x + vi[1].normal*bary.y + vi[2].normal*bary.z; 874 | v.texcoord = vi[0].texcoord*bary.x + vi[1].texcoord*bary.y + vi[2].texcoord*bary.z; 875 | v.texcoord1 = 0; 876 | v.texcoord2 = 0; 877 | v.texcoord3 = 0; 878 | v.color = 0; 879 | #if USE_VERTEX 880 | vert(v); 881 | #endif 882 | v2f_surf o = vert_surf (v); 883 | return o; 884 | } 885 | 886 | // fragment shader 887 | inline float4 frag_surf (v2f_surf IN) : SV_Target { 888 | return 1; 889 | } 890 | 891 | 892 | #endif 893 | 894 | ENDCG 895 | 896 | } 897 | // ---- meta information extraction pass: 898 | Pass { 899 | Name "Meta" 900 | Tags { "LightMode" = "Meta" } 901 | Cull Off 902 | 903 | CGPROGRAM 904 | // compile directives 905 | #pragma vertex tessvert_surf 906 | #pragma fragment frag_surf 907 | #pragma hull hs_surf 908 | #pragma domain ds_surf 909 | #pragma target 5.0 910 | 911 | #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2 912 | #pragma skip_variants INSTANCING_ON 913 | #pragma shader_feature EDITOR_VISUALIZATION 914 | 915 | 916 | // -------- variant for: 917 | #if !defined(INSTANCING_ON) 918 | // Surface shader code generated based on: 919 | // vertex modifier: 'disp' 920 | // writes to per-pixel normal: YES 921 | // writes to emission: YES 922 | // writes to occlusion: YES 923 | // needs world space reflection vector: no 924 | // needs world space normal vector: no 925 | // needs screen space position: no 926 | // needs world space position: no 927 | // needs view direction: no 928 | // needs world space view direction: no 929 | // needs world space position for lighting: YES 930 | // needs world space view direction for lighting: YES 931 | // needs world space view direction for lightmaps: no 932 | // needs vertex color: no 933 | // needs VFACE: no 934 | // passes tangent-to-world matrix to pixel shader: YES 935 | // reads from normal: no 936 | // 1 texcoords actually used 937 | // float2 _MainTex 938 | #define UNITY_PASS_META 939 | 940 | #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2; 941 | #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))) 942 | #define WorldNormalVector(data,normal) float3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)) 943 | 944 | // Original surface shader snippet: 945 | #line 22 "" 946 | #ifdef DUMMY_PREPROCESSOR_TO_WORK_AROUND_HLSL_COMPILER_LINE_HANDLING 947 | #endif 948 | 949 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 950 | 951 | // tessellation vertex shader 952 | 953 | 954 | // tessellation hull constant shader 955 | 956 | // tessellation hull shader 957 | 958 | 959 | #endif // UNITY_CAN_COMPILE_TESSELLATION 960 | 961 | 962 | 963 | // vertex-to-fragment interpolation data 964 | struct v2f_surf { 965 | UNITY_POSITION(pos); 966 | float2 pack0 : TEXCOORD0; // _MainTex 967 | float4 tSpace0 : TEXCOORD1; 968 | float4 tSpace1 : TEXCOORD2; 969 | float4 tSpace2 : TEXCOORD3; 970 | UNITY_VERTEX_INPUT_INSTANCE_ID 971 | UNITY_VERTEX_OUTPUT_STEREO 972 | }; 973 | float4 _MainTex_ST; 974 | 975 | // vertex shader 976 | inline v2f_surf vert_surf (appdata_full v) { 977 | UNITY_SETUP_INSTANCE_ID(v); 978 | v2f_surf o; 979 | UNITY_INITIALIZE_OUTPUT(v2f_surf,o); 980 | 981 | o.pos = UnityMetaVertexPosition(v.vertex, v.texcoord1.xy, v.texcoord2.xy, unity_LightmapST, unity_DynamicLightmapST); 982 | o.pack0.xy = TRANSFORM_TEX(v.texcoord, _MainTex); 983 | float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; 984 | float3 worldNormal = UnityObjectToWorldNormal(v.normal); 985 | float3 worldTangent = UnityObjectToWorldDir(v.tangent.xyz); 986 | float tangentSign = v.tangent.w * unity_WorldTransformParams.w; 987 | float3 worldBinormal = cross(worldNormal, worldTangent) * tangentSign; 988 | 989 | return o; 990 | } 991 | 992 | #ifdef UNITY_CAN_COMPILE_TESSELLATION 993 | 994 | // tessellation domain shader 995 | [UNITY_domain("tri")] 996 | inline v2f_surf ds_surf (UnityTessellationFactors tessFactors, const OutputPatch vi, float3 bary : SV_DomainLocation) { 997 | appdata_full v; 998 | v.vertex = vi[0].vertex*bary.x + vi[1].vertex*bary.y + vi[2].vertex*bary.z; 999 | #if USE_PHONG 1000 | float3 pp[3]; 1001 | pp[0] = v.vertex.xyz - vi[0].normal * (dot(v.vertex.xyz, vi[0].normal) - dot(vi[0].vertex.xyz, vi[0].normal)); 1002 | pp[1] = v.vertex.xyz - vi[1].normal * (dot(v.vertex.xyz, vi[1].normal) - dot(vi[1].vertex.xyz, vi[1].normal)); 1003 | pp[2] = v.vertex.xyz - vi[2].normal * (dot(v.vertex.xyz, vi[2].normal) - dot(vi[2].vertex.xyz, vi[2].normal)); 1004 | v.vertex.xyz = _Phong * (pp[0]*bary.x + pp[1]*bary.y + pp[2]*bary.z) + (1.0f-_Phong) * v.vertex.xyz; 1005 | #endif 1006 | v.tangent = vi[0].tangent*bary.x + vi[1].tangent*bary.y + vi[2].tangent*bary.z; 1007 | v.normal = vi[0].normal*bary.x + vi[1].normal*bary.y + vi[2].normal*bary.z; 1008 | v.texcoord = vi[0].texcoord*bary.x + vi[1].texcoord*bary.y + vi[2].texcoord*bary.z; 1009 | v.texcoord1 = vi[0].texcoord1*bary.x + vi[1].texcoord1*bary.y + vi[2].texcoord1*bary.z; 1010 | v.texcoord2 = vi[0].texcoord2*bary.x + vi[1].texcoord2*bary.y + vi[2].texcoord2*bary.z; 1011 | v.texcoord3 = 0; 1012 | v.color = 0; 1013 | #if USE_VERTEX 1014 | vert(v); 1015 | #endif 1016 | v2f_surf o = vert_surf (v); 1017 | return o; 1018 | } 1019 | 1020 | #endif // UNITY_CAN_COMPILE_TESSELLATION 1021 | 1022 | 1023 | // fragment shader 1024 | inline float4 frag_surf (v2f_surf IN) : SV_Target { 1025 | UNITY_SETUP_INSTANCE_ID(IN); 1026 | // prepare and unpack data 1027 | Input surfIN; 1028 | UNITY_INITIALIZE_OUTPUT(Input,surfIN); 1029 | surfIN.uv_MainTex.x = 1.0; 1030 | 1031 | surfIN.uv_MainTex = IN.pack0.xy; 1032 | float3 worldPos = float3(IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w); 1033 | #ifdef UNITY_COMPILER_HLSL 1034 | SurfaceOutputStandardSpecular o = (SurfaceOutputStandardSpecular)0; 1035 | #else 1036 | SurfaceOutputStandardSpecular o; 1037 | #endif 1038 | 1039 | 1040 | 1041 | // call surface function 1042 | surf (surfIN, o); 1043 | UnityMetaInput metaIN; 1044 | UNITY_INITIALIZE_OUTPUT(UnityMetaInput, metaIN); 1045 | metaIN.Albedo = o.Albedo; 1046 | metaIN.Emission = o.Emission; 1047 | metaIN.SpecularColor = o.Specular; 1048 | return UnityMetaFragment(metaIN); 1049 | } 1050 | 1051 | 1052 | #endif 1053 | 1054 | 1055 | ENDCG 1056 | 1057 | } 1058 | 1059 | // ---- end of surface shader generated code 1060 | 1061 | #LINE 90 1062 | 1063 | } 1064 | CustomEditor "SpecularShaderEditor" 1065 | } 1066 | 1067 | -------------------------------------------------------------------------------- /Assets/Shader/SkinShader/Shaders/Tess-Skin.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 12b9a2051f5880f499cccf19e7d1a7c4 3 | timeCreated: 1521399742 4 | licenseType: Pro 5 | ShaderImporter: 6 | externalObjects: {} 7 | defaultTextures: 8 | - _MainTex: {instanceID: 0} 9 | - _BumpMap: {instanceID: 0} 10 | - _SpecularMap: {instanceID: 0} 11 | - _HeightMap: {instanceID: 0} 12 | - _OcclusionMap: {instanceID: 0} 13 | - _DetailAlbedo: {instanceID: 0} 14 | - _DetailBump: {instanceID: 0} 15 | - _RampTex: {fileID: 2800000, guid: 43721d2a1a9c49b4585a8dd6dfab0a40, type: 3} 16 | userData: 17 | assetBundleName: 18 | assetBundleVariant: 19 | -------------------------------------------------------------------------------- /Assets/SkinDemo.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/Assets/SkinDemo.unity -------------------------------------------------------------------------------- /Assets/SkinDemo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c11907d87c1bbd43a2c73e4acb81cf7 3 | timeCreated: 18446744011573954816 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Subsurface Jade Demo.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/Assets/Subsurface Jade Demo.unity -------------------------------------------------------------------------------- /Assets/Subsurface Jade Demo.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a84a29c371fd1aa429c3c55a44332dab 3 | timeCreated: 1521673242 4 | licenseType: Pro 5 | DefaultImporter: 6 | externalObjects: {} 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/PresetManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2017.3.1f1 2 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leinlin/Unity-Subsurface-Scattering-Skin/0f4a9e09ff9072ceacd3321c7fcb3e42bc626e4f/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity-Subsurface-Scattering-Skin 2 | -------------------------------------------------------------------------------- /Subsurface Skin.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Subsurface Skin", "Assembly-CSharp.csproj", "{37D3C424-42C5-A773-D4EA-A048BF8BEEEC}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Subsurface Skin", "Assembly-CSharp-Editor.csproj", "{A2B4F519-8932-863A-5BC4-5C8A9E6BC10F}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {37D3C424-42C5-A773-D4EA-A048BF8BEEEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {37D3C424-42C5-A773-D4EA-A048BF8BEEEC}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {37D3C424-42C5-A773-D4EA-A048BF8BEEEC}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {37D3C424-42C5-A773-D4EA-A048BF8BEEEC}.Release|Any CPU.Build.0 = Release|Any CPU 18 | {A2B4F519-8932-863A-5BC4-5C8A9E6BC10F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {A2B4F519-8932-863A-5BC4-5C8A9E6BC10F}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {A2B4F519-8932-863A-5BC4-5C8A9E6BC10F}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {A2B4F519-8932-863A-5BC4-5C8A9E6BC10F}.Release|Any CPU.Build.0 = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(SolutionProperties) = preSolution 24 | HideSolutionNode = FALSE 25 | EndGlobalSection 26 | GlobalSection(MonoDevelopProperties) = preSolution 27 | StartupItem = Assembly-CSharp.csproj 28 | EndGlobalSection 29 | EndGlobal 30 | -------------------------------------------------------------------------------- /Subsurface Skin.userprefs: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /UnityPackageManager/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | } 4 | } 5 | --------------------------------------------------------------------------------