示例#1
0
        // Exports all non-experimental brushes along with their material parameters
        // into a directory structure suitable for submission to
        // google3/googledata/html/external_content/tiltbrush.com/shaders/brushes
        //
        // Input:
        //   Non-experimental brushes (from Assets/Manifest.asset)
        //   Their materials and shaders
        //
        // Output:
        //   An ExportManifest, writen to manifestPath
        //   An ExportRequests instance
        //
        // The manifest is consumed by Tilt Brush at export time, and should not
        // be uploaded to Poly or be served by it.
        //
        // The ExportRequests is processed by a texture downsampler; see DownsampleTextures()
        //
        // Shaders are not generated here; see GenerateShaders()
        //
        private static ExportRequests WriteManifest(
            string manifestPath, string exportRoot)
        {
            ExportRequests exportRequests = new ExportRequests();

            Debug.LogFormat("Exporting to: {0}", manifestPath);

            ExportGlTF.ExportManifest          manifest = new ExportGlTF.ExportManifest();
            Dictionary <Guid, BrushDescriptor> brushes;

            using (var unused = new BuildTiltBrush.TempHookUpSingletons())
            {
                manifest.tiltBrushVersion    = App.Config.m_VersionNumber;
                manifest.tiltBrushBuildStamp = App.Config.m_BuildStamp;
                brushes = GetBrushes();
            }

            foreach (KeyValuePair <Guid, BrushDescriptor> kvp in brushes)
            {
                try
                {
                    BrushDescriptor descriptor = kvp.Value;
                    var             exp        = ExportBrush(exportRequests, descriptor, exportRoot);
                    manifest.brushes.Add(exp.guid, exp);

                    // While we're at it, maybe a sanity check of the descriptor is in order
                    if (descriptor.m_RenderBackfaces && !exp.enableCull)
                    {
                        Debug.LogWarning(
                            $"{descriptor.m_DurableName}: generates backface geometry, but disables culling",
                            descriptor);
                    }
                }
                catch (ExportException e)
                {
                    Debug.LogException(e);
                } // foreach Brush + try
            }
            var serializer = new JsonSerializer();

            serializer.ContractResolver = new CustomJsonContractResolver();
            using (var writer = new CustomJsonWriter(new StreamWriter(manifestPath)))
            {
                writer.Formatting = Formatting.Indented;
                serializer.Serialize(writer, manifest);
            }

            return(exportRequests);
        }
示例#2
0
        // Input: the exportRequests
        // Output: downsampled textures, to subdirectories of exportRoot
        private static void ExportTextures(ExportRequests exportRequests)
        {
            string projectPath  = Path.GetDirectoryName(Application.dataPath);
            string requestsJson = Path.Combine(projectPath, "Temp/ExportRequests.json");
            var    serializer   = new JsonSerializer();

            serializer.ContractResolver = new CustomJsonContractResolver();
            using (var writer = new CustomJsonWriter(new StreamWriter(requestsJson))) {
                writer.Formatting = Formatting.Indented;
                serializer.Serialize(writer, exportRequests);
            }

            string scriptPath = Path.Combine(projectPath, "Support/bin/gltf_export_textures.py");

            RunCommand("python", scriptPath, requestsJson);
        }