NAP
Public Member Functions | List of all members
BlinnPhongTextureShader Class Reference

#include <blinnphongtextureshader.h>

Public Member Functions

 BlinnPhongTextureShader (Core &core)
 
virtual bool init (utility::ErrorState &errorState) override
 
- Public Member Functions inherited from Shader
 Shader (Core &core)
 
 ~Shader ()
 
const VertexAttributeDeclarationsgetAttributes () const
 
VkShaderModule getVertexModule () const
 
VkShaderModule getFragmentModule () const
 
- Public Member Functions inherited from BaseShader
 BaseShader (Core &core)
 
virtual ~BaseShader ()
 
const SamplerDeclarationsgetSamplerDeclarations () const
 
const std::vector< BufferObjectDeclaration > & getUBODeclarations () const
 
const std::vector< BufferObjectDeclaration > & getSSBODeclarations () const
 
const ShaderConstantDeclarationsgetConstantDeclarations () const
 
const std::string & getDisplayName () const
 
VkDescriptorSetLayout getDescriptorSetLayout () const
 
void clear ()
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Additional Inherited Members

- Public Types inherited from Shader
enum  EShaderType : uint { Vertex = 0x01, Fragment = 0x02 }
 
using ShaderTypeFlags = uint
 
- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 
- Protected Member Functions inherited from Shader
bool load (const std::string &displayName, const std::vector< std::string > &searchPaths, const char *vertShader, int vertSize, const char *fragShader, int fragSize, utility::ErrorState &errorState)
 
bool loadDefault (const std::string &displayName, utility::ErrorState &errorState)
 
- Protected Member Functions inherited from BaseShader
bool initLayout (VkDevice device, nap::utility::ErrorState &errorState)
 
bool verifyShaderVariableDeclarations (utility::ErrorState &errorState)
 
- Protected Attributes inherited from BaseShader
RenderServicemRenderService = nullptr
 Handle to render engine. More...
 
std::string mDisplayName
 Filename of shader used as display name. More...
 
BufferObjectDeclarationList mUBODeclarations
 All uniform buffer object declarations. More...
 
BufferObjectDeclarationList mSSBODeclarations
 All storage buffer object declarations. More...
 
SamplerDeclarations mSamplerDeclarations
 All sampler declarations. More...
 
ShaderConstantDeclarations mConstantDeclarations
 All shader constant declarations. More...
 
VkDescriptorSetLayout mDescriptorSetLayout = VK_NULL_HANDLE
 Descriptor set layout. More...
 

Description

Blinn Phong Texture Shader

This is NAP's default blinn-phong shader program and is compatible with the naprenderadvanced light system. It also supports shadows and environment maps. When compiling NAP for Raspberry Pi, shadows are disabled when the Vulkan version is lower than 1.1.

The blinnphongcolor shader exposes the following shader variables for users:

uniform UBO
{
vec3 ambient; //< Ambient
vec3 diffuse; //< Diffuse
vec3 specular; //< Specular
vec2 fresnel; //< Fresnel [scale, power]
float shininess; //< Shininess
float alpha; //< Alpha
float reflection; //< Reflection
uint environment; //< Whether to sample an environment map
} ubo;
uniform sampler2D colorTexture;
uniform samplerCube environmentMap;

The remaining uniforms are set automatically by the nap::RenderAdvancedService.

Inheritance diagram for BlinnPhongTextureShader:
[legend]
Collaboration diagram for BlinnPhongTextureShader:
[legend]

Constructor & Destructor Documentation

◆ BlinnPhongTextureShader()

Member Function Documentation

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Cross compiles the constant GLSL shader code to SPIR-V, creates the shader module and parses all the uniforms and samplers.

Parameters
errorStatecontains the error if initialization fails.
Returns
if initialization succeeded.

Reimplemented from Object.