Ejemplo n.º 1
0
        Texture2D CreateEnvMapTextureFromResult()
        {
            Assert.IsNotNull(m_ColorCorrect);

            var mat = DelightingService.GetLatLongMaterial(
                vm.latLongA,
                vm.normalsTexture,
                vm.latLongAverage,
                vm.overrideReferenceZone,
                vm.latLongExposure,
                vm.safetyZoneParams,
                true);

            var temporaryRT = RenderTexture.GetTemporary(vm.latLongA.width, vm.latLongA.height, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear);

            GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear);
            Graphics.Blit(null, temporaryRT, mat, 0);

            var           exportedLatLong = new Texture2D(vm.latLongA.width, vm.latLongA.height, TextureFormat.RGBAFloat, false, true);
            RenderTexture previous        = RenderTexture.active;

            RenderTexture.active = temporaryRT;
            exportedLatLong.ReadPixels(new Rect(0, 0, vm.latLongA.width, vm.latLongA.height), 0, 0, false);
            exportedLatLong.Apply();
            RenderTexture.active = previous;
            GL.sRGBWrite         = false;

            return(exportedLatLong);
        }
Ejemplo n.º 2
0
        public override void OnGUI()
        {
            SetValue(kLatLongExposure, EditorGUILayout.Slider(Content.kLatLongExposureLabel, GetValue(kLatLongExposure), 0, 1));

            var latLongA = GetValue(kLatLongA);

            if (latLongA != null)
            {
                var mat = DelightingService.GetLatLongMaterial(
                    latLongA,
                    GetValue(kNormalsTexture),
                    GetValue(kLatLongAverage),
                    GetValue(kOverrideReferenceZone),
                    GetValue(kLatLongExposure),
                    GetValue(kSafetyZoneParams),
                    false);

                var oldRt = RenderTexture.active;
                m_latLongExposed = DelightingHelpers.InstantiateRTIfRequired(m_latLongExposed, latLongA.width, latLongA.height, false, TextureWrapMode.Clamp);
                Graphics.Blit(null, m_latLongExposed, mat);
                RenderTexture.active = oldRt;

                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(Content.kLatLongALabel, EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(Content.kExportLabel))
                {
                    ExecuteCommand(kCmdExportMainEnvMap);
                }
                GUILayout.EndHorizontal();

                EditorGUILayout.Space();

                var rect = GUILayoutUtility.GetAspectRect(latLongA.width / (float)latLongA.height);
                GUI.DrawTexture(rect, m_latLongExposed);
                EditorGUILayout.Space();
            }



            var bakedLut = GetValue(kBakedLUT);

            if (bakedLut != null)
            {
                EditorGUILayout.Space();

                EditorGUILayout.LabelField(Content.kBakedLUTLabel, EditorStyles.boldLabel);

                EditorGUILayout.Space();

                var rect = GUILayoutUtility.GetAspectRect(bakedLut.width / (float)bakedLut.height);
                GUI.DrawTexture(rect, bakedLut);
                EditorGUILayout.Space();
            }
        }
Ejemplo n.º 3
0
        void Awake()
        {
            m_Service = new DelightingService();
            m_Service.vm.PropertyChanged += VmOnPropertyChanged;
            m_Root.dataContext            = m_Service.vm;
            m_Root.RepaintRequested      += Repaint;

            m_Service.vm.displayedUIMode               = prefsDisplayedUIMode;
            m_Service.vm.autoCompute                   = prefsAutoCompute;
            m_Service.vm.baseTextureSuffix             = prefsBaseTextureSuffix;
            m_Service.vm.normalsTextureSuffix          = prefsNormalsTextureSuffix;
            m_Service.vm.bentNormalsTextureSuffix      = prefsBentNormalsTextureSuffix;
            m_Service.vm.ambientOcclusionTextureSuffix = prefsAmbientOcclusionTextureSuffix;
            m_Service.vm.positionsTextureSuffix        = prefsPositionsTextureSuffix;
            m_Service.vm.maskTextureSuffix             = prefsMaskTextureSuffix;
            m_Service.log = new Logger(Debug.logger.logHandler);
            m_Service.log.filterLogType = LogType.Warning;
        }
 public DelightingViewModel(DelightingService service)
 {
     m_Service = service;
     EditorApplication.update += Update;
     PropertyChanged          += OnPropertyChanged;
 }