├── LICENSE.meta ├── README.md.meta ├── package.json.meta ├── Editor.meta ├── Editor ├── Cyanilux.BakeShader.Editor.asmdef.meta ├── BakeShader.cs.meta ├── Cyanilux.BakeShader.Editor.asmdef └── BakeShader.cs ├── Bake Shader Vertex Pos.shadersubgraph.meta ├── package.json ├── LICENSE ├── .gitignore ├── README.md └── Bake Shader Vertex Pos.shadersubgraph /LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 359774c7abf45f3468387393e222051d 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c03080a0f3832b94a9149116b3c3a324 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3caf126ca66339c4c80505873cd993d0 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5d05a8bb764529946863100b619926e5 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Cyanilux.BakeShader.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab82ce88a6cdd644e947c0c29566bec4 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/BakeShader.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecaad829568704847a792b344520aeee 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Bake Shader Vertex Pos.shadersubgraph.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36cb7734d94fb5549ac92a7d61fb9162 3 | ScriptedImporter: 4 | internalIDToNameTable: [] 5 | externalObjects: {} 6 | serializedVersion: 2 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.cyanilux.bakeshader", 3 | "version": "1.0.1", 4 | "displayName": "Bake Shader", 5 | "description": "Tool for baking shaders to textures. Blit2D, Blit3D, or MeshRenderer (uses model UV). Adds options to Material & MeshRenderer context menus and Editor Window (under Window/Cyanilux/BakeShader)", 6 | "keywords": [], 7 | "author": { 8 | "name": "Cyanilux", 9 | "url": "https://twitter.com/Cyanilux" 10 | } 11 | } -------------------------------------------------------------------------------- /Editor/Cyanilux.BakeShader.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Cyanilux.BakeShader.Editor", 3 | "rootNamespace": "Cyan", 4 | "references": [], 5 | "includePlatforms": [ 6 | "Editor" 7 | ], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Cyanilux 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Asset meta data should only be ignored when the corresponding asset is also ignored 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # Autogenerated Jetbrains Rider plugin 20 | [Aa]ssets/Plugins/Editor/JetBrains* 21 | 22 | # Visual Studio cache directory 23 | .vs/ 24 | 25 | # Gradle cache directory 26 | .gradle/ 27 | 28 | # Autogenerated VS/MD/Consulo solution and project files 29 | ExportedObj/ 30 | .consulo/ 31 | *.csproj 32 | *.unityproj 33 | *.sln 34 | *.suo 35 | *.tmp 36 | *.user 37 | *.userprefs 38 | *.pidb 39 | *.booproj 40 | *.svd 41 | *.pdb 42 | *.mdb 43 | *.opendb 44 | *.VC.db 45 | 46 | # Unity3D generated meta files 47 | *.pidb.meta 48 | *.pdb.meta 49 | *.mdb.meta 50 | 51 | # Unity3D generated file on crash reports 52 | sysinfo.txt 53 | 54 | # Builds 55 | *.apk 56 | *.unitypackage 57 | 58 | # Crashlytics generated file 59 | crashlytics-build.properties 60 | 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## BakeShader 2 | 3 | ![Bake](https://user-images.githubusercontent.com/69320946/187734767-1b574014-9d53-4f83-86e3-7f06f7ad2188.gif) 4 | 5 | - Adds "Bake Shader" window (under Window/Cyanilux/BakeShader) 6 | - Includes modes : Texture2D (png), Texture3D asset, Flipbook, MeshRenderer 7 | - Also adds "Bake" options to the "..." context menus on Material asset and MeshRenderer component 8 | - (If BakeShader window is open, this will use resolution & path settings set there, otherwise uses defaults mentioned below) 9 | - Should work in any render pipeline! 10 | - By default, results are saved under Assets/BakedTextures 11 | 12 | ### Setup: 13 | - Install via Package Manager → Add package via git URL : 14 | - `https://github.com/Cyanilux/BakeShader.git` 15 | - Alternatively, download and put the folder in your Assets 16 | 17 | ### Bake Modes : 18 | - **Texture2D (png)** 19 | - Shader is blit (basically draws a quad) 20 | - Result saved as .png 21 | - Defaults to 2048x2048 size 22 | - **Texture3D** 23 | - Shader is blit in slices. Use `_Slice` Float property in shader calculations. This ranges from 0 to 1 through the depth of the Texture3D 24 | - Result saved as Texture3D asset 25 | - Defaults to 128x128x128 size 26 | - **Flipbook** 27 | - Same as Texture3D, but slices are combined vertically into a long Texture2D 28 | - Result saved as .png, this could then be imported as a regular texture (for usage with Flipbook node later) or as a 2D Array, or 3D Texture. 29 | - Defaults to 256x256 size (per slice), 32 slices, (so final image size of 256x8192) 30 | - **MeshRenderer : Renderer is drawn to Texture2D** 31 | - Will bake using first Material only. Scene View must be open for Renderer baking to occur 32 | - Defaults to 2048x2048 size 33 | - For the intended result, shader should be **unlit** and **output using UV coordinates instead of vertices** : 34 | - For Shader Graphs, use the provided `Bake Shader Vertex Pos` subgraph in the **Position** port on the **Vertex** stack. Also use `Render Face : Both` in graph settings. 35 | - Note that using the `Position` node in **Fragment** stage will now produce different results, as this changes the vertex positions. In v12+ we can avoid this by using a **Custom Interpolator** to pass the unmodified vertex pos through, if required. See : https://www.cyanilux.com/tutorials/intro-to-shader-graph/#custom-interpolators 36 | - For Shader Code (CG/HLSL), the following should work (though some variables may need renaming). The pass should also specify `Cull Off` 37 | 38 | ``` 39 | #pragma multi_compile _ _BAKESHADER 40 | 41 | // in vertex function : 42 | #ifdef _BAKESHADER 43 | float2 remappedUV = IN.uv.xy * 2 - 1; 44 | float4 outputPos = float4(remappedUV.x, remappedUV.y, 0, 1); 45 | OUT.vertex = outputPos; // Built-in RP 46 | OUT.positionCS = outputPos; // URP 47 | #else 48 | OUT.vertex = UnityObjectToClipPos(IN.vertex); // Built-in RP 49 | OUT.positionCS = TransformObjectToHClip(IN.vertex); // URP 50 | #endif 51 | // (where "vertex" / "positionCS" is the common naming convention for the parameter using SV_POSITION semantic) 52 | ``` 53 | -------------------------------------------------------------------------------- /Editor/BakeShader.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using UnityEngine; 3 | using UnityEditor; 4 | using UnityEngine.Rendering; 5 | using Unity.Collections; 6 | 7 | /* 8 | @Cyanilux 9 | 10 | - Adds "Bake Shader" window (under Window/Cyanilux/BakeShader) 11 | - Includes modes : Blit2D (png), Blit3D (Texture3D asset), MeshRenderer 12 | - Also adds "Bake" options to the "..." context menus on Material asset and MeshRenderer component 13 | - (If BakeShader window is open, this will use resolution & path settings set there, otherwise uses defaults) 14 | - Should work in any render pipeline! 15 | 16 | For usage instructions, see README file 17 | */ 18 | 19 | namespace Cyan { 20 | 21 | public class BakeShader { 22 | 23 | private static int delayBaking = 1; // (in seconds) 24 | private static int blit3DSliceProperty = Shader.PropertyToID("_Slice"); // Used for Texture3D and Flipbook baking 25 | private static GlobalKeyword bakeShaderKeyword = GlobalKeyword.Create("_BAKESHADER"); 26 | 27 | // ----------------------------------------------------------- 28 | 29 | #region EditorWindow 30 | 31 | public enum BakeType { 32 | Texture2D, 33 | Texture3D, 34 | MeshRenderer, 35 | Flipbook 36 | } 37 | 38 | private class BakeShaderWindow : EditorWindow { 39 | 40 | public Vector3Int res3D = new Vector3Int(128, 128, 128); 41 | public Vector3Int resFlipbook = new Vector3Int(256, 256, 32); 42 | public Vector2Int res2D = new Vector2Int(2048, 2048); 43 | public BakeType bakeType; 44 | public MeshRenderer meshRenderer; 45 | public Material material; 46 | public string path = "BakedTextures"; 47 | 48 | private void OnGUI(){ 49 | EditorGUILayout.LabelField("Settings", EditorStyles.boldLabel); 50 | bakeType = (BakeType) EditorGUILayout.EnumPopup("Bake Type", bakeType); 51 | 52 | if (bakeType == BakeType.Texture3D){ 53 | res3D = EditorGUILayout.Vector3IntField("Resolution", res3D); 54 | }else if (bakeType == BakeType.Flipbook){ 55 | Vector2Int res = EditorGUILayout.Vector2IntField("Frame Resolution", new Vector2Int(resFlipbook.x, resFlipbook.y)); 56 | resFlipbook.x = res.x; 57 | resFlipbook.y = res.y; 58 | resFlipbook.z = EditorGUILayout.IntField("Frame Count", resFlipbook.z); 59 | }else{ 60 | res2D = EditorGUILayout.Vector2IntField("Resolution", res2D); 61 | } 62 | if (bakeType == BakeType.MeshRenderer){ 63 | meshRenderer = (MeshRenderer) EditorGUILayout.ObjectField("Mesh Renderer", meshRenderer, typeof(MeshRenderer), true); 64 | }else{ 65 | material = (Material) EditorGUILayout.ObjectField("Material", material, typeof(Material), true); 66 | } 67 | 68 | EditorGUILayout.Space(); 69 | path = EditorGUILayout.TextField("Path (Assets/)", path); 70 | EditorGUILayout.Space(); 71 | 72 | if (GUILayout.Button("Bake")){ 73 | Bake(); 74 | } 75 | } 76 | 77 | public void Bake(){ 78 | if (bakeType == BakeType.Texture2D){ 79 | BakeShader.Blit2D(material, res2D, path); 80 | }else if (bakeType == BakeType.Texture3D){ 81 | BakeShader.Blit3D(material, res3D, path); 82 | }else if (bakeType == BakeType.MeshRenderer){ 83 | BakeShader.Renderer(meshRenderer, res2D, path); 84 | }else if (bakeType == BakeType.Flipbook){ 85 | BakeShader.Blit3D(material, resFlipbook, path, true); 86 | } 87 | } 88 | 89 | } 90 | 91 | [MenuItem("Window/Cyanilux/Bake Shader")] 92 | private static void ShowWindow(MenuCommand command) { 93 | BakeShaderWindow window = (BakeShaderWindow)EditorWindow.GetWindow(typeof(BakeShaderWindow)); 94 | window.titleContent = new GUIContent("Bake Shader"); 95 | window.Show(); 96 | } 97 | 98 | #endregion 99 | 100 | #region ContextMenus 101 | 102 | [MenuItem("CONTEXT/MeshRenderer/Bake/Material To Texture (using Mesh UV)")] 103 | private static void ContextMenu_Bake(MenuCommand command) { 104 | Vector2Int res2D = new Vector2Int(2048, 2048); 105 | string path = "BakedTextures"; 106 | if (EditorWindow.HasOpenInstances()){ 107 | BakeShaderWindow window = (BakeShaderWindow)EditorWindow.GetWindow(typeof(BakeShaderWindow)); 108 | res2D = window.res2D; 109 | path = window.path; 110 | } 111 | MeshRenderer meshRenderer = (MeshRenderer)command.context; 112 | Renderer(meshRenderer, res2D, path); 113 | } 114 | 115 | [MenuItem("CONTEXT/Material/Bake/Texture2D (png)")] 116 | private static void ContextMenu_Blit2D(MenuCommand command) { 117 | Vector2Int res2D = new Vector2Int(2048, 2048); 118 | string path = "BakedTextures"; 119 | if (EditorWindow.HasOpenInstances()){ 120 | BakeShaderWindow window = (BakeShaderWindow)EditorWindow.GetWindow(typeof(BakeShaderWindow)); 121 | res2D = window.res2D; 122 | path = window.path; 123 | } 124 | Material material = (Material)command.context; 125 | Blit2D(material, res2D, path); 126 | } 127 | 128 | [MenuItem("CONTEXT/Material/Bake/Texture3D")] 129 | private static void ContextMenu_Bake3D(MenuCommand command) { 130 | Vector3Int res3D = new Vector3Int(128, 128, 128); 131 | string path = "BakedTextures"; 132 | if (EditorWindow.HasOpenInstances()){ 133 | BakeShaderWindow window = (BakeShaderWindow)EditorWindow.GetWindow(typeof(BakeShaderWindow)); 134 | res3D = window.res3D; 135 | path = window.path; 136 | } 137 | Material material = (Material)command.context; 138 | Blit3D(material, res3D, path); 139 | } 140 | 141 | [MenuItem("CONTEXT/Material/Bake/Flipbook")] 142 | private static void ContextMenu_BakeFlipbook(MenuCommand command) { 143 | Vector3Int resFlipbook = new Vector3Int(256, 256, 32); 144 | string path = "BakedTextures"; 145 | if (EditorWindow.HasOpenInstances()){ 146 | BakeShaderWindow window = (BakeShaderWindow)EditorWindow.GetWindow(typeof(BakeShaderWindow)); 147 | resFlipbook = window.resFlipbook; 148 | path = window.path; 149 | } 150 | Material material = (Material)command.context; 151 | Blit3D(material, resFlipbook, path, true); 152 | } 153 | 154 | #endregion 155 | 156 | #region Baking 157 | 158 | public static void Blit2D(Material material, Vector2Int resolution, string path){ 159 | RenderTexture rt = RenderTexture.GetTemporary(resolution.x, resolution.y); 160 | 161 | // Blit 162 | Graphics.Blit(null, rt, material, 0); 163 | 164 | // Read & Save 165 | Texture2D tex2D = ReadPixels2D(rt); 166 | SavePNG(path, GetMaterialName(material) + "_BakedTexture", tex2D.EncodeToPNG()); 167 | 168 | // Cleanup 169 | Object.DestroyImmediate(tex2D); 170 | RenderTexture.ReleaseTemporary(rt); 171 | RenderTexture.active = null; 172 | } 173 | 174 | public static void Blit3D(Material material, Vector3Int resolution, string path, bool saveAsFlipbook = false){ 175 | int w = resolution.x; 176 | int h = resolution.y; 177 | int d = resolution.z; 178 | RenderTextureDescriptor desc = new RenderTextureDescriptor(w, h) { 179 | dimension = UnityEngine.Rendering.TextureDimension.Tex3D, 180 | volumeDepth = d 181 | }; 182 | RenderTexture rt = RenderTexture.GetTemporary(desc); 183 | 184 | // Blit 185 | for (int i = 0; i < d; i++) { 186 | material.SetFloat(blit3DSliceProperty, ((i + 0.5f) / d)); 187 | Graphics.Blit(null, rt, material, 0, i); 188 | } 189 | 190 | // Readback 191 | AsyncGPUReadback.Request(rt, 0, 0, w, 0, h, 0, d, (AsyncGPUReadbackRequest rq) => { 192 | Color32[] arr = new Color32[w * h * d]; 193 | int size = w * h; 194 | for (int i = 0; i < d; i++) { 195 | NativeArray data = rq.GetData(i); 196 | NativeArray.Copy(data, 0, arr, i * size, size); 197 | } 198 | 199 | if (saveAsFlipbook){ 200 | // Save as Flipbook (PNG containing all slices/frames, vertically so I don't need to reorder array...) 201 | Texture2D tex = new Texture2D(w, h * d); 202 | tex.SetPixels32(arr); 203 | SavePNG(path, GetMaterialName(material) + "_BakedFlipbook", tex.EncodeToPNG()); 204 | }else{ 205 | // Save as Texture3D 206 | Texture3D tex = new Texture3D(w, h, d, TextureFormat.RGBA32, 0); 207 | tex.SetPixels32(arr, 0); 208 | SaveTexture3DAsset(path, GetMaterialName(material) + "_BakedTexture3D", tex); 209 | RenderTexture.ReleaseTemporary(rt); 210 | } 211 | 212 | }); 213 | } 214 | 215 | private static float initTime; 216 | private static MeshRenderer renderer; 217 | private static Vector2Int resolution; 218 | private static string path; 219 | 220 | public static void Renderer(MeshRenderer renderer, Vector2Int resolution, string path){ 221 | initTime = Time.realtimeSinceStartup; 222 | BakeShader.renderer = renderer; 223 | BakeShader.resolution = resolution; 224 | BakeShader.path = path; 225 | 226 | // UnityEngine.Experimental.Rendering.ShaderWarmup.WarmupShader(renderer.sharedMaterial.shader, new ShaderWarmupSetup()); 227 | // ShaderWarmup doesn't seem to help :\ 228 | // Pretty hacky, but will enable keyword, add a delay... and just let Unity handle it! 229 | Shader.EnableKeyword(bakeShaderKeyword); 230 | EditorApplication.update += DelayedRendererBake; 231 | } 232 | 233 | private static void DelayedRendererBake() { 234 | if (Time.realtimeSinceStartup < initTime + delayBaking) return; 235 | 236 | // Unregister function, make sure we only bake once 237 | EditorApplication.update -= DelayedRendererBake; 238 | 239 | // Bake 240 | RenderTexture renderTarget = RenderTexture.GetTemporary(resolution.x, resolution.y); 241 | Mesh mesh = renderer.gameObject.GetComponent().sharedMesh; 242 | Material material = renderer.sharedMaterial; 243 | 244 | CommandBuffer cmd = new CommandBuffer(); 245 | cmd.SetRenderTarget(renderTarget); 246 | cmd.EnableKeyword(bakeShaderKeyword); 247 | cmd.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.identity); 248 | cmd.DrawRenderer(renderer, renderer.sharedMaterial, 0, 0); 249 | cmd.DisableKeyword(bakeShaderKeyword); 250 | Graphics.ExecuteCommandBuffer(cmd); 251 | 252 | // Read & Save 253 | Texture2D tex2D = ReadPixels2D(renderTarget); 254 | SavePNG(path, GetMaterialName(material) + "_BakedTexture", tex2D.EncodeToPNG()); 255 | 256 | // Enable "Alpha Is Transparency" 257 | // (Unity should then stretch pixels in transparent areas, avoiding black seams around UV islands) 258 | TextureImporter texImporter = (TextureImporter) AssetImporter.GetAtPath("Assets/" + path + "/" + GetMaterialName(material) + "_BakedTexture.png"); 259 | texImporter.alphaIsTransparency = true; 260 | EditorUtility.SetDirty(texImporter); 261 | texImporter.SaveAndReimport(); 262 | 263 | // Cleanup 264 | Shader.DisableKeyword(bakeShaderKeyword); 265 | Object.DestroyImmediate(tex2D); 266 | RenderTexture.ReleaseTemporary(renderTarget); 267 | } 268 | 269 | private static Texture2D ReadPixels2D(RenderTexture rt){ 270 | // Readback 271 | RenderTexture current = RenderTexture.active; 272 | RenderTexture.active = rt; 273 | Vector2Int resolution = new Vector2Int(rt.width, rt.height); 274 | Texture2D tex = new Texture2D(resolution.x, resolution.y); 275 | tex.ReadPixels(new Rect(0, 0, resolution.x, resolution.y), 0, 0); 276 | //tex.Apply(); 277 | RenderTexture.active = current; 278 | return tex; 279 | } 280 | 281 | private static void SavePNG(string path, string name, byte[] bytes){ 282 | Directory.CreateDirectory(Application.dataPath + "/" + path); 283 | 284 | string pathName = path + "/" + name + ".png"; 285 | Object existingAsset = AssetDatabase.LoadAssetAtPath("Assets/" + pathName); 286 | if (existingAsset != null) { 287 | if (!EditorUtility.DisplayDialog("BakeShader", 288 | "Warning : Asset at path 'Assets/"+pathName+"' already exists, override it?", 289 | "Override!", "Cancel!")) { 290 | return; 291 | } 292 | } 293 | 294 | File.WriteAllBytes(Application.dataPath + "/" + pathName, bytes); 295 | AssetDatabase.Refresh(); 296 | } 297 | 298 | private static void SaveTexture3DAsset(string path, string name, Texture3D tex){ 299 | // Save Texture3D Asset 300 | Directory.CreateDirectory(Application.dataPath + "/" + path); 301 | tex.name = name; 302 | string assetPath = "Assets/" + path + "/" + name + ".asset"; 303 | Object existingAsset = AssetDatabase.LoadAssetAtPath(assetPath); 304 | if (existingAsset != null) { 305 | if (!EditorUtility.DisplayDialog("BakeShader", 306 | "Warning : Asset at path '"+assetPath+"' already exists, override it?", 307 | "Override!", "Cancel!")) { 308 | return; 309 | } 310 | } 311 | 312 | if (existingAsset == null) { 313 | AssetDatabase.CreateAsset(tex, assetPath); 314 | } else { 315 | EditorUtility.CopySerialized(tex, existingAsset); 316 | } 317 | AssetDatabase.SaveAssets(); 318 | AssetDatabase.Refresh(); 319 | } 320 | 321 | private static string GetMaterialName(Material material){ 322 | string name = material.name; 323 | if (name.StartsWith("Material/")){ 324 | // embedded under graph 325 | name = name.Substring(9); 326 | } 327 | return name; 328 | } 329 | 330 | #endregion 331 | } 332 | 333 | } -------------------------------------------------------------------------------- /Bake Shader Vertex Pos.shadersubgraph: -------------------------------------------------------------------------------- 1 | { 2 | "m_SGVersion": 3, 3 | "m_Type": "UnityEditor.ShaderGraph.GraphData", 4 | "m_ObjectId": "76aa642b7444478ebe97285115cafd8b", 5 | "m_Properties": [], 6 | "m_Keywords": [ 7 | { 8 | "m_Id": "b0450df66e154606914921987653863e" 9 | } 10 | ], 11 | "m_Dropdowns": [], 12 | "m_CategoryData": [ 13 | { 14 | "m_Id": "646943c5d8ad420e98c49a420e591d24" 15 | } 16 | ], 17 | "m_Nodes": [ 18 | { 19 | "m_Id": "9d34c665e72a4aadab8ec67933d502ac" 20 | }, 21 | { 22 | "m_Id": "1f97701daa4b40bdac30c29b98989e65" 23 | }, 24 | { 25 | "m_Id": "471bb10210464785959e015a51546be9" 26 | }, 27 | { 28 | "m_Id": "204a8531a05a4d289cf54c7df51baeee" 29 | }, 30 | { 31 | "m_Id": "0ae9179ec18f4dcd96c6e4bd2874ff8e" 32 | }, 33 | { 34 | "m_Id": "e408a10a970a49cf9889c43ab9295516" 35 | }, 36 | { 37 | "m_Id": "72eb995d805c45849efa096314cd7f9d" 38 | } 39 | ], 40 | "m_GroupDatas": [], 41 | "m_StickyNoteDatas": [], 42 | "m_Edges": [ 43 | { 44 | "m_OutputSlot": { 45 | "m_Node": { 46 | "m_Id": "0ae9179ec18f4dcd96c6e4bd2874ff8e" 47 | }, 48 | "m_SlotId": 2 49 | }, 50 | "m_InputSlot": { 51 | "m_Node": { 52 | "m_Id": "72eb995d805c45849efa096314cd7f9d" 53 | }, 54 | "m_SlotId": 0 55 | } 56 | }, 57 | { 58 | "m_OutputSlot": { 59 | "m_Node": { 60 | "m_Id": "1f97701daa4b40bdac30c29b98989e65" 61 | }, 62 | "m_SlotId": 0 63 | }, 64 | "m_InputSlot": { 65 | "m_Node": { 66 | "m_Id": "9d34c665e72a4aadab8ec67933d502ac" 67 | }, 68 | "m_SlotId": 1 69 | } 70 | }, 71 | { 72 | "m_OutputSlot": { 73 | "m_Node": { 74 | "m_Id": "204a8531a05a4d289cf54c7df51baeee" 75 | }, 76 | "m_SlotId": 2 77 | }, 78 | "m_InputSlot": { 79 | "m_Node": { 80 | "m_Id": "0ae9179ec18f4dcd96c6e4bd2874ff8e" 81 | }, 82 | "m_SlotId": 0 83 | } 84 | }, 85 | { 86 | "m_OutputSlot": { 87 | "m_Node": { 88 | "m_Id": "471bb10210464785959e015a51546be9" 89 | }, 90 | "m_SlotId": 0 91 | }, 92 | "m_InputSlot": { 93 | "m_Node": { 94 | "m_Id": "204a8531a05a4d289cf54c7df51baeee" 95 | }, 96 | "m_SlotId": 0 97 | } 98 | }, 99 | { 100 | "m_OutputSlot": { 101 | "m_Node": { 102 | "m_Id": "72eb995d805c45849efa096314cd7f9d" 103 | }, 104 | "m_SlotId": 1 105 | }, 106 | "m_InputSlot": { 107 | "m_Node": { 108 | "m_Id": "1f97701daa4b40bdac30c29b98989e65" 109 | }, 110 | "m_SlotId": 1 111 | } 112 | }, 113 | { 114 | "m_OutputSlot": { 115 | "m_Node": { 116 | "m_Id": "e408a10a970a49cf9889c43ab9295516" 117 | }, 118 | "m_SlotId": 0 119 | }, 120 | "m_InputSlot": { 121 | "m_Node": { 122 | "m_Id": "1f97701daa4b40bdac30c29b98989e65" 123 | }, 124 | "m_SlotId": 2 125 | } 126 | } 127 | ], 128 | "m_VertexContext": { 129 | "m_Position": { 130 | "x": 0.0, 131 | "y": 0.0 132 | }, 133 | "m_Blocks": [] 134 | }, 135 | "m_FragmentContext": { 136 | "m_Position": { 137 | "x": 0.0, 138 | "y": 0.0 139 | }, 140 | "m_Blocks": [] 141 | }, 142 | "m_PreviewData": { 143 | "serializedMesh": { 144 | "m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}", 145 | "m_Guid": "" 146 | }, 147 | "preventRotation": false 148 | }, 149 | "m_Path": "Sub Graphs", 150 | "m_GraphPrecision": 1, 151 | "m_PreviewMode": 2, 152 | "m_OutputNode": { 153 | "m_Id": "9d34c665e72a4aadab8ec67933d502ac" 154 | }, 155 | "m_ActiveTargets": [] 156 | } 157 | 158 | { 159 | "m_SGVersion": 0, 160 | "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", 161 | "m_ObjectId": "06ac7bea4d40416e94f3c6991e50a102", 162 | "m_Id": 1, 163 | "m_DisplayName": "On", 164 | "m_SlotType": 0, 165 | "m_Hidden": false, 166 | "m_ShaderOutputName": "On", 167 | "m_StageCapability": 3, 168 | "m_Value": { 169 | "x": 0.0, 170 | "y": 0.0, 171 | "z": 0.0, 172 | "w": 0.0 173 | }, 174 | "m_DefaultValue": { 175 | "x": 0.0, 176 | "y": 0.0, 177 | "z": 0.0, 178 | "w": 0.0 179 | } 180 | } 181 | 182 | { 183 | "m_SGVersion": 0, 184 | "m_Type": "UnityEditor.ShaderGraph.SubtractNode", 185 | "m_ObjectId": "0ae9179ec18f4dcd96c6e4bd2874ff8e", 186 | "m_Group": { 187 | "m_Id": "" 188 | }, 189 | "m_Name": "Subtract", 190 | "m_DrawState": { 191 | "m_Expanded": true, 192 | "m_Position": { 193 | "serializedVersion": "2", 194 | "x": 56.99997329711914, 195 | "y": -108.0, 196 | "width": 130.00001525878907, 197 | "height": 118.0 198 | } 199 | }, 200 | "m_Slots": [ 201 | { 202 | "m_Id": "3ae630e131cf424c84caed29e193b361" 203 | }, 204 | { 205 | "m_Id": "6116db7535ee411e9bd54341a9a5e6e4" 206 | }, 207 | { 208 | "m_Id": "d3486d34d8cd4a1dbbf7d8fa75ac11bb" 209 | } 210 | ], 211 | "synonyms": [ 212 | "subtraction", 213 | "remove", 214 | "minus", 215 | "take away" 216 | ], 217 | "m_Precision": 0, 218 | "m_PreviewExpanded": false, 219 | "m_PreviewMode": 0, 220 | "m_CustomColors": { 221 | "m_SerializableColors": [] 222 | } 223 | } 224 | 225 | { 226 | "m_SGVersion": 0, 227 | "m_Type": "UnityEditor.ShaderGraph.KeywordNode", 228 | "m_ObjectId": "1f97701daa4b40bdac30c29b98989e65", 229 | "m_Group": { 230 | "m_Id": "" 231 | }, 232 | "m_Name": "BakeShaderKeyword", 233 | "m_DrawState": { 234 | "m_Expanded": true, 235 | "m_Position": { 236 | "serializedVersion": "2", 237 | "x": 423.9999694824219, 238 | "y": -27.999984741210939, 239 | "width": 183.00003051757813, 240 | "height": 118.0 241 | } 242 | }, 243 | "m_Slots": [ 244 | { 245 | "m_Id": "38f78c6f27b54e17abaa7bbde5c0fdb3" 246 | }, 247 | { 248 | "m_Id": "06ac7bea4d40416e94f3c6991e50a102" 249 | }, 250 | { 251 | "m_Id": "e976e99b033341bca1bc8c4403a0ba23" 252 | } 253 | ], 254 | "synonyms": [], 255 | "m_Precision": 0, 256 | "m_PreviewExpanded": false, 257 | "m_PreviewMode": 0, 258 | "m_CustomColors": { 259 | "m_SerializableColors": [] 260 | }, 261 | "m_Keyword": { 262 | "m_Id": "b0450df66e154606914921987653863e" 263 | } 264 | } 265 | 266 | { 267 | "m_SGVersion": 0, 268 | "m_Type": "UnityEditor.ShaderGraph.MultiplyNode", 269 | "m_ObjectId": "204a8531a05a4d289cf54c7df51baeee", 270 | "m_Group": { 271 | "m_Id": "" 272 | }, 273 | "m_Name": "Multiply", 274 | "m_DrawState": { 275 | "m_Expanded": true, 276 | "m_Position": { 277 | "serializedVersion": "2", 278 | "x": -97.00003051757813, 279 | "y": -159.0, 280 | "width": 129.99998474121095, 281 | "height": 117.99999237060547 282 | } 283 | }, 284 | "m_Slots": [ 285 | { 286 | "m_Id": "77f4f8dd7dcf4b97a3fe7a72c8848c67" 287 | }, 288 | { 289 | "m_Id": "c2a806b70e7c46a8a8394d1016820e12" 290 | }, 291 | { 292 | "m_Id": "9432d54415bb42fb845ac4dc0c00068e" 293 | } 294 | ], 295 | "synonyms": [ 296 | "multiplication", 297 | "times", 298 | "x" 299 | ], 300 | "m_Precision": 0, 301 | "m_PreviewExpanded": false, 302 | "m_PreviewMode": 0, 303 | "m_CustomColors": { 304 | "m_SerializableColors": [] 305 | } 306 | } 307 | 308 | { 309 | "m_SGVersion": 0, 310 | "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", 311 | "m_ObjectId": "38f78c6f27b54e17abaa7bbde5c0fdb3", 312 | "m_Id": 0, 313 | "m_DisplayName": "ShaderBake", 314 | "m_SlotType": 1, 315 | "m_Hidden": false, 316 | "m_ShaderOutputName": "Out", 317 | "m_StageCapability": 3, 318 | "m_Value": { 319 | "x": 0.0, 320 | "y": 0.0, 321 | "z": 0.0, 322 | "w": 0.0 323 | }, 324 | "m_DefaultValue": { 325 | "x": 0.0, 326 | "y": 0.0, 327 | "z": 0.0, 328 | "w": 0.0 329 | } 330 | } 331 | 332 | { 333 | "m_SGVersion": 0, 334 | "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", 335 | "m_ObjectId": "3ae630e131cf424c84caed29e193b361", 336 | "m_Id": 0, 337 | "m_DisplayName": "A", 338 | "m_SlotType": 0, 339 | "m_Hidden": false, 340 | "m_ShaderOutputName": "A", 341 | "m_StageCapability": 3, 342 | "m_Value": { 343 | "x": 1.0, 344 | "y": 1.0, 345 | "z": 1.0, 346 | "w": 1.0 347 | }, 348 | "m_DefaultValue": { 349 | "x": 0.0, 350 | "y": 0.0, 351 | "z": 0.0, 352 | "w": 0.0 353 | } 354 | } 355 | 356 | { 357 | "m_SGVersion": 0, 358 | "m_Type": "UnityEditor.ShaderGraph.UVNode", 359 | "m_ObjectId": "471bb10210464785959e015a51546be9", 360 | "m_Group": { 361 | "m_Id": "" 362 | }, 363 | "m_Name": "UV", 364 | "m_DrawState": { 365 | "m_Expanded": true, 366 | "m_Position": { 367 | "serializedVersion": "2", 368 | "x": -266.0000305175781, 369 | "y": -223.0, 370 | "width": 145.00001525878907, 371 | "height": 129.0 372 | } 373 | }, 374 | "m_Slots": [ 375 | { 376 | "m_Id": "5fc934945f474eda9007998befdd2472" 377 | } 378 | ], 379 | "synonyms": [ 380 | "texcoords", 381 | "coords", 382 | "coordinates" 383 | ], 384 | "m_Precision": 0, 385 | "m_PreviewExpanded": false, 386 | "m_PreviewMode": 0, 387 | "m_CustomColors": { 388 | "m_SerializableColors": [] 389 | }, 390 | "m_OutputChannel": 0 391 | } 392 | 393 | { 394 | "m_SGVersion": 0, 395 | "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", 396 | "m_ObjectId": "5fc934945f474eda9007998befdd2472", 397 | "m_Id": 0, 398 | "m_DisplayName": "Out", 399 | "m_SlotType": 1, 400 | "m_Hidden": false, 401 | "m_ShaderOutputName": "Out", 402 | "m_StageCapability": 3, 403 | "m_Value": { 404 | "x": 0.0, 405 | "y": 0.0, 406 | "z": 0.0, 407 | "w": 0.0 408 | }, 409 | "m_DefaultValue": { 410 | "x": 0.0, 411 | "y": 0.0, 412 | "z": 0.0, 413 | "w": 0.0 414 | }, 415 | "m_Labels": [] 416 | } 417 | 418 | { 419 | "m_SGVersion": 0, 420 | "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", 421 | "m_ObjectId": "6116db7535ee411e9bd54341a9a5e6e4", 422 | "m_Id": 1, 423 | "m_DisplayName": "B", 424 | "m_SlotType": 0, 425 | "m_Hidden": false, 426 | "m_ShaderOutputName": "B", 427 | "m_StageCapability": 3, 428 | "m_Value": { 429 | "x": 1.0, 430 | "y": 1.0, 431 | "z": 1.0, 432 | "w": 1.0 433 | }, 434 | "m_DefaultValue": { 435 | "x": 0.0, 436 | "y": 0.0, 437 | "z": 0.0, 438 | "w": 0.0 439 | } 440 | } 441 | 442 | { 443 | "m_SGVersion": 0, 444 | "m_Type": "UnityEditor.ShaderGraph.CategoryData", 445 | "m_ObjectId": "646943c5d8ad420e98c49a420e591d24", 446 | "m_Name": "", 447 | "m_ChildObjectList": [ 448 | { 449 | "m_Id": "b0450df66e154606914921987653863e" 450 | } 451 | ] 452 | } 453 | 454 | { 455 | "m_SGVersion": 1, 456 | "m_Type": "UnityEditor.ShaderGraph.TransformNode", 457 | "m_ObjectId": "72eb995d805c45849efa096314cd7f9d", 458 | "m_Group": { 459 | "m_Id": "" 460 | }, 461 | "m_Name": "Transform", 462 | "m_DrawState": { 463 | "m_Expanded": true, 464 | "m_Position": { 465 | "serializedVersion": "2", 466 | "x": 186.99998474121095, 467 | "y": -108.0, 468 | "width": 211.99998474121095, 469 | "height": 157.0 470 | } 471 | }, 472 | "m_Slots": [ 473 | { 474 | "m_Id": "c1db8f2780d042d6ab53026936560f74" 475 | }, 476 | { 477 | "m_Id": "f8399802853643139c14901f1ca45245" 478 | } 479 | ], 480 | "synonyms": [ 481 | "world", 482 | "tangent", 483 | "object", 484 | "view", 485 | "screen", 486 | "convert" 487 | ], 488 | "m_Precision": 0, 489 | "m_PreviewExpanded": false, 490 | "m_PreviewMode": 0, 491 | "m_CustomColors": { 492 | "m_SerializableColors": [] 493 | }, 494 | "m_Conversion": { 495 | "from": 2, 496 | "to": 0 497 | }, 498 | "m_ConversionType": 0 499 | } 500 | 501 | { 502 | "m_SGVersion": 0, 503 | "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", 504 | "m_ObjectId": "77f4f8dd7dcf4b97a3fe7a72c8848c67", 505 | "m_Id": 0, 506 | "m_DisplayName": "A", 507 | "m_SlotType": 0, 508 | "m_Hidden": false, 509 | "m_ShaderOutputName": "A", 510 | "m_StageCapability": 3, 511 | "m_Value": { 512 | "e00": 0.0, 513 | "e01": 0.0, 514 | "e02": 0.0, 515 | "e03": 0.0, 516 | "e10": 0.0, 517 | "e11": 0.0, 518 | "e12": 0.0, 519 | "e13": 0.0, 520 | "e20": 0.0, 521 | "e21": 0.0, 522 | "e22": 0.0, 523 | "e23": 0.0, 524 | "e30": 0.0, 525 | "e31": 0.0, 526 | "e32": 0.0, 527 | "e33": 0.0 528 | }, 529 | "m_DefaultValue": { 530 | "e00": 1.0, 531 | "e01": 0.0, 532 | "e02": 0.0, 533 | "e03": 0.0, 534 | "e10": 0.0, 535 | "e11": 1.0, 536 | "e12": 0.0, 537 | "e13": 0.0, 538 | "e20": 0.0, 539 | "e21": 0.0, 540 | "e22": 1.0, 541 | "e23": 0.0, 542 | "e30": 0.0, 543 | "e31": 0.0, 544 | "e32": 0.0, 545 | "e33": 1.0 546 | } 547 | } 548 | 549 | { 550 | "m_SGVersion": 0, 551 | "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", 552 | "m_ObjectId": "9432d54415bb42fb845ac4dc0c00068e", 553 | "m_Id": 2, 554 | "m_DisplayName": "Out", 555 | "m_SlotType": 1, 556 | "m_Hidden": false, 557 | "m_ShaderOutputName": "Out", 558 | "m_StageCapability": 3, 559 | "m_Value": { 560 | "e00": 0.0, 561 | "e01": 0.0, 562 | "e02": 0.0, 563 | "e03": 0.0, 564 | "e10": 0.0, 565 | "e11": 0.0, 566 | "e12": 0.0, 567 | "e13": 0.0, 568 | "e20": 0.0, 569 | "e21": 0.0, 570 | "e22": 0.0, 571 | "e23": 0.0, 572 | "e30": 0.0, 573 | "e31": 0.0, 574 | "e32": 0.0, 575 | "e33": 0.0 576 | }, 577 | "m_DefaultValue": { 578 | "e00": 1.0, 579 | "e01": 0.0, 580 | "e02": 0.0, 581 | "e03": 0.0, 582 | "e10": 0.0, 583 | "e11": 1.0, 584 | "e12": 0.0, 585 | "e13": 0.0, 586 | "e20": 0.0, 587 | "e21": 0.0, 588 | "e22": 1.0, 589 | "e23": 0.0, 590 | "e30": 0.0, 591 | "e31": 0.0, 592 | "e32": 0.0, 593 | "e33": 1.0 594 | } 595 | } 596 | 597 | { 598 | "m_SGVersion": 0, 599 | "m_Type": "UnityEditor.ShaderGraph.SubGraphOutputNode", 600 | "m_ObjectId": "9d34c665e72a4aadab8ec67933d502ac", 601 | "m_Group": { 602 | "m_Id": "" 603 | }, 604 | "m_Name": "Output", 605 | "m_DrawState": { 606 | "m_Expanded": true, 607 | "m_Position": { 608 | "serializedVersion": "2", 609 | "x": 607.0, 610 | "y": -28.0, 611 | "width": 121.0, 612 | "height": 77.0 613 | } 614 | }, 615 | "m_Slots": [ 616 | { 617 | "m_Id": "a43563bbf242484ca69667c8c733a67e" 618 | } 619 | ], 620 | "synonyms": [], 621 | "m_Precision": 0, 622 | "m_PreviewExpanded": true, 623 | "m_PreviewMode": 0, 624 | "m_CustomColors": { 625 | "m_SerializableColors": [] 626 | }, 627 | "IsFirstSlotValid": true 628 | } 629 | 630 | { 631 | "m_SGVersion": 0, 632 | "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", 633 | "m_ObjectId": "a43563bbf242484ca69667c8c733a67e", 634 | "m_Id": 1, 635 | "m_DisplayName": "Out_Vector3", 636 | "m_SlotType": 0, 637 | "m_Hidden": false, 638 | "m_ShaderOutputName": "OutVector3", 639 | "m_StageCapability": 3, 640 | "m_Value": { 641 | "x": 0.0, 642 | "y": 0.0, 643 | "z": 0.0 644 | }, 645 | "m_DefaultValue": { 646 | "x": 0.0, 647 | "y": 0.0, 648 | "z": 0.0 649 | }, 650 | "m_Labels": [] 651 | } 652 | 653 | { 654 | "m_SGVersion": 1, 655 | "m_Type": "UnityEditor.ShaderGraph.ShaderKeyword", 656 | "m_ObjectId": "b0450df66e154606914921987653863e", 657 | "m_Guid": { 658 | "m_GuidSerialized": "dc2ad95a-fb25-4262-a613-fd47735479f9" 659 | }, 660 | "m_Name": "BakeShaderKeyword", 661 | "m_DefaultRefNameVersion": 1, 662 | "m_RefNameGeneratedByDisplayName": "BakeShaderKeyword", 663 | "m_DefaultReferenceName": "_BAKESHADERKEYWORD", 664 | "m_OverrideReferenceName": "_BAKESHADER", 665 | "m_GeneratePropertyBlock": true, 666 | "m_UseCustomSlotLabel": false, 667 | "m_CustomSlotLabel": "", 668 | "m_KeywordType": 0, 669 | "m_KeywordDefinition": 1, 670 | "m_KeywordScope": 1, 671 | "m_KeywordStages": 63, 672 | "m_Entries": [], 673 | "m_Value": 0, 674 | "m_IsEditable": true 675 | } 676 | 677 | { 678 | "m_SGVersion": 0, 679 | "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", 680 | "m_ObjectId": "c1db8f2780d042d6ab53026936560f74", 681 | "m_Id": 0, 682 | "m_DisplayName": "In", 683 | "m_SlotType": 0, 684 | "m_Hidden": false, 685 | "m_ShaderOutputName": "In", 686 | "m_StageCapability": 3, 687 | "m_Value": { 688 | "x": 0.0, 689 | "y": 0.0, 690 | "z": 0.0 691 | }, 692 | "m_DefaultValue": { 693 | "x": 0.0, 694 | "y": 0.0, 695 | "z": 0.0 696 | }, 697 | "m_Labels": [] 698 | } 699 | 700 | { 701 | "m_SGVersion": 0, 702 | "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", 703 | "m_ObjectId": "c2a806b70e7c46a8a8394d1016820e12", 704 | "m_Id": 1, 705 | "m_DisplayName": "B", 706 | "m_SlotType": 0, 707 | "m_Hidden": false, 708 | "m_ShaderOutputName": "B", 709 | "m_StageCapability": 3, 710 | "m_Value": { 711 | "e00": 2.0, 712 | "e01": 2.0, 713 | "e02": 2.0, 714 | "e03": 2.0, 715 | "e10": 2.0, 716 | "e11": 2.0, 717 | "e12": 2.0, 718 | "e13": 2.0, 719 | "e20": 2.0, 720 | "e21": 2.0, 721 | "e22": 2.0, 722 | "e23": 2.0, 723 | "e30": 2.0, 724 | "e31": 2.0, 725 | "e32": 2.0, 726 | "e33": 2.0 727 | }, 728 | "m_DefaultValue": { 729 | "e00": 1.0, 730 | "e01": 0.0, 731 | "e02": 0.0, 732 | "e03": 0.0, 733 | "e10": 0.0, 734 | "e11": 1.0, 735 | "e12": 0.0, 736 | "e13": 0.0, 737 | "e20": 0.0, 738 | "e21": 0.0, 739 | "e22": 1.0, 740 | "e23": 0.0, 741 | "e30": 0.0, 742 | "e31": 0.0, 743 | "e32": 0.0, 744 | "e33": 1.0 745 | } 746 | } 747 | 748 | { 749 | "m_SGVersion": 0, 750 | "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", 751 | "m_ObjectId": "d3486d34d8cd4a1dbbf7d8fa75ac11bb", 752 | "m_Id": 2, 753 | "m_DisplayName": "Out", 754 | "m_SlotType": 1, 755 | "m_Hidden": false, 756 | "m_ShaderOutputName": "Out", 757 | "m_StageCapability": 3, 758 | "m_Value": { 759 | "x": 0.0, 760 | "y": 0.0, 761 | "z": 0.0, 762 | "w": 0.0 763 | }, 764 | "m_DefaultValue": { 765 | "x": 0.0, 766 | "y": 0.0, 767 | "z": 0.0, 768 | "w": 0.0 769 | } 770 | } 771 | 772 | { 773 | "m_SGVersion": 0, 774 | "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", 775 | "m_ObjectId": "de0bdb37f7e34e2fb97c5d290e5045d5", 776 | "m_Id": 0, 777 | "m_DisplayName": "Out", 778 | "m_SlotType": 1, 779 | "m_Hidden": false, 780 | "m_ShaderOutputName": "Out", 781 | "m_StageCapability": 3, 782 | "m_Value": { 783 | "x": 0.0, 784 | "y": 0.0, 785 | "z": 0.0 786 | }, 787 | "m_DefaultValue": { 788 | "x": 0.0, 789 | "y": 0.0, 790 | "z": 0.0 791 | }, 792 | "m_Labels": [] 793 | } 794 | 795 | { 796 | "m_SGVersion": 1, 797 | "m_Type": "UnityEditor.ShaderGraph.PositionNode", 798 | "m_ObjectId": "e408a10a970a49cf9889c43ab9295516", 799 | "m_Group": { 800 | "m_Id": "" 801 | }, 802 | "m_Name": "Position", 803 | "m_DrawState": { 804 | "m_Expanded": true, 805 | "m_Position": { 806 | "serializedVersion": "2", 807 | "x": 193.00001525878907, 808 | "y": 57.99999237060547, 809 | "width": 206.0000457763672, 810 | "height": 131.00003051757813 811 | } 812 | }, 813 | "m_Slots": [ 814 | { 815 | "m_Id": "de0bdb37f7e34e2fb97c5d290e5045d5" 816 | } 817 | ], 818 | "synonyms": [ 819 | "location" 820 | ], 821 | "m_Precision": 1, 822 | "m_PreviewExpanded": false, 823 | "m_PreviewMode": 2, 824 | "m_CustomColors": { 825 | "m_SerializableColors": [] 826 | }, 827 | "m_Space": 0, 828 | "m_PositionSource": 0 829 | } 830 | 831 | { 832 | "m_SGVersion": 0, 833 | "m_Type": "UnityEditor.ShaderGraph.DynamicVectorMaterialSlot", 834 | "m_ObjectId": "e976e99b033341bca1bc8c4403a0ba23", 835 | "m_Id": 2, 836 | "m_DisplayName": "Off", 837 | "m_SlotType": 0, 838 | "m_Hidden": false, 839 | "m_ShaderOutputName": "Off", 840 | "m_StageCapability": 3, 841 | "m_Value": { 842 | "x": 0.0, 843 | "y": 0.0, 844 | "z": 0.0, 845 | "w": 0.0 846 | }, 847 | "m_DefaultValue": { 848 | "x": 0.0, 849 | "y": 0.0, 850 | "z": 0.0, 851 | "w": 0.0 852 | } 853 | } 854 | 855 | { 856 | "m_SGVersion": 0, 857 | "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", 858 | "m_ObjectId": "f8399802853643139c14901f1ca45245", 859 | "m_Id": 1, 860 | "m_DisplayName": "Out", 861 | "m_SlotType": 1, 862 | "m_Hidden": false, 863 | "m_ShaderOutputName": "Out", 864 | "m_StageCapability": 3, 865 | "m_Value": { 866 | "x": 0.0, 867 | "y": 0.0, 868 | "z": 0.0 869 | }, 870 | "m_DefaultValue": { 871 | "x": 0.0, 872 | "y": 0.0, 873 | "z": 0.0 874 | }, 875 | "m_Labels": [] 876 | } 877 | 878 | --------------------------------------------------------------------------------