TDME2 1.9.121
ShadowMapRenderShaderFoliageImplementation.cpp
Go to the documentation of this file.
2
3#include <string>
4
5#include <tdme/tdme.h>
11
12using std::to_string;
13
20
21bool ShadowMapRenderShaderFoliageImplementation::isSupported(Renderer* renderer) {
22 return true;
23}
24
26{
27}
28
30{
31}
32
34 return "foliage";
35}
36
38{
39 auto shaderVersion = renderer->getShaderVersion();
40
41 // load shadow mapping shaders
44 "shader/" + shaderVersion + "/shadowmapping",
45 "render_vertexshader.vert",
46 "#define HAVE_FOLIAGE",
47 FileSystem::getInstance()->getContentAsString(
48 "shader/" + shaderVersion + "/functions",
49 "create_rotation_matrix.inc.glsl"
50 ) +
51 "\n\n" +
52 FileSystem::getInstance()->getContentAsString(
53 "shader/" + shaderVersion + "/functions",
54 "create_translation_matrix.inc.glsl"
55 ) +
56 "\n\n" +
57 FileSystem::getInstance()->getContentAsString(
58 "shader/" + shaderVersion + "/functions",
59 "create_foliage_transform_matrix.inc.glsl"
60 )
61 );
62 if (vertexShaderId == 0) return;
63
66 "shader/" + shaderVersion + "/shadowmapping",
67 "render_fragmentshader.frag"
68 );
69 if (fragmentShaderId == 0) return;
70
71 // create shadow mapping render program
75
77
78 //
79 if (initialized == false) return;
80
81 //
82 if (initialized == false) return;
83
84 // uniforms
88}
89
91 auto& shaderParameters = renderer->getShaderParameters(contextIdx);
92 if (uniformSpeed != -1) renderer->setProgramUniformFloat(contextIdx, uniformSpeed, shaderParameters.getShaderParameter("speed").getFloatValue());
93 if (uniformAmplitudeDefault != -1) renderer->setProgramUniformFloat(contextIdx, uniformAmplitudeDefault, shaderParameters.getShaderParameter("amplitudeDefault").getFloatValue());
94 if (uniformAmplitudeMax != -1) renderer->setProgramUniformFloat(contextIdx, uniformAmplitudeMax, shaderParameters.getShaderParameter("amplitudeMax").getFloatValue());
95}
TDME2 engine entity shader parameters.
Shader parameter model class.
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.
virtual void updateShaderParameters(Renderer *renderer, int contextIdx) override
Update shader parameters.
File system singleton class.
Definition: FileSystem.h:14