Deferred rendering mode + Skybox
- Added deferred rendering mode to the renderer - Added a skybox to the forward rendering mode - moved default imported assets directory (temporary fix)
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								Editor/Assets/Cube.mesh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Editor/Assets/Cube.mesh
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -66,13 +66,9 @@ YAML::Emitter& operator<< (YAML::Emitter& emitter, glm::vec3& vector) {
 | 
			
		||||
			emitter << YAML::Key << "Light";
 | 
			
		||||
			emitter << YAML::Value;
 | 
			
		||||
			emitter << YAML::BeginMap;
 | 
			
		||||
			emitter << YAML::Key << "strength";
 | 
			
		||||
			emitter << YAML::Value << entity.GetComponent<LightComponent>().Strength;
 | 
			
		||||
 | 
			
		||||
			emitter << YAML::Key << "Color";
 | 
			
		||||
			emitter << YAML::Value << entity.GetComponent<LightComponent>().Color;
 | 
			
		||||
			emitter << YAML::EndMap;
 | 
			
		||||
			
 | 
			
		||||
			emitter << YAML::EndMap;	
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -129,7 +125,6 @@ YAML::Emitter& operator<< (YAML::Emitter& emitter, glm::vec3& vector) {
 | 
			
		||||
		}
 | 
			
		||||
		if (entity["Light"]) {
 | 
			
		||||
			LightComponent lc = SE.AddComponent<LightComponent>();
 | 
			
		||||
			lc.Strength = entity["Light"]["strength"].as<float>();
 | 
			
		||||
			lc.Color = glm::vec3(entity["Light"]["Color"][0].as<float>(), entity["Light"]["Color"][1].as<float>(), entity["Light"]["Color"][2].as<float>());
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -106,9 +106,10 @@ public:
 | 
			
		||||
                switch (result) {
 | 
			
		||||
                case(NFD_OKAY):
 | 
			
		||||
                    // Import Model
 | 
			
		||||
                    
 | 
			
		||||
                    AssetManager::LoadFromSource(
 | 
			
		||||
                        path,
 | 
			
		||||
                        project.get()->GetProjectDirectory() / "Assets"
 | 
			
		||||
                        "build/Debug/Assets"//project.get()->GetProjectDirectory() / "Assets"
 | 
			
		||||
                    );
 | 
			
		||||
                    break;
 | 
			
		||||
                case(NFD_CANCEL):
 | 
			
		||||
 | 
			
		||||
@ -19,8 +19,7 @@ using namespace YoggieEngine;
 | 
			
		||||
 | 
			
		||||
auto matrix = glm::mat4(1.0f);
 | 
			
		||||
auto worldOrigin = glm::mat4(1.0f);
 | 
			
		||||
auto projection = glm::perspective(45.0f, 0.89f, 0.001f, 1.0f);
 | 
			
		||||
auto view = glm::mat4(1.0f);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
inline void ComponentView(const std::string& componentName, voidFunction func)
 | 
			
		||||
{
 | 
			
		||||
@ -40,7 +39,7 @@ public:
 | 
			
		||||
 | 
			
		||||
	void AddComponentDropDown(Entity& selected ) 
 | 
			
		||||
    {
 | 
			
		||||
		static char* names[] = { "Script Component", "Camera Component" };
 | 
			
		||||
		static char* names[] = { "Script Component", "Camera Component", "Light Component"};
 | 
			
		||||
        if (ImGui::Button("Add Component"))
 | 
			
		||||
            ImGui::OpenPopup("Component picker");
 | 
			
		||||
 | 
			
		||||
@ -82,25 +81,23 @@ public:
 | 
			
		||||
                ImGui::ColorEdit3("Colour", glm::value_ptr(render3d.color));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        static bool deferred = true;
 | 
			
		||||
        if (selected.HasComponent<LightComponent>()) {
 | 
			
		||||
            auto& light = selected.GetComponent<LightComponent>();
 | 
			
		||||
            if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) {
 | 
			
		||||
                ImGui::DragFloat("Strength", &light.Strength, 0.001f);
 | 
			
		||||
                ImGui::ColorEdit3("Colour", glm::value_ptr(light.Color));
 | 
			
		||||
                ImGui::Checkbox("Deferred", &deferred);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (selected.HasComponent <CameraComponent>()) {
 | 
			
		||||
            auto& camera = selected.GetComponent<CameraComponent>();
 | 
			
		||||
            static float Zoom = 90;
 | 
			
		||||
            static glm::vec3 Position, Rotation = glm::vec3(0.0f);
 | 
			
		||||
            ComponentView("Camera", [] {
 | 
			
		||||
                ImGui::SliderFloat("Zoom", &Zoom, 10, 190);
 | 
			
		||||
            ImGui::InputFloat3("Position:", &Position[0]);
 | 
			
		||||
            ImGui::InputFloat3("Rotation:", &Rotation[0]);
 | 
			
		||||
                });
 | 
			
		||||
            if (ImGui::CollapsingHeader("Camera")) {
 | 
			
		||||
                ImGui::DragFloat3("Position:",glm::value_ptr(camera.Position), 0.01f);
 | 
			
		||||
                ImGui::DragFloat3("Rotation:", glm::value_ptr(camera.Rotation), 0.01f);
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (selected.HasComponent<ScriptComponent>()) {
 | 
			
		||||
@ -131,7 +128,7 @@ public:
 | 
			
		||||
 | 
			
		||||
class Viewport : EditorWindow {
 | 
			
		||||
public:
 | 
			
		||||
    Viewport (Framebuffer& fb, Camera cam ) : EditorWindow("SceneView") 
 | 
			
		||||
    Viewport (Framebuffer& fb, Camera cam) : EditorWindow("SceneView") 
 | 
			
		||||
    {
 | 
			
		||||
        ImVec2 WinPos = ImGui::GetWindowPos();
 | 
			
		||||
        ImVec2 ContentRegionMin = ImGui::GetWindowContentRegionMin();
 | 
			
		||||
@ -149,11 +146,13 @@ public:
 | 
			
		||||
        ImGuizmo::Enable(true);
 | 
			
		||||
        ImGuizmo::SetRect(ScreenSpaceMin.x, ScreenSpaceMin.y,ContentRegionMax.x, ContentRegionMax.y);
 | 
			
		||||
        
 | 
			
		||||
        ImGuizmo::ViewManipulate(glm::value_ptr(cam.ViewMatrix), 1, { ScreenSpaceMin.x,ScreenSpaceMin.y }, { 90,90 }, 0x22CCCCCC);
 | 
			
		||||
        glm::mat4 transposed_view = glm::transpose(cam.ViewMatrix);
 | 
			
		||||
        
 | 
			
		||||
        ImGuizmo::ViewManipulate(glm::value_ptr(transposed_view), 1, { ScreenSpaceMin.x,ScreenSpaceMin.y }, { 90,90 }, 0x22CCCCCC);
 | 
			
		||||
        ImGuizmo::DrawGrid(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), glm::value_ptr(worldOrigin), 100.0f);
 | 
			
		||||
      
 | 
			
		||||
        // Matrix is the model matrix we would want to manipulate
 | 
			
		||||
        ImGuizmo::Manipulate(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(matrix));
 | 
			
		||||
        //ImGuizmo::Manipulate(glm::value_ptr(cam.ViewMatrix), glm::value_ptr(cam.ProjectionMatrix), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(cam.ViewMatrix));
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -14,8 +14,6 @@
 | 
			
		||||
#include "SceneSerializer.h"
 | 
			
		||||
#include "AssetManagement/AssetManager.h"
 | 
			
		||||
#include "UI/MainMenuBar.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
const unsigned int MS_PER_UPDATE = 2;
 | 
			
		||||
void CreateTestProject(std::unique_ptr<Project>& project, Scene& scene);
 | 
			
		||||
 | 
			
		||||
@ -26,6 +24,8 @@ RendererConfig EditorSceneRendererConfig{
 | 
			
		||||
    true // Depth testing  
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
glm::vec3 temp = glm::vec3(0);
 | 
			
		||||
Camera cam = Camera(glm::vec3(12.0f, 1.0f, 0.0f), glm::vec3(45.0f, 0.0f, 0.0f), 90);
 | 
			
		||||
class Editor : public Application {
 | 
			
		||||
public:
 | 
			
		||||
    Editor() 
 | 
			
		||||
@ -46,7 +46,9 @@ public:
 | 
			
		||||
            viewportRenderer.Submit(renderComponent, t);
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
        viewportRenderer.Render();
 | 
			
		||||
        // Render  scene 
 | 
			
		||||
        viewportRenderer.Render(ActiveScene);
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void RenderEditorGUI() {
 | 
			
		||||
@ -120,7 +122,6 @@ public:
 | 
			
		||||
        Physics Physics;
 | 
			
		||||
        //Physics.Demo();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        double previous = glfwGetTime();
 | 
			
		||||
        double lag = 0.0;
 | 
			
		||||
        while (!AppWindow.WindowShouldClose())
 | 
			
		||||
@ -145,6 +146,8 @@ public:
 | 
			
		||||
                lag -= MS_PER_UPDATE;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            
 | 
			
		||||
            RenderScene();
 | 
			
		||||
 | 
			
		||||
            RenderEditorGUI();
 | 
			
		||||
@ -176,7 +179,6 @@ private:
 | 
			
		||||
    std::unique_ptr<Project> CurrentProject;
 | 
			
		||||
    Scene ActiveScene;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
YoggieEngine::Application* CreateApplication() {
 | 
			
		||||
@ -211,8 +213,10 @@ void CreateTestProject(std::unique_ptr<Project>& project, Scene& scene ) {
 | 
			
		||||
    rendercube2.mesh = *(model->renderable->mesh);
 | 
			
		||||
 | 
			
		||||
    // create an ambient light source
 | 
			
		||||
    auto AmbientLight = scene.AddEntity("AmbientLight");
 | 
			
		||||
    auto light = AmbientLight.AddComponent<LightComponent>();
 | 
			
		||||
    light.Color = glm::vec3(1.0f);
 | 
			
		||||
    light.Strength = 1.0f;
 | 
			
		||||
    auto light = scene.AddEntity("Light");
 | 
			
		||||
    auto lightComponent = light.AddComponent<LightComponent>();
 | 
			
		||||
    lightComponent.Color = glm::vec3(1.0f);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user