Skip to content

Vp::PhongShader ​

Shader for lit objects with textures.

#include "Viewport/shader/PhongShader.h"

Inherits from Vp::ObjectShader, Vp::WorldShader, Vp::Shader

Public Types ​

Name
enumLightingModel { PHONG, BLINN_PHONG}

Public Functions ​

Name
PhongShader(GLuint id)
virtual voidinit(bool initSuperclass) override
virtual voidsetUniforms() override<br>Set uniforms before rendering.
virtual voidsetUniformsPerMeshPart(Core::Mesh::MeshPart & meshPart) override<br>Set uniforms before rendering individual mesh parts.

Protected Functions ​

Name
voidbindTexture(GLuint textureID, const std::string & type, int typeIndex, GLuint textureUnit)
voidbindTextures(Core::Mesh::TextureSet tSet)
voidclearTextures() const<br>Sets all texture active flags to false.
voidsetMaterialUniforms(Core::Mesh::Material material)

Public Attributes ​

Name
LightingModelm_lightingModel
glm::vec3m_tint

Protected Attributes ​

Name
GLintm_lightingModelId
GLintmaterial_ambient
GLintmaterial_diffuse
GLintmaterial_shininess
GLintmaterial_specular
GLintnormalStrength
GLinttintId

Additional inherited members ​

Public Functions inherited from Vp::ObjectShader

Name
ObjectShader(GLuint id)

Public Attributes inherited from Vp::ObjectShader

Name
floatm_opacity

Protected Attributes inherited from Vp::ObjectShader

Name
GLintopacityId

Public Functions inherited from Vp::WorldShader

Name
WorldShader(GLuint id)
voidsetWorldTransform(const glm::mat4 & model, const glm::mat4 & view, const glm::mat4 & projection)<br>Updates MVP matrices.

Public Attributes inherited from Vp::WorldShader

Name
glm::mat4m_model
boolm_normal <br>Whether to provide normal matrix uniform.
glm::mat4m_projection
boolm_pvm <br>Whether to provide precalculated PVM matrix uniform.
boolm_pvmSeparate <br>Whether to provide individual pvm matrices.
glm::mat4m_view
GLintm_wboitFarId
GLintm_wboitNearId
GLintmodelMatrixId
GLintnormalMatrixId
GLintprojectionMatrixId
GLintpvmMatrixId
GLintviewMatrixId

Public Functions inherited from Vp::Shader

Name
Shader(GLuint id)
virtual~Shader() =default
voidbindTexture2D(GLuint textureUnit, GLuint textureID, GLint samplerLocation)
voidbindTexture2DArray(GLuint textureUnit, GLuint textureID, GLint samplerLocation)
voidbindTexture2DMS(GLuint textureUnit, GLuint textureID, GLint samplerLocation)
boolhasUniform(GLint location) const
boolsupportsUserClipping() const
boolsupportsWboit() const
virtual voiduse() const

Public Attributes inherited from Vp::Shader

Name
const std::array< glm::vec4, 6 > *m_clippingPlanes
std::stringm_fragSource
std::stringm_geoSource
GLuintm_id
std::stringm_injectedSource
std::stringm_vertSource
boolm_wboit <br>Whether to use weighted blended transparency for output if supported.
intm_wboitFunc

Protected Attributes inherited from Vp::Shader

Name
std::array< GLint, 6 >m_clippingPlanesId
GLintm_wboitFlagId <br>Uniform id of the wboit enable/disable flag.
GLintm_wboitFuncId

Public Types Documentation ​

enum LightingModel ​

EnumeratorValueDescription
PHONG
BLINN_PHONG

Public Functions Documentation ​

function PhongShader ​

cpp
explicit PhongShader(
    GLuint id
)

function init ​

cpp
virtual void init(
    bool initSuperclass
) override

Reimplements: Vp::ObjectShader::init

function setUniforms ​

cpp
virtual void setUniforms() override

Set uniforms before rendering.

Reimplements: Vp::ObjectShader::setUniforms

function setUniformsPerMeshPart ​

cpp
virtual void setUniformsPerMeshPart(
    Core::Mesh::MeshPart & meshPart
) override

Set uniforms before rendering individual mesh parts.

Parameters:

  • meshPart MeshPart being rendered

Reimplements: Vp::Shader::setUniformsPerMeshPart

Protected Functions Documentation ​

function bindTexture ​

cpp
void bindTexture(
    GLuint textureID,
    const std::string & type,
    int typeIndex,
    GLuint textureUnit
)

function bindTextures ​

cpp
void bindTextures(
    Core::Mesh::TextureSet tSet
)

function clearTextures ​

cpp
void clearTextures() const

Sets all texture active flags to false.

Used to reset texture state before binding new set of textures.

function setMaterialUniforms ​

cpp
void setMaterialUniforms(
    Core::Mesh::Material material
)

Public Attributes Documentation ​

variable m_lightingModel ​

cpp
LightingModel m_lightingModel {BLINN_PHONG};

variable m_tint ​

cpp
glm::vec3 m_tint {1.0f};

Protected Attributes Documentation ​

variable m_lightingModelId ​

cpp
GLint m_lightingModelId;

variable material_ambient ​

cpp
GLint material_ambient;

variable material_diffuse ​

cpp
GLint material_diffuse;

variable material_shininess ​

cpp
GLint material_shininess;

variable material_specular ​

cpp
GLint material_specular;

variable normalStrength ​

cpp
GLint normalStrength;

variable tintId ​

cpp
GLint tintId;

Updated on 2026-09-11 at 21:24:25 +0000