36 LightingShaderPBRBaseImplementation::LightingShaderPBRBaseImplementation(
Renderer* renderer)
178 if (light.enabled == 0)
return;
260 string environmentType =
"studio_grey";
263 "pbr-environment-diffuse",
264 envDiffuseTextures[0] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/diffuse",
"diffuse_left.png"),
265 envDiffuseTextures[1] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/diffuse",
"diffuse_right.png"),
266 envDiffuseTextures[2] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/diffuse",
"diffuse_top.png"),
267 envDiffuseTextures[3] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/diffuse",
"diffuse_bottom.png"),
268 envDiffuseTextures[4] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/diffuse",
"diffuse_front.png"),
269 envDiffuseTextures[5] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/diffuse",
"diffuse_back.png"),
274 "pbr-environment-specular",
275 envSpecularTextures[0] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/specular",
"specular_left.png"),
276 envSpecularTextures[1] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/specular",
"specular_right.png"),
277 envSpecularTextures[2] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/specular",
"specular_top.png"),
278 envSpecularTextures[3] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/specular",
"specular_bottom.png"),
279 envSpecularTextures[4] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/specular",
"specular_front.png"),
280 envSpecularTextures[5] = TextureReader::read(
"resources/engine/environments/" + environmentType +
"/specular",
"specular_back.png"),
static Engine * getInstance()
Returns engine instance.
static TextureManager * getTextureManager()
static BRDFLUTShader * getBRDFLUTShader()
int32_t getColorTextureId() override
Lighting shader implementation.
int32_t uniformMetallicRoughnessSamplerAvailable
virtual void loadTextures(const string &pathName) override
Load textures.
int32_t uniformViewProjectionMatrix
virtual void updateLight(Renderer *renderer, int contextIdx, int32_t lightId) override
Update light to program.
virtual void updateTextureMatrix(Renderer *renderer, int contextIdx) override
Update texture matrix to program.
virtual void updateMaterial(Renderer *renderer, int contextIdx) override
Update material to program.
int32_t uniformBaseColorFactor
int32_t textureDiffuseEnvSampler
int32_t uniformBaseColorSampler
int32_t uniformNormalScale
virtual void updateMatrices(Renderer *renderer, int contextIdx) override
Update matrices to program.
array< int32_t, Engine::LIGHTS_MAX > uniformLightColor
virtual void initialize() override
Initialize renderer.
int32_t textureSpecularEnvSampler
array< int32_t, Engine::LIGHTS_MAX > uniformLightOuterConeCos
virtual bool isInitialized() override
int32_t uniformMetallicRoughnessSampler
int32_t uniformDiffuseEnvSampler
array< int32_t, Engine::LIGHTS_MAX > uniformLightAmbient
virtual void unloadTextures() override
Unload textures.
virtual void bindTexture(Renderer *renderer, int contextIdx, int32_t textureId) override
Bind texture.
virtual void updateEffect(Renderer *renderer, int contextIdx) override
Update effect to program.
int32_t uniformSpecularEnvSampler
array< Texture *, 6 > envSpecularTextures
virtual void unUseProgram(int contextIdx) override
Unuse lighting program.
array< int32_t, Engine::LIGHTS_MAX > uniformLightRange
int32_t uniformMetallicFactor
virtual void useProgram(Engine *engine, int contextIdx) override
Use lighting program.
int32_t uniformEmissiveFactor
virtual void updateShaderParameters(Renderer *renderer, int contextIdx) override=0
Update shader parameters.
array< int32_t, Engine::LIGHTS_MAX > uniformLightType
int32_t uniformBaseColorSamplerAvailable
int32_t uniformEmissiveSampler
int32_t uniformAlphaCutoffEnabled
array< int32_t, Engine::LIGHTS_MAX > uniformLightPosition
array< int32_t, Engine::LIGHTS_MAX > uniformLightEnabled
array< Texture *, 6 > envDiffuseTextures
int32_t uniformNormalSampler
int32_t uniformRoughnessFactor
int32_t uniformEmissiveSamplerAvailable
array< int32_t, Engine::LIGHTS_MAX > uniformLightInnerConeCos
int32_t uniformAlphaCutoff
array< int32_t, Engine::LIGHTS_MAX > uniformLightDirection
array< int32_t, Engine::LIGHTS_MAX > uniformLightIntensity
int32_t uniformNormalSamplerAvailable
void removeTexture(Texture *texture)
Removes a texture from manager.
int32_t addCubeMapTexture(const string &id, Texture *textureLeft, Texture *textureRight, Texture *textureTop, Texture *textureBottom, Texture *textureFront, Texture *textureBack, int contextIdx=0)
Adds a cube map texture to manager.
virtual void setTextureUnit(int contextIdx, int32_t textureUnit)=0
Sets up texture unit.
virtual void bindCubeMapTexture(int contextIdx, int32_t textureId)=0
Binds a cube map texture with given id or unbinds when using ID_NONE.
virtual void setProgramUniformFloatVec4(int contextIdx, int32_t uniformId, const array< float, 4 > &data)=0
Set up a float vec4 uniform value.
virtual int32_t getTextureUnit(int contextIdx)=0
Get texture unit.
Matrix4x4 & getProjectionMatrix()
virtual void setProgramUniformInteger(int contextIdx, int32_t uniformId, int32_t value)=0
Set up a integer uniform value.
virtual bool linkProgram(int32_t programId)=0
Links attached shaders to a program.
virtual void bindTexture(int contextIdx, int32_t textureId)=0
Binds a texture with given id or unbinds when using ID_NONE.
void setLighting(int contextIdx, int32_t lighting)
Set current lighting model.
virtual void setProgramUniformFloatMatrix4x4(int contextIdx, int32_t uniformId, const array< float, 16 > &value)=0
Set up a float matrix 4x4 uniform value.
virtual int32_t getProgramUniformLocation(int32_t programId, const string &name)=0
Returns location of given uniform variable.
int32_t CONTEXTINDEX_DEFAULT
Matrix4x4 & getCameraMatrix()
Renderer_PBRMaterial & getPBRMaterial(int contextIdx)
Get PBR material.
virtual void useProgram(int contextIdx, int32_t programId)=0
Use shader program.
virtual void setProgramUniformFloatVec3(int contextIdx, int32_t uniformId, const array< float, 3 > &data)=0
Set up a float vec3 uniform value.
Vector3 & getCameraPosition()
virtual void setProgramUniformFloat(int contextIdx, int32_t uniformId, float value)=0
Set up a float uniform value.
Renderer_Light & getLight(int contextIdx, int32_t lightIdx)
Get light.
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Vector3 multiply(const Vector3 &vector3) const
Multiplies this matrix with vector3.
Matrix4x4 & set(float r0c0, float r0c1, float r0c2, float r0c3, float r1c0, float r1c1, float r1c2, float r1c3, float r2c0, float r2c1, float r2c2, float r2c3, float r3c0, float r3c1, float r3c2, float r3c3)
Sets this matrix by its components.
const array< float, 16 > & getArray() const
Vector3 class representing vector3 mathematical structure and operations with x, y,...
const array< float, 3 > & getArray() const
Lighting shader constants.
static constexpr int32_t PBR_TEXTUREUNIT_ENVIRONMENT_DIFFUSE
static constexpr int32_t PBR_TEXTUREUNIT_EMISSIVE
static constexpr int32_t PBR_TEXTUREUNIT_BASECOLOR
static constexpr int32_t PBR_TEXTUREUNIT_METALLICROUGHNESS
static constexpr int32_t PBR_TEXTUREUNIT_ENVIRONMENT_SPECULAR
static constexpr int32_t PBR_TEXTUREUNIT_NORMAL
static constexpr int32_t PBR_TEXTUREUNIT_ENVIRONMENT_BRDF