TDME2 1.9.121
LightingShaderPBRDefaultImplementation.cpp
Go to the documentation of this file.
2
3#include <string>
4
5#include <tdme/tdme.h>
11
12using std::string;
13using std::to_string;
14
21
22bool LightingShaderPBRDefaultImplementation::isSupported(Renderer* renderer) {
23 return renderer->isPBRAvailable();
24}
25
27{
28}
29
31 return "pbr-default";
32}
33
35{
36 auto shaderVersion = renderer->getShaderVersion();
37
38 // lighting
39 // vertex shader
42 "shader/" + shaderVersion + "/lighting/pbr",
43 "render_vertexshader.vert",
44 string() +
45 "#define LIGHT_COUNT " + to_string(Engine::LIGHTS_MAX) + "\n#define USE_PUNCTUAL\n#define MATERIAL_METALLICROUGHNESS\n#define USE_IBL\n"
46 );
47 if (vertexShaderId == 0) return;
48
49 // fragment shader
52 "shader/" + shaderVersion + "/lighting/pbr",
53 "render_fragmentshader.frag",
54 string() +
55 "#define LIGHT_COUNT " + to_string(Engine::LIGHTS_MAX) + "\n#define USE_PUNCTUAL\n#define MATERIAL_METALLICROUGHNESS\n#define USE_IBL\n",
56 FileSystem::getInstance()->getContentAsString(
57 "shader/" + shaderVersion + "/functions/pbr",
58 "tonemapping.inc.glsl"
59 ) +
60 "\n\n" +
61 FileSystem::getInstance()->getContentAsString(
62 "shader/" + shaderVersion + "/functions/pbr",
63 "textures.inc.glsl"
64 ) +
65 "\n\n" +
66 FileSystem::getInstance()->getContentAsString(
67 "shader/" + shaderVersion + "/functions/pbr",
68 "functions.inc.glsl"
69 ) +
70 "\n\n" +
71 FileSystem::getInstance()->getContentAsString(
72 "shader/" + shaderVersion + "/functions/pbr",
73 "pbr_lighting.inc.glsl"
74 ) +
75 "\n\n"
76 );
77 if (fragmentShaderId == 0) return;
78
79 // create, attach and link program
83
84 //
86}
87
89 Engine::registerShader(Engine::ShaderType::SHADERTYPE_OBJECT3D, getId());
90}
91
93}
Engine main class.
Definition: Engine.h:122
static void registerShader(ShaderType type, const string &shaderId, const map< string, ShaderParameter > &parameterDefaults={})
Register shader.
Definition: Engine.cpp:2122
static constexpr int LIGHTS_MAX
Definition: Engine.h:173
virtual void updateShaderParameters(Renderer *renderer, int contextIdx) override
Update shader parameters.
virtual int32_t loadShader(int32_t type, const string &pathName, const string &fileName, const string &definitions=string(), const string &functions=string())=0
Loads a shader.
virtual int32_t createProgram(int type)=0
Creates a shader program.
virtual void attachShaderToProgram(int32_t programId, int32_t shaderId)=0
Attaches a shader to a program.
File system singleton class.
Definition: FileSystem.h:14