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); DelightingHelpers.PushSRGBWrite(false); Graphics.Blit(null, temporaryRT, mat, 0); DelightingHelpers.PopSRGBWrite(); 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); }
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); DelightingHelpers.PushSRGBWrite(false); Graphics.Blit(null, m_latLongExposed, mat); DelightingHelpers.PopSRGBWrite(); 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(); } }