353 if (texture->
target() == GL_TEXTURE_3D)
402 string programNameDraw;
412 std::string geom =
"";
431 string programNameUpdate;
442 vector<const char*> outputNames;
443 outputNames.push_back(
"tf_position");
444 outputNames.push_back(
"tf_velocity");
445 outputNames.push_back(
"tf_startTime");
448 outputNames.push_back(
"tf_initialVelocity");
453 outputNames.push_back(
"tf_rotation");
458 outputNames.push_back(
"tf_angularVelo");
463 outputNames.push_back(
"tf_texNum");
468 outputNames.push_back(
"tf_initialPosition");
509 SLbool supportGPUSkinning)
562 assert(
program &&
"SLMaterial::passToUniforms: No shader program set!");
584 texture->bindActive(nextTexUnit);
589 snprintf(
name,
sizeof(
name),
"u_matTextureDiffuse%d", texNb);
594 snprintf(
name,
sizeof(
name),
"u_matTextureSpecular%d", texNb);
599 snprintf(
name,
sizeof(
name),
"u_matTextureNormal%d", texNb);
604 snprintf(
name,
sizeof(
name),
"u_matTextureHeight%d", texNb);
609 snprintf(
name,
sizeof(
name),
"u_matTextureOcclusion%d", texNb);
614 snprintf(
name,
sizeof(
name),
"u_matTextureRoughness%d", texNb);
619 snprintf(
name,
sizeof(
name),
"u_matTextureMetallic%d", texNb);
624 snprintf(
name,
sizeof(
name),
"u_matTextureRoughMetal%d", texNb);
629 snprintf(
name,
sizeof(
name),
"u_matTextureOccluRoughMetal%d", texNb);
634 snprintf(
name,
sizeof(
name),
"u_matTextureEmissive%d", texNb);
639 snprintf(
name,
sizeof(
name),
"u_matTextureEnvCubemap%d", texNb);
644 snprintf(
name,
sizeof(
name),
"u_matTextureFont%d", texNb);
649 snprintf(
name,
sizeof(
name),
"u_matTextureDiffuse%d", texNb);
656 "texture name %s not found for program: %s",
697 std::to_string(
_textures[iTT][iT]->uvIndex());
713 if (
_textures[iTT][iT]->uvIndex() == uvIndex)
vector< SLLight * > SLVLight
STL vector of light pointers.
Toplevel holder of the assets meshes, materials, textures and shaders.
SLGLProgram * getProgramByName(const string &programName)
Returns the pointer to shader program if found by name.
bool removeProgram(SLGLProgram *program)
Removes the specified mesh from the meshes resource vector.
SLVMaterial & materials()
Active or visible camera node class.
Generated Shader Program class inherited from SLGLProgram.
static void buildProgramNamePS(SLMaterial *mat, string &programName, bool isDrawProg, bool drawInstanced)
static void buildProgramName(SLMaterial *mat, SLVLight *lights, SLbool supportGPUSkinning, string &programName)
Builds unique program name that identifies shader program.
Encapsulation of an OpenGL shader program object.
SLint uniform4fv(const SLchar *name, SLsizei count, const SLfloat *value) const
Passes 4 float values py pointer to the uniform variable "name".
void deleteDataGpu()
Delete all Gpu data.
SLint uniform1f(const SLchar *name, SLfloat v0) const
Passes the float value v0 to the uniform variable "name".
void initTF(const char *writeBackAttrib[], int size)
void beginUse(SLCamera *cam, SLMaterial *mat, SLVLight *lights)
SLint uniform1i(const SLchar *name, SLint v0) const
Passes the int values v0 to the uniform variable "name".
Singleton class holding all OpenGL states.
static SLGLState * instance()
Public static instance getter for singleton pattern.
void currentMaterial(SLMaterial *mat)
Texture object for OpenGL texturing.
void texType(SLTextureType bt)
void bindActive(SLuint texUnit=0)
SLCol4f _emissive
emissive color coefficients
SLCol4f _specular
specular color (RGB reflection coefficients)
SLfloat shininess() const
SLfloat _kt
transmission coefficient 0.0 - 1.0 used for ray and path tracing
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.
SLstring texturesString()
Returns a unique string that represent all textures used.
SLfloat _kr
reflection coefficient 0.0 - 1.0 used for ray and path tracing
static SLfloat PERFECT
PM: shininess/translucency limit.
SLVGLTexture _textures[TT_numTextureType]
array of texture vectors one for each type
SLAssetManager * _assetManager
pointer to the asset manager (the owner) if available
SLint passToUniforms(SLGLProgram *program, SLint nextTexUnit)
Passes all material parameters as uniforms to the passed shader program.
SLVGLTexture _textures3d
texture vector for diffuse 3D textures
SLfloat _metalness
metallic property (0-1) in Cook-Torrance model
SLGLProgram * _programTF
pointer to a GLSL shader program for transformFeedback
SLfloat _roughness
roughness property (0-1) in Cook-Torrance model
void generateProgramPS(bool drawInstanced=false)
SLCol4f _ambient
ambient color (RGB reflection coefficients)
SLCol4f _diffuse
diffuse color (RGB reflection coefficients)
SLbool _getsShadows
true if shadows are visible on this material
SLfloat roughness() const
SLfloat metalness() const
void addTexture(SLGLTexture *texture)
Adds the passed texture to the equivalent texture type vector.
void activate(SLCamera *cam, SLVLight *lights, SLbool supportGPUSkinning)
SLParticleSystem * _ps
pointer to a particle system
SLGLProgram * _program
pointer to a GLSL shader program
SLSkybox * _skybox
pointer to the skybox
SLfloat _kn
refraction index
SLbool usesUVIndex(SLbyte uvIndex)
Returns true if the specified uvIndex is used by one of the textures.
SLReflectionModel _reflectionModel
reflection model (RM_BlinnPhong or RM_CookTorrance)
SLGLTexture * _errorTexture
pointer to error texture that is shown if another texture fails
SLint _numTextures
number of textures in all _textures vectors array
SLfloat _shininess
shininess exponent in Blinn-Phong model
SLGLProgram * programTF()
SLstring _compileErrorTexFilePath
path to the error texture
SLfloat _translucency
translucency exponent for light refraction for path tracing
Base class for all other classes.
void name(const SLstring &Name)
const SLstring & name() const
SLParticleSystem creates a particle meshes from a point primitive buffer.
SLbool doFlipBookTexture()
Skybox node class with a SLBox mesh.
SLGLTexture * irradianceCubemap()
SLGLTexture * brdfLutTexture()
SLGLTexture * roughnessCubemap()
void set(const T X, const T Y, const T Z, const T W=1)
void clear(std::string path)
void log(const char *tag, const char *format,...)
logs a formatted string platform independently