Skip to content

Commit

Permalink
Material shader assembly system (v0.6.5) (#32)
Browse files Browse the repository at this point in the history
- Generate material shaders from a unified material template.
- Delete every Material subclasses, hard-coded gbuffer shaders, and corresponding render pass classes.
  • Loading branch information
codeonwort committed Sep 27, 2022
1 parent 5231b39 commit 622f1d8
Show file tree
Hide file tree
Showing 98 changed files with 2,493 additions and 1,906 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ OpenGL rendering library (for 3d graphics study)
* Asynchronous asset loader
* Runtime shader recompilation
* Actor system (component-based development)
* Material shader assembly system

## Sample Images

Expand Down
19 changes: 6 additions & 13 deletions projects/PathosEngine/PathosEngine.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
<ClCompile Include="src\pathos\loader\spline_loader.cpp" />
<ClCompile Include="src\pathos\mesh\model_transform.cpp" />
<ClCompile Include="src\pathos\mesh\static_mesh_component.cpp" />
<ClCompile Include="src\pathos\named_object.cpp" />
<ClCompile Include="src\pathos\engine.cpp" />
<ClCompile Include="src\pathos\light\shadow_directional.cpp" />
<ClCompile Include="src\pathos\loader\imageloader.cpp" />
Expand All @@ -129,11 +128,6 @@
<ClCompile Include="src\pathos\overlay\display_object_proxy.cpp" />
<ClCompile Include="src\pathos\overlay\label.cpp" />
<ClCompile Include="src\pathos\overlay\rectangle.cpp" />
<ClCompile Include="src\pathos\render\deferred\deferredpass_pack_alphaonly.cpp" />
<ClCompile Include="src\pathos\render\deferred\deferredpass_pack_base.cpp" />
<ClCompile Include="src\pathos\render\deferred\deferredpass_pack_pbr.cpp" />
<ClCompile Include="src\pathos\render\deferred\deferredpass_pack_solidcolor.cpp" />
<ClCompile Include="src\pathos\render\deferred\deferredpass_pack_wireframe.cpp" />
<ClCompile Include="src\pathos\render\direct_lighting.cpp" />
<ClCompile Include="src\pathos\render\depth_prepass.cpp" />
<ClCompile Include="src\pathos\render\forward\translucency_rendering.cpp" />
Expand All @@ -155,6 +149,7 @@
<ClCompile Include="src\pathos\render\render_device.cpp" />
<ClCompile Include="src\pathos\render\render_overlay.cpp" />
<ClCompile Include="src\pathos\render\render_target.cpp" />
<ClCompile Include="src\pathos\render\resolve_unlit.cpp" />
<ClCompile Include="src\pathos\render\scene_proxy.cpp" />
<ClCompile Include="src\pathos\render\screen_space_reflection.cpp" />
<ClCompile Include="src\pathos\render\sky_atmosphere.cpp" />
Expand All @@ -165,6 +160,8 @@
<ClCompile Include="src\pathos\render\sky_ansel.cpp" />
<ClCompile Include="src\pathos\render\visualize_buffer.cpp" />
<ClCompile Include="src\pathos\scene\scene_capture_component.cpp" />
<ClCompile Include="src\pathos\shader\material_shader.cpp" />
<ClCompile Include="src\pathos\shader\material_shader_assembler.cpp" />
<ClCompile Include="src\pathos\shader\shader_program.cpp" />
<ClCompile Include="src\pathos\texture\volume_texture.cpp" />
<ClCompile Include="src\pathos\text\font_mgr.cpp" />
Expand Down Expand Up @@ -239,7 +236,6 @@
<ClInclude Include="src\pathos\mesh\model_transform.h" />
<ClInclude Include="src\pathos\mesh\static_mesh_actor.h" />
<ClInclude Include="src\pathos\mesh\static_mesh_component.h" />
<ClInclude Include="src\pathos\named_object.h" />
<ClInclude Include="src\pathos\core_minimal.h" />
<ClInclude Include="src\pathos\engine.h" />
<ClInclude Include="src\pathos\light\light_all.h" />
Expand All @@ -251,7 +247,6 @@
<ClInclude Include="src\pathos\overlay\display_object_proxy.h" />
<ClInclude Include="src\pathos\overlay\label.h" />
<ClInclude Include="src\pathos\overlay\rectangle.h" />
<ClInclude Include="src\pathos\render\deferred\deferredpass_pack_alphaonly.h" />
<ClInclude Include="src\pathos\render\depth_prepass.h" />
<ClInclude Include="src\pathos\render\forward\translucency_rendering.h" />
<ClInclude Include="src\pathos\render\indirect_lighting.h" />
Expand All @@ -270,13 +265,16 @@
<ClInclude Include="src\pathos\render\render_command_list.h" />
<ClInclude Include="src\pathos\render\render_device.h" />
<ClInclude Include="src\pathos\render\render_target.h" />
<ClInclude Include="src\pathos\render\resolve_unlit.h" />
<ClInclude Include="src\pathos\render\scene_proxy.h" />
<ClInclude Include="src\pathos\render\screen_space_reflection.h" />
<ClInclude Include="src\pathos\render\sky_atmosphere.h" />
<ClInclude Include="src\pathos\render\sky_clouds.h" />
<ClInclude Include="src\pathos\scene\scene_render_settings.h" />
<ClInclude Include="src\pathos\render\scene_render_targets.h" />
<ClInclude Include="src\pathos\scene\scene_capture_component.h" />
<ClInclude Include="src\pathos\shader\material_shader.h" />
<ClInclude Include="src\pathos\shader\material_shader_assembler.h" />
<ClInclude Include="src\pathos\shader\shader_program.h" />
<ClInclude Include="src\pathos\shader\shader_storage_buffer.h" />
<ClInclude Include="src\pathos\smart_pointer.h" />
Expand All @@ -292,11 +290,6 @@
<ClInclude Include="src\pathos\util\gl_debug_group.h" />
<ClInclude Include="src\pathos\util\math_lib.h" />
<ClInclude Include="src\pathos\util\renderdoc_integration.h" />
<ClInclude Include="src\pathos\render\deferred\deferredpass.h" />
<ClInclude Include="src\pathos\render\deferred\deferredpass_pack_base.h" />
<ClInclude Include="src\pathos\render\deferred\deferredpass_pack_pbr.h" />
<ClInclude Include="src\pathos\render\deferred\deferredpass_pack_solidcolor.h" />
<ClInclude Include="src\pathos\render\deferred\deferredpass_pack_wireframe.h" />
<ClInclude Include="src\pathos\render\direct_lighting.h" />
<ClInclude Include="src\pathos\render\postprocessing\depth_of_field.h" />
<ClInclude Include="src\pathos\render\sky.h" />
Expand Down
57 changes: 18 additions & 39 deletions projects/PathosEngine/PathosEngine.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,9 @@
<ClCompile Include="src\pathos\render\render_deferred.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\render\deferred\deferredpass_pack_base.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\render\deferred\deferredpass_pack_solidcolor.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\render\direct_lighting.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\render\deferred\deferredpass_pack_wireframe.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\text\font_mgr.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
Expand Down Expand Up @@ -135,9 +126,6 @@
<ClCompile Include="src\pathos\render\overlay\overlaypass_text.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\render\deferred\deferredpass_pack_pbr.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\console.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
Expand All @@ -150,9 +138,6 @@
<ClCompile Include="src\pathos\render\visualize_buffer.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\named_object.cpp">
<Filter>소스 파일\pathos</Filter>
</ClCompile>
<ClCompile Include="src\pathos\render\skybox.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
Expand Down Expand Up @@ -324,9 +309,6 @@
<ClCompile Include="src\pathos\text\text_component.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\render\deferred\deferredpass_pack_alphaonly.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\util\engine_util.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
Expand Down Expand Up @@ -357,6 +339,15 @@
<ClCompile Include="src\pathos\overlay\display_object_proxy.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\shader\material_shader_assembler.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\shader\material_shader.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="src\pathos\render\resolve_unlit.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\pathos\mesh\geometry.h">
Expand Down Expand Up @@ -404,21 +395,9 @@
<ClInclude Include="src\pathos\render\render_deferred.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\render\deferred\deferredpass_pack_solidcolor.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\render\deferred\deferredpass_pack_base.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\render\deferred\deferredpass.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\render\direct_lighting.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\render\deferred\deferredpass_pack_wireframe.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\text\font_mgr.h">
<Filter>헤더 파일</Filter>
</ClInclude>
Expand Down Expand Up @@ -458,9 +437,6 @@
<ClInclude Include="src\pathos\render\overlay\overlaypass_text.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\render\deferred\deferredpass_pack_pbr.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\console.h">
<Filter>헤더 파일</Filter>
</ClInclude>
Expand All @@ -485,9 +461,6 @@
<ClInclude Include="src\pathos\shader\uniform_buffer.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\named_object.h">
<Filter>헤더 파일\pathos</Filter>
</ClInclude>
<ClInclude Include="src\pathos\render_minimal.h">
<Filter>헤더 파일</Filter>
</ClInclude>
Expand Down Expand Up @@ -734,9 +707,6 @@
<ClInclude Include="src\pathos\text\text_component.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\render\deferred\deferredpass_pack_alphaonly.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\thread\render_thread.h">
<Filter>헤더 파일</Filter>
</ClInclude>
Expand Down Expand Up @@ -782,5 +752,14 @@
<ClInclude Include="src\pathos\light\rect_light_actor.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\shader\material_shader_assembler.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\shader\material_shader.h">
<Filter>헤더 파일</Filter>
</ClInclude>
<ClInclude Include="src\pathos\render\resolve_unlit.h">
<Filter>헤더 파일</Filter>
</ClInclude>
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions projects/PathosEngine/src/badger/types/vector_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ using vector4i = glm::ivec4;
using vector2ui = glm::uvec2;
using vector3ui = glm::uvec3;
using vector4ui = glm::uvec4;

using vector2b = glm::bvec2;
using vector3b = glm::bvec3;
using vector4b = glm::bvec4;
3 changes: 3 additions & 0 deletions projects/PathosEngine/src/pathos/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "pathos/util/renderdoc_integration.h"
#include "pathos/overlay/display_object_proxy.h"
#include "pathos/overlay/display_object.h"
#include "pathos/shader/material_shader_assembler.h"

#include "pathos/loader/imageloader.h" // subsystem: image loader
#include "pathos/text/font_mgr.h" // subsystem: font manager
Expand Down Expand Up @@ -145,6 +146,8 @@ namespace pathos {
gConsole->addLine(line.c_str(), false);
}

MaterialShaderAssembler::get().initializeMaterialShaders();

LOG(LogInfo, "=== PATHOS has been initialized ===");
LOG(LogInfo, "");

Expand Down
2 changes: 1 addition & 1 deletion projects/PathosEngine/src/pathos/engine_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
*/
#define PATHOS_MAJOR_VERSION 0
#define PATHOS_MINOR_VERSION 6
#define PATHOS_PATCH_VERSION 4
#define PATHOS_PATCH_VERSION 5
1 change: 1 addition & 0 deletions projects/PathosEngine/src/pathos/loader/asset_streamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace pathos {
CHECK(loader);

arg->loader = loader;
loader->setMaterialOverrides(std::move(arg->materialOverrides));
loader->load(arg->filepath, arg->mtlDir);

streamer->mutex_loadedOBJs.lock();
Expand Down
17 changes: 17 additions & 0 deletions projects/PathosEngine/src/pathos/loader/asset_streamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@

#include <list>
#include <mutex>
#include <vector>
#include <string>
#include <utility>
#include <functional>

namespace pathos {

class AssetStreamer;
class OBJLoader;
class Material;

using WavefrontOBJHandler = std::function<void(OBJLoader* objLoader, uint64 payload)>;

Expand All @@ -34,8 +38,19 @@ namespace pathos {
, baseDir(inBaseDir)
{
}
void addMaterialOverride(const std::string& mtlName, Material* newMaterial) {
for (auto& v : materialOverrides) {
if (v.first == mtlName) {
v.second = newMaterial;
return;
}
}
materialOverrides.push_back(std::make_pair(mtlName, newMaterial));
}

const char* filepath;
const char* baseDir;
std::vector<std::pair<std::string, Material*>> materialOverrides;
};

//////////////////////////////////////////////////////////////////////////
Expand All @@ -54,6 +69,7 @@ namespace pathos {
OBJLoader* loader;
const char* filepath;
const char* mtlDir;
std::vector<std::pair<std::string, Material*>> materialOverrides;

uint64 payload;
};
Expand Down Expand Up @@ -123,6 +139,7 @@ namespace pathos {
arg->streamer = this;
arg->filepath = assetRef.filepath;
arg->mtlDir = assetRef.baseDir;
arg->materialOverrides = assetRef.materialOverrides;

arg->payload = payload;

Expand Down

0 comments on commit 622f1d8

Please sign in to comment.