Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Pipeline & Add Texture Mapping #13

Merged
merged 19 commits into from
Sep 21, 2024

Conversation

ZzzhHe
Copy link
Contributor

@ZzzhHe ZzzhHe commented Sep 15, 2024

Description

This pull request includes several key enhancements:

  • Optimized Triangle Drawing Algorithm: Improved performance in triangle rasterization.
  • Refactored Shader Structure: Restructured shaders for better clarity and maintainability.
  • Abstracted the Rasterizer: Introduced an abstraction layer to enhance modularity.
  • Introduced Uniform Buffer System: Implemented a system for efficient management of shader uniforms.
  • Modularized the Pipeline: Aligned the rendering pipeline more closely with OpenGL's structure for improved programmability.
  • Implemented Texture Mapping for Diffuse and Specular Components: Enhanced visual realism by supporting texture mapping.
  • Optimized Texture Loading: Eliminated redundant texture loading to improve efficiency.
  • Camera System: Implement a simple and controllable camera system.
  • Swap Buffer and Real-time Display: Introduced a swap buffer system to facilitate real-time rendering and display. By implementing double buffering, the rendering pipeline now supports smooth frame transitions and reduces visual artifacts such as flickering.

Screenshot 2024-09-14 at 20 04 55

Test Platform

macOS 14.5
Linux (Ubuntu 20.04)

TODO:

  • Optimize performance for smoother real-time rendering.
  • Implement normal mapping.
  • Update comments, documentation and README.

ZzzhHe added 12 commits August 27, 2024 15:14
Signed-off-by: ZhuohaoHe <[email protected]>
…d a uniform buffer, and modularized the pipeline to align more closely with OpenGL's structure and improve clarity and programmability.

Signed-off-by: ZhuohaoHe <[email protected]>
Signed-off-by: ZhuohaoHe <[email protected]>
@ZzzhHe ZzzhHe requested a review from MRNIU September 15, 2024 00:05
CMakeLists.txt Outdated
@@ -45,6 +45,8 @@ set(LOG_FILE_PATH "${EXECUTABLE_OUTPUT_PATH}/logs/SimpleRendererLog.log")
set(LOG_FILE_MAX_SIZE 1024*1024*4)
# 日志文件数量
set(LOG_FILE_MAX_COUNT 8)
#Debug Type (for cmake debug)
set(CMAKE_BUILD_TYPE "Debug")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个改到 CMakePresets.json 吧

size_t height_;
size_t size_;
std::unique_ptr<uint32_t[]> framebuffer_1_;
std::unique_ptr<uint32_t[]> framebuffer_2_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个能不能写成 vector 或者 array 的形式,方便拓展

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是要把uint32_t[]替换为vector吗?因为我感觉uint32_t[]更加直观用起来也简单


glm::mat4 GetProjectionMatrix(float fov, float aspectRatio, float nearPlane,
float farPlane) const {
return glm::perspective(glm::radians(fov), aspectRatio, nearPlane,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个和 lookAt 我们把算法暴露出来吧,这也算是个知识点

glm::vec3 newFront;
newFront.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch));
newFront.y = sin(glm::radians(pitch));
newFront.z = sin(glm::radians(yaw)) * cos(glm::radians(pitch));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sin cos 加上 std::

#include "stb_image.h"

namespace simple_renderer {
Texture Texture::LoadTextureFromFile(const std::string& path) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不是有构造析构吗,为啥还要专门实现一个方法

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为这个函数是个static函数,直接从文件中加载材质,然后返回一个材质。到处都可以直接用,不需要专门创建一个Texture对象。

@MRNIU MRNIU merged commit ce72d6c into Simple-XX:main Sep 21, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants