SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLMaterialDefaultGray Class Reference

Global default gray color material for meshes that don't define their own. More...

#include <SLMaterial.h>

Inheritance diagram for SLMaterialDefaultGray:
[legend]

Static Public Member Functions

static SLMaterialDefaultGrayinstance ()
 
static void deleteInstance ()
 

Private Member Functions

 SLMaterialDefaultGray ()
 

Static Private Attributes

static SLMaterialDefaultGray_instance = nullptr
 

Additional Inherited Members

- Public Member Functions inherited from SLMaterial
 SLMaterial (SLAssetManager *am, const SLchar *name, const SLCol4f &amdi=SLCol4f::WHITE, const SLCol4f &spec=SLCol4f::WHITE, SLfloat shininess=100.0f, SLfloat kr=0.0, SLfloat kt=0.0f, SLfloat kn=1.0f, SLGLProgram *program=nullptr)
 Default ctor for Blinn-Phong reflection model materials without textures. More...
 
 SLMaterial (SLAssetManager *am, const SLchar *name, SLGLTexture *texture1, SLGLTexture *texture2=nullptr, SLGLTexture *texture3=nullptr, SLGLTexture *texture4=nullptr, SLGLProgram *program=nullptr)
 Ctor for textured Blinn-Phong reflection model materials. More...
 
 SLMaterial (SLAssetManager *am, const SLchar *name, SLSkybox *skybox, SLCol4f diffuse, SLfloat roughness, SLfloat metalness, SLGLProgram *program=nullptr)
 Ctor for PBR material with Cook-Torrance material parameters. More...
 
 SLMaterial (SLAssetManager *am, const SLchar *name, SLSkybox *skybox, SLGLTexture *texture1, SLGLTexture *texture2=nullptr, SLGLTexture *texture3=nullptr, SLGLTexture *texture4=nullptr, SLGLTexture *texture5=nullptr, SLGLProgram *program=nullptr)
 Ctor for PBR material with Cook-Torrance material textures. More...
 
 SLMaterial (SLAssetManager *am, const SLchar *name, SLParticleSystem *ps, SLGLTexture *texture, SLGLProgram *program=nullptr, SLGLProgram *programTF=nullptr)
 Ctor for Particle System material with one texture (Draw and update) More...
 
 SLMaterial (SLAssetManager *am, SLGLProgram *colorUniformProgram, const SLCol4f &uniformColor, const SLchar *name=(const char *)"Uniform color")
 Ctor for uniform color material without lighting. More...
 
 SLMaterial (SLAssetManager *am, const SLchar *name, SLGLProgram *program)
 Ctor for only a program. More...
 
 ~SLMaterial () override
 
void generateProgramPS (bool drawInstanced=false)
 
void activate (SLCamera *cam, SLVLight *lights, SLbool supportGPUSkinning)
 
SLint passToUniforms (SLGLProgram *program, SLint nextTexUnit)
 Passes all material parameters as uniforms to the passed shader program. More...
 
void deleteDataGpu ()
 
SLbool hasAlpha ()
 Returns true if there is any transparency in diffuse alpha or textures. More...
 
SLbool has3DTexture ()
 Returns true if a material has a 3D texture. More...
 
SLbool usesUVIndex (SLbyte uvIndex)
 Returns true if the specified uvIndex is used by one of the textures. More...
 
SLbool needsTangents ()
 
SLbool hasTextureType (SLTextureType tt)
 
SLbool hasTextureTypeWithUVIndex (SLTextureType tt, SLuint texIndex, SLbyte uvIndex)
 
void removeTextureType (SLTextureType tt)
 
void addTexture (SLGLTexture *texture)
 Adds the passed texture to the equivalent texture type vector. More...
 
SLstring texturesString ()
 Returns a unique string that represent all textures used. More...
 
void assetManager (SLAssetManager *am)
 
void reflectionModel (SLReflectionModel rm)
 
void ambient (const SLCol4f &ambi)
 
void diffuse (const SLCol4f &diff)
 
void ambientDiffuse (const SLCol4f &am_di)
 
void specular (const SLCol4f &spec)
 
void emissive (const SLCol4f &emis)
 
void transmissive (const SLCol4f &transm)
 
void translucency (SLfloat transl)
 
void shininess (SLfloat shin)
 
void roughness (SLfloat r)
 
void metalness (SLfloat m)
 
void kr (SLfloat kr)
 
void kt (SLfloat kt)
 
void kn (SLfloat kn)
 
void getsShadows (SLbool receivesShadows)
 
void program (SLGLProgram *sp)
 
void programTF (SLGLProgram *sp)
 
void skybox (SLSkybox *sb)
 
void ps (SLParticleSystem *ps)
 
SLAssetManagerassetManager ()
 
SLReflectionModel reflectionModel ()
 
SLCol4f ambient ()
 
SLCol4f diffuse ()
 
SLCol4f specular ()
 
SLCol4f emissive ()
 
SLfloat shininess () const
 
SLfloat roughness () const
 
SLfloat metalness () const
 
SLCol4f transmissive ()
 
SLfloat translucency () const
 
SLfloat kr () const
 
SLfloat kt () const
 
SLfloat kn () const
 
SLbool getsShadows () const
 
SLuint numTextures ()
 
SLGLProgramprogram ()
 
SLGLProgramprogramTF ()
 
SLSkyboxskybox ()
 
SLParticleSystemps ()
 
SLVNodenodesVisible2D ()
 
SLVNodenodesVisible3D ()
 
SLVGLTexturetextures (SLTextureType type)
 
SLVGLTexturetextures3d ()
 
- Public Member Functions inherited from SLObject
 SLObject (const SLstring &Name="", const SLstring &url="")
 
virtual ~SLObject ()
 
void name (const SLstring &Name)
 
void url (const SLstring &url)
 
const SLstringname () const
 
const SLstringurl () const
 
- Static Public Attributes inherited from SLMaterial
static SLfloat K
 PM: Constant of gloss calibration (slope of point light at dist 1) More...
 
static SLfloat PERFECT = 1000.0f
 PM: shininess/translucency limit. More...
 
- Protected Attributes inherited from SLMaterial
SLAssetManager_assetManager
 pointer to the asset manager (the owner) if available More...
 
SLReflectionModel _reflectionModel
 reflection model (RM_BlinnPhong or RM_CookTorrance) More...
 
SLCol4f _ambient
 ambient color (RGB reflection coefficients) More...
 
SLCol4f _diffuse
 diffuse color (RGB reflection coefficients) More...
 
SLCol4f _specular
 specular color (RGB reflection coefficients) More...
 
SLCol4f _emissive
 emissive color coefficients More...
 
SLfloat _shininess
 shininess exponent in Blinn-Phong model More...
 
SLfloat _roughness
 roughness property (0-1) in Cook-Torrance model More...
 
SLfloat _metalness
 metallic property (0-1) in Cook-Torrance model More...
 
SLCol4f _transmissive
 transmissive color (RGB reflection coefficients) for path tracing More...
 
SLfloat _translucency
 translucency exponent for light refraction for path tracing More...
 
SLfloat _kr {}
 reflection coefficient 0.0 - 1.0 used for ray and path tracing More...
 
SLfloat _kt {}
 transmission coefficient 0.0 - 1.0 used for ray and path tracing More...
 
SLfloat _kn {}
 refraction index More...
 
SLbool _getsShadows
 true if shadows are visible on this material More...
 
SLGLProgram_program {}
 pointer to a GLSL shader program More...
 
SLGLProgram_programTF {}
 pointer to a GLSL shader program for transformFeedback More...
 
SLint _numTextures
 number of textures in all _textures vectors array More...
 
SLSkybox_skybox
 pointer to the skybox More...
 
SLParticleSystem_ps
 pointer to a particle system More...
 
SLVGLTexture _textures [TT_numTextureType]
 array of texture vectors one for each type More...
 
SLVGLTexture _textures3d
 texture vector for diffuse 3D textures More...
 
SLGLTexture_errorTexture = nullptr
 pointer to error texture that is shown if another texture fails More...
 
SLstring _compileErrorTexFilePath
 path to the error texture More...
 
SLVNode _nodesVisible2D
 Vector of all visible 2D nodes of with this material. More...
 
SLVNode _nodesVisible3D
 Vector of all visible 3D nodes of with this material. More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 

Detailed Description

Global default gray color material for meshes that don't define their own.

Because the default material depends a default shader program (SLGLDefaultProgPerVrtBlinn or SLGLDefaultProgPerVrtBlinnTm) that itself depends on the scene configuration (e.g. the num. of lights) ist MUST be deleted at scene destruction.

Definition at line 283 of file SLMaterial.h.

Constructor & Destructor Documentation

◆ SLMaterialDefaultGray()

SLMaterialDefaultGray::SLMaterialDefaultGray ( )
inlineprivate

Definition at line 302 of file SLMaterial.h.

303  : SLMaterial(nullptr, "default", SLVec4f::GRAY, SLVec4f::WHITE)
304  {
305  ambient({0.2f, 0.2f, 0.2f});
306  }
SLMaterial(SLAssetManager *am, const SLchar *name, const SLCol4f &amdi=SLCol4f::WHITE, const SLCol4f &spec=SLCol4f::WHITE, SLfloat shininess=100.0f, SLfloat kr=0.0, SLfloat kt=0.0f, SLfloat kn=1.0f, SLGLProgram *program=nullptr)
Default ctor for Blinn-Phong reflection model materials without textures.
Definition: SLMaterial.cpp:37
SLCol4f ambient()
Definition: SLMaterial.h:213
static SLVec4 WHITE
Definition: SLVec4.h:215
static SLVec4 GRAY
Definition: SLVec4.h:214

Member Function Documentation

◆ deleteInstance()

static void SLMaterialDefaultGray::deleteInstance ( )
inlinestatic

Definition at line 292 of file SLMaterial.h.

293  {
294  if (_instance)
295  {
296  delete _instance;
297  _instance = nullptr;
298  }
299  }
static SLMaterialDefaultGray * _instance
Definition: SLMaterial.h:308

◆ instance()

static SLMaterialDefaultGray* SLMaterialDefaultGray::instance ( )
inlinestatic

Definition at line 286 of file SLMaterial.h.

287  {
288  if (!_instance)
290  return _instance;
291  }

Member Data Documentation

◆ _instance

SLMaterialDefaultGray * SLMaterialDefaultGray::_instance = nullptr
staticprivate

Definition at line 308 of file SLMaterial.h.


The documentation for this class was generated from the following files: