Просмотр исходного кода

Fixed a bug with scene view where the render texture would get stretched at smaller sizes
Game window now properly displays main camera contents
Newly added cameras are main by default

BearishSun 10 лет назад
Родитель
Сommit
cf708239e6

+ 28 - 5
MBansheeEditor/GameWindow.cs

@@ -19,6 +19,7 @@ namespace BansheeEditor
 
         private int selectedAspectRatio = 0;
         private GUIRenderTexture renderTextureGUI;
+        private GUILabel noCameraLabel;
 
         /// <summary>
         /// Opens the game window.
@@ -78,24 +79,43 @@ namespace BansheeEditor
             for (int i = 0; i < aspectRatios.Length; i++)
                 aspectRatioTitles[i + 1] = aspectRatios[i].width + ":" + aspectRatios[i].height;
 
-            GUIListBoxField aspectField = new GUIListBoxField(aspectRatioTitles, new LocEdString("Aspect ratio"));
+            GUIListBoxField aspectField = new GUIListBoxField(aspectRatioTitles, new LocEdString("Aspect ratio"), 100, GUIOption.FixedWidth(300));
             aspectField.OnSelectionChanged += OnAspectRatioChanged;
             
-            GUILayout buttonLayout = mainLayout.AddLayoutX();
+            GUILayoutY buttonLayoutVert = mainLayout.AddLayoutY();
+            GUILayoutX buttonLayout = buttonLayoutVert.AddLayoutX();
             buttonLayout.AddElement(aspectField);
             buttonLayout.AddFlexibleSpace();
+            buttonLayoutVert.AddFlexibleSpace();
 
             renderTextureGUI = new GUIRenderTexture(null);
+            noCameraLabel = new GUILabel(new LocEdString("(No main camera in scene)"));
 
-            GUILayoutY alignLayoutY = mainLayout.AddLayoutY();
+            GUIPanel rtPanel = mainLayout.AddPanel();
+            rtPanel.AddElement(renderTextureGUI);
+
+            GUILayoutY alignLayoutY = rtPanel.AddLayoutY();
             alignLayoutY.AddFlexibleSpace();
             GUILayoutX alignLayoutX = alignLayoutY.AddLayoutX();
             alignLayoutX.AddFlexibleSpace();
-            alignLayoutX.AddElement(renderTextureGUI);
+            alignLayoutX.AddElement(noCameraLabel);
             alignLayoutX.AddFlexibleSpace();
             alignLayoutY.AddFlexibleSpace();
 
             UpdateRenderTexture(Width, Height);
+
+            bool hasMainCamera = Scene.Camera != null;
+
+            renderTextureGUI.Active = hasMainCamera;
+            noCameraLabel.Active = !hasMainCamera;
+        }
+
+        private void OnEditorUpdate()
+        {
+            bool hasMainCamera = Scene.Camera != null;
+
+            renderTextureGUI.Active = hasMainCamera;
+            noCameraLabel.Active = !hasMainCamera;
         }
 
         private void OnDestroy()
@@ -126,6 +146,9 @@ namespace BansheeEditor
 
             EditorApplication.MainRenderTarget = renderTexture;
             renderTextureGUI.RenderTexture = renderTexture;
+
+            Rect2I rtBounds = new Rect2I(0, 0, width, height);
+            renderTextureGUI.Bounds = rtBounds;
         }
 
         /// <summary>
@@ -141,7 +164,7 @@ namespace BansheeEditor
         /// <inheritdoc/>
         protected override void WindowResized(int width, int height)
         {
-            UpdateRenderTexture(width, height - HeaderHeight);
+            UpdateRenderTexture(width, height);
 
             base.WindowResized(width, height);
         }

+ 5 - 2
MBansheeEditor/MenuItems.cs

@@ -23,7 +23,9 @@ namespace BansheeEditor
                 return;
 
             UndoRedo.RecordSO(so, "Added a Camera component");
-            so.AddComponent<Camera>();
+            Camera cam = so.AddComponent<Camera>();
+            cam.Main = true;
+
             EditorApplication.SetSceneDirty();
         }
 
@@ -111,7 +113,8 @@ namespace BansheeEditor
         private static void AddCameraSO()
         {
             SceneObject so = UndoRedo.CreateSO("Camera", "Created a Camera");
-            so.AddComponent<Camera>();
+            Camera cam = so.AddComponent<Camera>();
+            cam.Main = true;
 
             Selection.SceneObject = so;
             EditorApplication.SetSceneDirty();

+ 7 - 1
MBansheeEditor/Scene/SceneWindow.cs

@@ -30,6 +30,7 @@ namespace BansheeEditor
         private SceneCamera cameraController;
         private RenderTexture2D renderTexture;
         private GUILayoutY mainLayout;
+        private GUIPanel rtPanel;
 
         private GUIRenderTexture renderTextureGUI;
         private SceneViewHandler sceneViewHandler;
@@ -173,6 +174,8 @@ namespace BansheeEditor
             handlesLayout.AddElement(rotateSnapButton);
             handlesLayout.AddElement(rotateSnapInput);
 
+            rtPanel = mainLayout.AddPanel();
+
             toggleProfilerOverlayKey = new VirtualButton(ToggleProfilerOverlayBinding);
             viewToolKey = new VirtualButton(ViewToolBinding);
             moveToolKey = new VirtualButton(MoveToolBinding);
@@ -607,7 +610,7 @@ namespace BansheeEditor
                 cameraController = sceneCameraSO.AddComponent<SceneCamera>();
 
                 renderTextureGUI = new GUIRenderTexture(renderTexture);
-                mainLayout.AddElement(renderTextureGUI);
+                rtPanel.AddElement(renderTextureGUI);
 
                 sceneViewHandler = new SceneViewHandler(this, camera);
 		    }
@@ -617,6 +620,9 @@ namespace BansheeEditor
 		        renderTextureGUI.RenderTexture = renderTexture;
 		    }
 
+            Rect2I rtBounds = new Rect2I(0, 0, width, height);
+            renderTextureGUI.Bounds = rtBounds;
+
 		    // TODO - Consider only doing the resize once user stops resizing the widget in order to reduce constant
 		    // render target destroy/create cycle for every single pixel.
 

+ 1 - 1
RenderBeast/Include/BsRenderBeastOptions.h

@@ -53,7 +53,7 @@ namespace BansheeEngine
 		 * is then converted into visible colors using a tone mapping operator depending
 		 * on average scene brightness.
 		 */
-		bool hdr = true;
+		bool hdr = false;
 
 		/**
 		 * Controls if and how a render queue groups renderable objects by material in 

+ 1 - 0
TODO.txt

@@ -55,6 +55,7 @@ Optional:
 
 Seriously optional:
  - Drag to select in scene view
+ - When starting play-in-editor, automatically make the Game Window active
  - Automatically generate readable inspector names and add [Name] attribute that allows custom naming
  - Add Range[] attribute to C# that forces a float/int to be displayed as a slider
  - GUI tabbing to switch between elements

+ 4 - 0
TODOExperimentation.txt

@@ -14,6 +14,8 @@ Assign ViewOrigin, PreViewTranslation, TransViewProj
  - Do this after I have basic rendering working, to avoid additional issues when I'm initially trying to get it to work
  
 Later:
+ - Output skylight color in base pass (hook up color buffer as well as gbuffer as render target so I can output scene color)
+  - For now just use a constant color, later add a SH environment map lookup
  - Lights already existing in scene on load don't seem to render (seems they get converted to point lights for some reason)
  - I changed how unsupported texture formats work, I should test if I didn't break OpenGL
  - When rendering lights right now I need to bind Gbuffer and light parameters to material, and then bind the material parameters to the pipeline
@@ -36,6 +38,8 @@ Notes:
  - Will need to ensure the code works in OpenGL (means porting shaders or building the cross compiler). I cannot delay 
    this as later it will be hard to debug when the pipeline is more complex.
  - Consider having a debug toggle that makes the gbuffer use floating point storage, to compare quality quickly
+ - I'll need to add sky-lighting and perhaps other form of pre-computed lighting. Base pass should output colors resulting
+   from those operations during its base pass.
 
 Generate different RenderableController for each set of elements
  - Will likely want to rename current LitTexRenderableController to OpaqueSomething