TDME2 1.9.121
DeferredLightingShaderPBRTreeImplementation.cpp
Go to the documentation of this file.
2
3#include <string>
4
5#include <tdme/tdme.h>
10#include <tdme/engine/Timing.h>
11
14
15using std::string;
16using std::to_string;
17
19
27
28bool DeferredLightingShaderPBRTreeImplementation::isSupported(Renderer* renderer) {
29 return renderer->isDeferredShadingAvailable() == true;
30}
31
33{
34}
35
37 return "defer_pbr-tree";
38}
39
41{
42 auto shaderVersion = renderer->getShaderVersion();
43
44 // lighting
47 "shader/" + shaderVersion + "/lighting/pbr",
48 "render_vertexshader.vert",
49 string() +
50 "#define LIGHT_COUNT " + to_string(Engine::LIGHTS_MAX) + "\n#define USE_PUNCTUAL\n#define MATERIAL_METALLICROUGHNESS\n" +
51 "#define HAVE_TREE\n#define HAVE_DEPTH_FOG\n#define USE_IBL\n",
52 FileSystem::getInstance()->getContentAsString(
53 "shader/" + shaderVersion + "/functions",
54 "create_rotation_matrix.inc.glsl"
55 ) +
56 "\n\n" +
57 FileSystem::getInstance()->getContentAsString(
58 "shader/" + shaderVersion + "/functions",
59 "create_translation_matrix.inc.glsl"
60 ) +
61 "\n\n" +
62 FileSystem::getInstance()->getContentAsString(
63 "shader/" + shaderVersion + "/functions",
64 "create_tree_transform_matrix.inc.glsl"
65 )
66 );
67 if (vertexShaderId == 0) return;
68
69 // fragment shader
72 "shader/" + shaderVersion + "/lighting/pbr",
73 "defer_fragmentshader.frag",
74 "#define LIGHT_COUNT " + to_string(Engine::LIGHTS_MAX) + "\n#define USE_PUNCTUAL\n#define MATERIAL_METALLICROUGHNESS\n#define USE_IBL\n",
75 FileSystem::getInstance()->getContentAsString(
76 "shader/" + shaderVersion + "/functions/pbr",
77 "tonemapping.inc.glsl"
78 ) +
79 "\n\n" +
80 FileSystem::getInstance()->getContentAsString(
81 "shader/" + shaderVersion + "/functions/pbr",
82 "textures.inc.glsl"
83 ) +
84 "\n\n" +
85 FileSystem::getInstance()->getContentAsString(
86 "shader/" + shaderVersion + "/functions/pbr",
87 "functions.inc.glsl"
88 ) +
89 "\n\n" +
90 FileSystem::getInstance()->getContentAsString(
91 "shader/" + shaderVersion + "/functions/pbr",
92 "pbr_lighting.inc.glsl"
93 ) +
94 "\n\n"
95 );
96 if (fragmentShaderId == 0) return;
97
98 // create, attach and link program
102
103 //
105
106 //
107 if (initialized == false) return;
108
109 // uniforms
112}
113
115}
116
118{
120
121 // time
122 if (uniformTime != -1) renderer->setProgramUniformFloat(contextIdx, uniformTime, static_cast<float>(engine->getTiming()->getTotalTime()) / 1000.0f);
123}
124
126 auto& shaderParameters = renderer->getShaderParameters(contextIdx);
127 if (uniformSpeed != -1) renderer->setProgramUniformFloat(contextIdx, uniformSpeed, shaderParameters.getShaderParameter("speed").getFloatValue());
128}
Engine main class.
Definition: Engine.h:122
Timing * getTiming()
Definition: Engine.h:900
static constexpr int LIGHTS_MAX
Definition: Engine.h:173
TDME2 engine entity shader parameters.
Shader parameter model class.
Timing class.
Definition: Timing.h:17
int64_t getTotalTime()
Definition: Timing.h:61
virtual void useProgram(Engine *engine, int contextIdx) override
Use lighting program.
virtual void updateShaderParameters(Renderer *renderer, int contextIdx) override
Update shader parameters.
virtual void useProgram(Engine *engine, int contextIdx) override
Use lighting program.
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.
virtual int32_t getProgramUniformLocation(int32_t programId, const string &name)=0
Returns location of given uniform variable.
const EntityShaderParameters & getShaderParameters(int contextIdx)
Get shader parameters.
Definition: Renderer.h:1194
virtual void setProgramUniformFloat(int contextIdx, int32_t uniformId, float value)=0
Set up a float uniform value.
File system singleton class.
Definition: FileSystem.h:14