TDME2 1.9.121
ShadowMapCreationShaderFoliageImplementation.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 ShadowMapCreationShaderFoliageImplementation::isSupported(Renderer* renderer) {
22 return true;
23}
24
26{
27}
28
30}
31
33 return "foliage";
34}
35
37{
38 auto shaderVersion = renderer->getShaderVersion();
39
40 // load shadow mapping creation shaders
43 "shader/" + shaderVersion + "/shadowmapping",
44 "creation_vertexshader.vert",
45 "#define HAVE_FOLIAGE",
46 FileSystem::getInstance()->getContentAsString(
47 "shader/" + shaderVersion + "/functions",
48 "create_rotation_matrix.inc.glsl"
49 ) +
50 "\n\n" +
51 FileSystem::getInstance()->getContentAsString(
52 "shader/" + shaderVersion + "/functions",
53 "create_translation_matrix.inc.glsl"
54 ) +
55 "\n\n" +
56 FileSystem::getInstance()->getContentAsString(
57 "shader/" + shaderVersion + "/functions",
58 "create_foliage_transform_matrix.inc.glsl"
59 )
60 );
61 if (vertexShaderId == 0) return;
64 "shader/" + shaderVersion + "/shadowmapping",
65 "creation_fragmentshader.frag"
66 );
67 if (fragmentShaderId == 0) return;
68
69 // create shadow map creation program
73
74 //
76
77 //
78 if (initialized == false) return;
79
80 // uniforms
84}
85
87 auto& shaderParameters = renderer->getShaderParameters(contextIdx);
88 if (uniformSpeed != -1) renderer->setProgramUniformFloat(contextIdx, uniformSpeed, shaderParameters.getShaderParameter("speed").getFloatValue());
89 if (uniformAmplitudeDefault != -1) renderer->setProgramUniformFloat(contextIdx, uniformAmplitudeDefault, shaderParameters.getShaderParameter("amplitudeDefault").getFloatValue());
90 if (uniformAmplitudeMax != -1) renderer->setProgramUniformFloat(contextIdx, uniformAmplitudeMax, shaderParameters.getShaderParameter("amplitudeMax").getFloatValue());
91}
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