Пример #1
0
        static void ExportSkyToImage()
        {
            HDRenderPipelineInstance renderpipelineInstance = UnityEngine.Experimental.Rendering.RenderPipelineManager.currentPipeline as HDRenderPipelineInstance;

            if (renderpipelineInstance == null)
            {
                Debug.LogError("HDRenderPipeline is not instantiated.");
                return;
            }

            Texture2D result = renderpipelineInstance.ExportSkyToTexture();

            if (result == null)
            {
                return;
            }

            // Encode texture into PNG
            byte[] bytes = null;
            bytes = result.EncodeToEXR(Texture2D.EXRFlags.CompressZIP);
            Object.DestroyImmediate(result);

            string assetPath = EditorUtility.SaveFilePanel("Export Sky", "Assets", "SkyExport", "exr");

            if (!string.IsNullOrEmpty(assetPath))
            {
                File.WriteAllBytes(assetPath, bytes);
                AssetDatabase.Refresh();
            }
        }
Пример #2
0
        protected void ShaderSSSInputGUI(Material material)
        {
            HDRenderPipelineInstance hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipelineInstance;

            if (subsurfaceProfile == null)
            {
                // Attempt to load the profile from the SSS Settings.
                int profileID = (int)subsurfaceProfileID.floatValue;

                if (0 <= profileID && profileID < hdPipeline.sssSettings.profiles.Length &&
                    hdPipeline.sssSettings.profiles[profileID] != null)
                {
                    // This is a valid profile ID.
                    subsurfaceProfile = hdPipeline.sssSettings.profiles[profileID];

                    // Refresh the ID of the profile.
                    hdPipeline.sssSettings.OnValidate();
                }
            }

            subsurfaceProfile = EditorGUILayout.ObjectField(Styles.subsurfaceProfileText, subsurfaceProfile, typeof(SubsurfaceScatteringProfile), false) as SubsurfaceScatteringProfile;

            bool validProfile = false;

            // Set the profile ID.
            if (subsurfaceProfile != null)
            {
                // Load the profile from the GUI field.
                int profileID = subsurfaceProfile.settingsIndex;

                if (0 <= profileID && profileID < hdPipeline.sssSettings.profiles.Length)
                {
                    validProfile = true;
                    material.SetInt("_SubsurfaceProfile", profileID);
                }
                else
                {
                    subsurfaceProfile = null;
                    Debug.LogError("The SSS Profile assigned to the material has an invalid index. First, add the Profile to the SSS Settings, and then reassign it to the material.");
                }
            }

            if (!validProfile)
            {
                // Disable SSS for this object.
                material.SetInt("_SubsurfaceProfile", SubsurfaceScatteringSettings.neutralProfileID);
            }

            m_MaterialEditor.ShaderProperty(subsurfaceRadius, Styles.subsurfaceRadiusText);
            m_MaterialEditor.TexturePropertySingleLine(Styles.subsurfaceRadiusMapText, subsurfaceRadiusMap);
            m_MaterialEditor.ShaderProperty(thickness, Styles.thicknessText);
            m_MaterialEditor.TexturePropertySingleLine(Styles.thicknessMapText, thicknessMap);
        }