Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Assets/Textures/Editor/folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Assets/Textures/Editor/shader.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ include_directories(includes)
set(IMGUI_SRC
${CMAKE_CURRENT_SOURCE_DIR}/includes/ImGUI/imgui_impl_glfw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/includes/ImGUI/imgui_impl_opengl3.cpp
${CMAKE_CURRENT_SOURCE_DIR}/includes/ImGUI/imgui.cpp
${CMAKE_CURRENT_SOURCE_DIR}/includes/ImGUI/imgui_widgets.cpp
${CMAKE_CURRENT_SOURCE_DIR}/includes/ImGUI/imgui_draw.cpp
${CMAKE_CURRENT_SOURCE_DIR}/includes/ImGUI/imgui_tables.cpp
)

set(IMGUIZMO_SRC
Expand Down
2 changes: 2 additions & 0 deletions ICE/Core/include/ICEEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class ICEEngine {
std::shared_ptr<Framebuffer> getInternalFramebuffer() const;
void setRenderFramebufferInternal(bool use_internal);

std::shared_ptr<Window> getWindow() const;

private:
std::shared_ptr<GraphicsFactory> m_graphics_factory;
std::shared_ptr<Context> ctx;
Expand Down
10 changes: 7 additions & 3 deletions ICE/Core/src/ICEEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ void ICEEngine::step() {
}

void ICEEngine::setupScene(const std::shared_ptr<Camera> &camera_) {
auto renderer = std::make_shared<ForwardRenderer>(api, m_graphics_factory, project->getCurrentScene()->getRegistry(), project->getAssetBank());
auto rs = std::make_shared<RenderSystem>();
auto renderer = std::make_shared<ForwardRenderer>(api, m_graphics_factory);
auto rs = std::make_shared<RenderSystem>(api, m_graphics_factory, project->getCurrentScene()->getRegistry(), project->getAssetBank());
rs->setCamera(camera_);
rs->setRenderer(renderer);
project->getCurrentScene()->getRegistry()->addSystem(rs);

camera = camera_;
auto [w, h] = m_window->getSize();
renderer->resize(w, h);
}
Expand Down Expand Up @@ -80,6 +80,10 @@ void ICEEngine::setRenderFramebufferInternal(bool use_internal) {
}
}

std::shared_ptr<Window> ICEEngine::getWindow() const {
return m_window;
}

void ICEEngine::setProject(const std::shared_ptr<Project> &project) {
this->project = project;
this->camera->getPosition() = project->getCameraPosition();
Expand Down
28 changes: 9 additions & 19 deletions ICE/Graphics/include/ForwardRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,36 @@ namespace ICE {

class ForwardRenderer : public Renderer {
public:
ForwardRenderer(const std::shared_ptr<RendererAPI>& api, const std::shared_ptr<GraphicsFactory>& factory,
const std::shared_ptr<Registry>& registry, const std::shared_ptr<AssetBank>& assetBank);
ForwardRenderer(const std::shared_ptr<RendererAPI>& api, const std::shared_ptr<GraphicsFactory>& factory);

void submit(Entity e) override;
void remove(Entity e) override;
void submitSkybox(const Skybox& e) override;
void submitDrawable(const Drawable& e) override;
void submitLight(const Light& e) override;

void prepareFrame(Camera& camera) override;

void render() override;
std::shared_ptr<Framebuffer> render() override;

void endFrame() override;

void setTarget(const std::shared_ptr<Framebuffer>& fb) override;

void resize(uint32_t width, uint32_t height) override;

void setClearColor(Eigen::Vector4f clearColor) override;
void setViewport(int x, int y, int w, int h) override;

private:
void submitModel(int node_idx, const std::vector<Model::Node>& nodes, const std::vector<std::shared_ptr<Mesh>>& meshes,
const std::vector<AssetUID>& materials, const Eigen::Matrix4f& transform);

std::shared_ptr<RendererAPI> m_api;
std::shared_ptr<Registry> m_registry;
std::shared_ptr<AssetBank> m_asset_bank;

std::shared_ptr<Framebuffer> target = nullptr;
std::vector<RenderCommand> m_render_commands;
std::vector<Entity> m_render_queue;
std::vector<Entity> m_lights;
AssetUID m_skybox = NO_ASSET_ID;

GeometryPass m_geometry_pass;

std::shared_ptr<VertexArray> m_quad_vao;

std::shared_ptr<UniformBuffer> m_camera_ubo;
std::shared_ptr<UniformBuffer> m_light_ubo;

std::optional<Skybox> m_skybox;
std::vector<Drawable> m_drawables;
std::vector<Light> m_lights;

RendererConfig config;
};
} // namespace ICE
3 changes: 3 additions & 0 deletions ICE/Graphics/include/Material.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class Material : public Asset {
}
}

void renameUniform(const std::string& previous_name, const std::string& new_name);
void removeUniform(const std::string& name);

std::unordered_map<std::string, UniformValue> getAllUniforms() const;
AssetUID getShader() const;
void setShader(AssetUID shader_id);
Expand Down
3 changes: 3 additions & 0 deletions ICE/Graphics/include/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class Model : public Asset {
void setSkeleton(const Skeleton &skeleton) { m_skeleton = skeleton; }
void setAnimations(const std::unordered_map<std::string, Animation> &animations) { m_animations = animations; }

void traverse(std::vector<std::shared_ptr<Mesh>> &meshes, std::vector<AssetUID> &materials, std::vector<Eigen::Matrix4f> &transforms,
const Eigen::Matrix4f &base_transform = Eigen::Matrix4f::Identity());

AssetType getType() const override { return AssetType::EModel; }
std::string getTypeName() const override { return "Model"; }

Expand Down
3 changes: 3 additions & 0 deletions ICE/Graphics/include/RenderCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "Material.h"
#include "Mesh.h"
#include "Shader.h"
#include "Model.h"

namespace ICE {
struct RenderCommand {
Expand All @@ -19,6 +20,8 @@ struct RenderCommand {
std::unordered_map<AssetUID, std::shared_ptr<Texture>> textures;
Eigen::Matrix4f model_matrix;

std::vector<Model::BoneInfo> bones;

bool faceCulling = true;
bool depthTest = true;
};
Expand Down
31 changes: 27 additions & 4 deletions ICE/Graphics/include/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,37 @@ struct alignas(16) CameraUBO {
Eigen::Matrix4f view;
};

struct Skybox {
std::shared_ptr<Mesh> cube_mesh;
std::shared_ptr<Shader> shader;
std::unordered_map<AssetUID, std::shared_ptr<Texture>> textures;
};

struct Drawable {
std::shared_ptr<Mesh> mesh;
std::shared_ptr<Material> material;
std::shared_ptr<Shader> shader;
std::unordered_map<AssetUID, std::shared_ptr<Texture>> textures;
Eigen::Matrix4f model_matrix;
Model::Skeleton skeleton;
};

struct Light {
Eigen::Vector3f position;
Eigen::Vector3f rotation;
Eigen::Vector3f color;
float distance_dropoff;
LightType type;
};

class Renderer {
public:
virtual void submit(Entity e) = 0;
virtual void remove(Entity e) = 0;
virtual void submitSkybox(const Skybox& e) = 0;
virtual void submitDrawable(const Drawable& e) = 0;
virtual void submitLight(const Light& e) = 0;
virtual void prepareFrame(Camera &camera) = 0;
virtual void render() = 0;
virtual std::shared_ptr<Framebuffer> render() = 0;
virtual void endFrame() = 0;
virtual void setTarget(const std::shared_ptr<Framebuffer> &target) = 0;
virtual void resize(uint32_t width, uint32_t height) = 0;
virtual void setClearColor(Eigen::Vector4f clearColor) = 0;
virtual void setViewport(int x, int y, int w, int h) = 0;
Expand Down
Loading
Loading