Nameless Engine
Loading...
Searching...
No Matches
EngineShaders.hpp
1#pragma once
2
3// Custom.
4#include "shader/ShaderDescription.h"
5#include "misc/ProjectPaths.h"
6#include "shader/general/EngineShaderConstantMacros.hpp"
7#include "shader/general/EngineShaderNames.hpp"
8
9namespace ne {
12 private:
23 static inline std::filesystem::path
24 constructPathToShaderSourceFile(bool bIsHlsl, const std::string& sShaderPathRelativeFinal) {
25 // Prepare language name string.
26 const auto pLanguageName = bIsHlsl ? "hlsl" : "glsl";
27
28 return ProjectPaths::getPathToResDirectory(ResourceDirectory::ENGINE) / "shaders" /
29 pLanguageName / "final" / (sShaderPathRelativeFinal + "." + pLanguageName);
30 }
31
32 public:
33 EngineShaders() = delete;
34
36 struct MeshNode {
44 static inline ShaderDescription getVertexShader(bool bIsHlsl) {
45 return ShaderDescription(
47 constructPathToShaderSourceFile(bIsHlsl, "MeshNode.vert"),
48 ShaderType::VERTEX_SHADER,
49 VertexFormat::MESH_NODE,
50 "main",
51 {});
52 }
53
61 static inline ShaderDescription getFragmentShader(bool bIsHlsl) {
62 return ShaderDescription(
64 constructPathToShaderSourceFile(bIsHlsl, "MeshNode.frag"),
65 ShaderType::FRAGMENT_SHADER,
66 VertexFormat::MESH_NODE,
67 "main",
69 }
70 };
71
73 struct PointLight {
81 static inline ShaderDescription getFragmentShader(bool bIsHlsl) {
82 return ShaderDescription(
84 constructPathToShaderSourceFile(bIsHlsl, "PointLight.frag"),
85 ShaderType::FRAGMENT_SHADER,
86 VertexFormat::MESH_NODE,
87 "main",
89 {"POINT_LIGHT_SHADOW_PASS", ""}});
90 }
91 };
92
94 struct ForwardPlus {
104 return ShaderDescription(
106 constructPathToShaderSourceFile(bIsHlsl, "light_culling/CalculateGridFrustums.comp"),
107 ShaderType::COMPUTE_SHADER,
108 {},
109 "main",
111 }
112
122 return ShaderDescription(
124 constructPathToShaderSourceFile(bIsHlsl, "light_culling/PrepareLightCulling.comp"),
125 ShaderType::COMPUTE_SHADER,
126 {},
127 "main",
128 {});
129 }
130
139 return ShaderDescription(
141 constructPathToShaderSourceFile(bIsHlsl, "light_culling/LightCulling.comp"),
142 ShaderType::COMPUTE_SHADER,
143 {},
144 "main",
148 }
149 };
150 };
151} // namespace ne
Definition: EngineShaders.hpp:11
static std::filesystem::path constructPathToShaderSourceFile(bool bIsHlsl, const std::string &sShaderPathRelativeFinal)
Definition: EngineShaders.hpp:24
static std::filesystem::path getPathToResDirectory()
Definition: ProjectPaths.cpp:123
static std::pair< std::string, std::string > getLightGridTileSizeMacro()
Definition: EngineShaderConstantMacros.hpp:23
static std::pair< std::string, std::string > getAveragePointLightNumPerTileMacro()
Definition: EngineShaderConstantMacros.hpp:35
static std::pair< std::string, std::string > getAverageSpotLightNumPerTileMacro()
Definition: EngineShaderConstantMacros.hpp:47
static std::string getLightCullingComputeShaderName()
Definition: EngineShaderNames.hpp:68
static std::string getCalculateFrustumGridComputeShaderName()
Definition: EngineShaderNames.hpp:49
static std::string getPrepareLightCullingComputeShaderName()
Definition: EngineShaderNames.hpp:59
static std::string getVertexShaderName()
Definition: EngineShaderNames.hpp:20
static std::string getFragmentShaderName()
Definition: EngineShaderNames.hpp:27
static std::string_view getFragmentShaderName()
Definition: EngineShaderNames.hpp:38
Definition: EngineShaders.hpp:94
static ShaderDescription getCalculateGridFrustumComputeShader(bool bIsHlsl)
Definition: EngineShaders.hpp:103
static ShaderDescription getLightCullingComputeShader(bool bIsHlsl)
Definition: EngineShaders.hpp:138
static ShaderDescription getPrepareLightCullingComputeShader(bool bIsHlsl)
Definition: EngineShaders.hpp:121
Definition: EngineShaders.hpp:36
static ShaderDescription getFragmentShader(bool bIsHlsl)
Definition: EngineShaders.hpp:61
static ShaderDescription getVertexShader(bool bIsHlsl)
Definition: EngineShaders.hpp:44
Definition: EngineShaders.hpp:73
static ShaderDescription getFragmentShader(bool bIsHlsl)
Definition: EngineShaders.hpp:81
Definition: ShaderDescription.h:74