@ -65,6 +65,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGLBase: public GL::AbstractShaderProgr
UniformBuffers = 1 < < 10 ,
MultiDraw = UniformBuffers | ( 1 < < 11 ) ,
TextureArrays = 1 < < 17 ,
DynamicPerVertexJointCount = 1 < < 18
# endif
} ;
typedef Containers : : EnumSet < FlagBase > FlagsBase ;
@ -78,11 +79,12 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGLBase: public GL::AbstractShaderProgr
static MAGNUM_SHADERS_LOCAL void assertExtensions ( const FlagsBase flags ) ;
static MAGNUM_SHADERS_LOCAL GL : : Version setupShaders ( GL : : Shader & vert , GL : : Shader & frag , const Utility : : Resource & rs , const FlagsBase flags
# ifndef MAGNUM_TARGET_GLES2
, UnsignedInt materialCount , UnsignedInt drawCount
, UnsignedInt dimensions , UnsignedInt jointCount , UnsignedInt perVertexJointCount , UnsignedInt secondaryPerVertexJointCount , UnsignedInt materialCount , UnsignedInt drawCount , UnsignedInt perInstanceJointCountUniform , UnsignedInt perVertexJointCountUniform
# endif
) ;
# ifndef MAGNUM_TARGET_GLES2
MeshVisualizerGLBase & setPerVertexJointCount ( UnsignedInt count , UnsignedInt secondaryCount ) ;
MeshVisualizerGLBase & setTextureMatrix ( const Matrix3 & matrix ) ;
MeshVisualizerGLBase & setTextureLayer ( UnsignedInt layer ) ;
MeshVisualizerGLBase & setObjectId ( UnsignedInt id ) ;
@ -92,22 +94,29 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGLBase: public GL::AbstractShaderProgr
MeshVisualizerGLBase & setWireframeWidth ( Float width ) ;
# ifndef MAGNUM_TARGET_GLES2
MeshVisualizerGLBase & setColorMapTransformation ( Float offset , Float scale ) ;
MeshVisualizerGLBase & setPerInstanceJointCount ( UnsignedInt count ) ;
MeshVisualizerGLBase & setDrawOffset ( UnsignedInt offset ) ;
MeshVisualizerGLBase & bindColorMapTexture ( GL : : Texture2D & texture ) ;
MeshVisualizerGLBase & bindObjectIdTexture ( GL : : Texture2D & texture ) ;
MeshVisualizerGLBase & bindObjectIdTexture ( GL : : Texture2DArray & texture ) ;
# endif
# ifndef MAGNUM_TARGET_GLES2
MeshVisualizerGLBase & setDrawOffset ( UnsignedInt offset ) ;
MeshVisualizerGLBase & bindTextureTransformationBuffer ( GL : : Buffer & buffer ) ;
MeshVisualizerGLBase & bindTextureTransformationBuffer ( GL : : Buffer & buffer , GLintptr offset , GLsizeiptr size ) ;
MeshVisualizerGLBase & bindMaterialBuffer ( GL : : Buffer & buffer ) ;
MeshVisualizerGLBase & bindMaterialBuffer ( GL : : Buffer & buffer , GLintptr offset , GLsizeiptr size ) ;
MeshVisualizerGLBase & bindJointBuffer ( GL : : Buffer & buffer ) ;
MeshVisualizerGLBase & bindJointBuffer ( GL : : Buffer & buffer , GLintptr offset , GLsizeiptr size ) ;
# endif
FlagsBase _flags ;
# ifndef MAGNUM_TARGET_GLES2
UnsignedInt _materialCount { } , _drawCount { } ;
UnsignedInt _jointCount { } ,
_perVertexJointCount { } ,
_secondaryPerVertexJointCount { } ,
_materialCount { } ,
_drawCount { } ;
# endif
Int _viewportSizeUniform { 0 } ,
_colorUniform { 1 } ,
@ -118,10 +127,15 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGLBase: public GL::AbstractShaderProgr
Int _colorMapOffsetScaleUniform { 5 } ,
_objectIdUniform { 6 } ,
_textureMatrixUniform { 7 } ,
_textureLayerUniform { 8 } ;
/* Used instead of all other uniforms except viewportSize when
Flag : : UniformBuffers is set , so it can alias them */
Int _drawOffsetUniform { 1 } ;
_textureLayerUniform { 8 } ,
/* 9 to 13 different between MeshVisualizerGL2D and
MeshVisualizerGL3D */
_jointMatricesUniform { 14 } ,
_perInstanceJointCountUniform , /* 14 + jointCount */
/* Used instead of all other uniforms except viewportSize when
Flag : : UniformBuffers is set , so it can alias them */
_drawOffsetUniform { 1 } ,
_perVertexJointCountUniform ; /* 15 + jointCount, or 2 with UBOs */
# endif
} ;
@ -189,7 +203,8 @@ a trimmed-down @ref MeshVisualizerDrawUniform2D is used instead of
*/
class MAGNUM_SHADERS_EXPORT MeshVisualizerGL2D : public Implementation : : MeshVisualizerGLBase {
public :
class Configuration ;
/* MSVC needs dllexport here as well */
class MAGNUM_SHADERS_EXPORT Configuration ;
class CompileState ;
/**
@ -205,6 +220,64 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL2D: public Implementation::MeshVisua
typedef GenericGL2D : : TextureCoordinates TextureCoordinates ;
# endif
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Joint ids
* @ m_since_latest
*
* @ ref shaders - generic " Generic attribute " , @ ref Magnum : : Vector4ui .
* Used only if @ ref perVertexJointCount ( ) isn ' t @ cpp 0 @ ce .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
typedef GenericGL3D : : JointIds JointIds ;
/**
* @ brief Weights
* @ m_since_latest
*
* @ ref shaders - generic " Generic attribute " , @ ref Magnum : : Vector4 .
* Used only if @ ref perVertexJointCount ( ) isn ' t @ cpp 0 @ ce .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
typedef GenericGL3D : : Weights Weights ;
/**
* @ brief Secondary joint ids
* @ m_since_latest
*
* @ ref shaders - generic " Generic attribute " , @ ref Magnum : : Vector4ui .
* Used only if @ ref secondaryPerVertexJointCount ( ) isn ' t @ cpp 0 @ ce .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
typedef GenericGL3D : : SecondaryJointIds SecondaryJointIds ;
/**
* @ brief Secondary weights
* @ m_since_latest
*
* @ ref shaders - generic " Generic attribute " , @ ref Magnum : : Vector4 .
* Used only if @ ref secondaryPerVertexJointCount ( ) isn ' t @ cpp 0 @ ce .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
typedef GenericGL3D : : SecondaryWeights SecondaryWeights ;
# endif
/**
* @ brief Vertex index
*
@ -443,6 +516,29 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL2D: public Implementation::MeshVisua
/** @copydoc MeshVisualizerGL3D::Flag::TextureArrays */
TextureArrays = 1 < < 17 ,
/**
* Dynamic per - vertex joint count for skinning . Uses only the first
* M / N primary / secondary components defined by
* @ ref setPerVertexJointCount ( ) instead of
* all primary / secondary components defined by
* @ ref Configuration : : setJointCount ( ) at shader compilation time .
* Useful in order to avoid having a shader permutation defined for
* every possible joint count . Unfortunately it ' s not possible to
* make use of default values for unspecified input components as
* the last component is always @ cpp 1.0 @ ce instead of
* @ cpp 0.0 @ ce , on the other hand dynamically limiting the joint
* count can reduce the time spent executing the vertex shader
* compared to going through the full set of per - vertex joints
* always .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders ,
* which is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
* @ m_since_latest
*/
DynamicPerVertexJointCount = 1 < < 18 ,
# endif
} ;
@ -555,6 +651,47 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL2D: public Implementation::MeshVisua
return Flag ( UnsignedInt ( Implementation : : MeshVisualizerGLBase : : _flags ) ) ;
}
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Joint count
* @ m_since_latest
*
* If @ ref Flag : : UniformBuffers is not set , this is the number of joint
* matrices accepted by @ ref setJointMatrices ( ) / @ ref setJointMatrix ( ) .
* If @ ref Flag : : UniformBuffers is set , this is the statically defined
* size of the @ ref TransformationUniform2D uniform buffer bound with
* @ ref bindJointBuffer ( ) .
* @ see @ ref Configuration : : setJointCount ( )
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt jointCount ( ) const { return _jointCount ; }
/**
* @ brief Per - vertex joint count
* @ m_since_latest
*
* Returns the value set with @ ref Configuration : : setJointCount ( ) . If
* @ ref Flag : : DynamicPerVertexJointCount is set , the count can be
* additionally modified per - draw using @ ref setPerVertexJointCount ( ) .
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt perVertexJointCount ( ) const { return _perVertexJointCount ; }
/**
* @ brief Secondary per - vertex joint count
* @ m_since_latest
*
* Returns the value set with @ ref Configuration : : setJointCount ( ) . If
* @ ref Flag : : DynamicPerVertexJointCount is set , the count can be
* additionally modified per - draw using @ ref setPerVertexJointCount ( ) .
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt secondaryPerVertexJointCount ( ) const { return _secondaryPerVertexJointCount ; }
# endif
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Material count
@ -585,6 +722,37 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL2D: public Implementation::MeshVisua
UnsignedInt drawCount ( ) const { return _drawCount ; }
# endif
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Set dynamic per - vertex skinning joint count
* @ return Reference to self ( for method chaining )
* @ m_since_latest
*
* Allows reducing the count of iterated joints for a particular draw
* call , making it possible to use a single shader with meshes that
* contain different count of per - vertex joints . See
* @ ref Flag : : DynamicPerVertexJointCount for more information . As the
* joint count is tied to the mesh layout , this is a per - draw - call
* setting even in case of @ ref Flag : : UniformBuffers instead of being
* a value in @ ref MeshVisualizerDrawUniform2D . Initial value is same
* as @ ref perVertexJointCount ( ) and
* @ ref secondaryPerVertexJointCount ( ) .
*
* Expects that @ ref Flag : : DynamicPerVertexJointCount is set ,
* @ p count is not larger than @ ref perVertexJointCount ( ) and
* @ p secondaryCount not larger than @ ref secondaryPerVertexJointCount ( ) .
* @ see @ ref Configuration : : setJointCount ( )
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders , which
* is not available in WebGL 1.0 .
*/
MeshVisualizerGL2D & setPerVertexJointCount ( UnsignedInt count , UnsignedInt secondaryCount = 0 ) {
return static_cast < MeshVisualizerGL2D & > ( Implementation : : MeshVisualizerGLBase : : setPerVertexJointCount ( count , secondaryCount ) ) ;
}
# endif
/** @{
* @ name Uniform setters
*
@ -722,6 +890,78 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL2D: public Implementation::MeshVisua
*/
MeshVisualizerGL2D & setSmoothness ( Float smoothness ) ;
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Set joint matrices
* @ return Reference to self ( for method chaining )
* @ m_since_latest
*
* Initial values are identity transformations . Expects that the size
* of the @ p matrices array is the same as @ ref jointCount ( ) .
*
* Expects that @ ref Flag : : UniformBuffers is not set , in that case fill
* @ ref TransformationUniform2D : : transformationMatrix and call
* @ ref bindJointBuffer ( ) instead .
* @ see @ ref setJointMatrix ( UnsignedInt , const Matrix3 & )
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
MeshVisualizerGL2D & setJointMatrices ( const Containers : : ArrayView < const Matrix3 > matrices ) ;
/**
* @ overload
* @ m_since_latest
*/
MeshVisualizerGL2D & setJointMatrices ( std : : initializer_list < Matrix3 > matrices ) ;
/**
* @ brief Set joint matrix for given joint
* @ return Reference to self ( for method chaining )
* @ m_since_latest
*
* Unlike @ ref setJointMatrices ( ) updates just a single joint matrix .
* Expects that @ p id is less than @ ref jointCount ( ) .
*
* Expects that @ ref Flag : : UniformBuffers is not set , in that case fill
* @ ref TransformationUniform2D : : transformationMatrix and call
* @ ref bindJointBuffer ( ) instead .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
MeshVisualizerGL2D & setJointMatrix ( UnsignedInt id , const Matrix3 & matrix ) ;
/**
* @ brief Set per - instance joint count
* @ return Reference to self ( for method chaining )
* @ m_since_latest
*
* Offset added to joint IDs in the @ ref JointIds and
* @ ref SecondaryJointIds in instanced draws . Should be less than
* @ ref jointCount ( ) . Initial value is @ cpp 0 @ ce , meaning every
* instance will use the same joint matrices , setting it to a non - zero
* value causes the joint IDs to be interpreted as
* @ glsl gl_InstanceID * count + jointId @ ce .
*
* Expects that @ ref Flag : : UniformBuffers is not set , in that case fill
* @ ref MeshVisualizerDrawUniform2D : : perInstanceJointCount and call
* @ ref bindDrawBuffer ( ) instead .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
MeshVisualizerGL2D & setPerInstanceJointCount ( UnsignedInt count ) {
return static_cast < MeshVisualizerGL2D & > ( Implementation : : MeshVisualizerGLBase : : setPerInstanceJointCount ( count ) ) ;
}
# endif
/**
* @ }
*/
@ -834,6 +1074,29 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL2D: public Implementation::MeshVisua
return static_cast < MeshVisualizerGL2D & > ( Implementation : : MeshVisualizerGLBase : : bindMaterialBuffer ( buffer , offset , size ) ) ;
}
/**
* @ brief Bind a joint matrix uniform buffer
* @ return Reference to self ( for method chaining )
* @ m_since_latest
*
* Expects that @ ref Flag : : UniformBuffers is set . The buffer is
* expected to contain @ ref jointCount ( ) instances of
* @ ref TransformationUniform2D .
* @ requires_gl31 Extension @ gl_extension { ARB , uniform_buffer_object }
* @ requires_gles30 Uniform buffers are not available in OpenGL ES 2.0 .
* @ requires_webgl20 Uniform buffers are not available in WebGL 1.0 .
*/
MeshVisualizerGL2D & bindJointBuffer ( GL : : Buffer & buffer ) {
return static_cast < MeshVisualizerGL2D & > ( Implementation : : MeshVisualizerGLBase : : bindJointBuffer ( buffer ) ) ;
}
/**
* @ overload
* @ m_since_latest
*/
MeshVisualizerGL2D & bindJointBuffer ( GL : : Buffer & buffer , GLintptr offset , GLsizeiptr size ) {
return static_cast < MeshVisualizerGL2D & > ( Implementation : : MeshVisualizerGLBase : : bindJointBuffer ( buffer , offset , size ) ) ;
}
/**
* @ }
*/
@ -881,7 +1144,7 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL2D: public Implementation::MeshVisua
@ see @ ref MeshVisualizerGL2D ( const Configuration & ) ,
@ ref compile ( const Configuration & )
*/
class MeshVisualizerGL2D : : Configuration {
class MAGNUM_SHADERS_EXPORT M eshVisualizerGL2D : : Configuration {
public :
explicit Configuration ( ) = default ;
@ -903,6 +1166,67 @@ class MeshVisualizerGL2D::Configuration {
}
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Joint count
*
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt jointCount ( ) const { return _jointCount ; }
/**
* @ brief Per - vertex joint count
*
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt perVertexJointCount ( ) const { return _perVertexJointCount ; }
/**
* @ brief Secondary per - vertex joint count
*
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt secondaryPerVertexJointCount ( ) const { return _secondaryPerVertexJointCount ; }
/**
* @ brief Set joint count
*
* If @ ref Flag : : UniformBuffers isn ' t set , @ p count describes how many
* joint matrices get supplied to each draw by @ ref setJointMatrices ( )
* / @ ref setJointMatrix ( ) . If @ ref Flag : : UniformBuffers is set ,
* @ p count describes size of a @ ref TransformationUniform2D buffer
* bound with @ ref bindJointBuffer ( ) ; as uniform buffers are required
* to have a statically defined size . The per - vertex joints then index
* into the array offset by
* @ ref MeshVisualizerDrawUniform2D : : jointOffset . If @ p count is
* @ cpp 0 @ ce , skinning is not performed .
*
* The @ p perVertexCount and @ p secondaryPerVertexCount then describe
* how many components are taken from @ ref JointIds / @ ref Weights and
* @ ref SecondaryJointIds / @ ref SecondaryWeights attributes . Both
* values are expected to not be larger than @ cpp 4 @ ce , setting either
* of these to @ cpp 0 @ ce means given attribute is not used at all . If
* @ p count is @ cpp 0 @ ce , both @ p perVertexCount and
* @ p secondaryPerVertexCount is expected to be @ cpp 0 @ ce as well ; if
* @ p count is non - zero at least one of @ p perVertexCount and
* @ p secondaryPerVertexCount is expected to be non - zero as well .
*
* Default value for all three is @ cpp 0 @ ce .
* @ see @ ref MeshVisualizerGL2D : : jointCount ( ) ,
* @ ref MeshVisualizerGL2D : : perVertexJointCount ( ) ,
* @ ref MeshVisualizerGL2D : : secondaryPerVertexJointCount ( ) ,
* @ ref Flag : : DynamicPerVertexJointCount ,
* @ ref MeshVisualizerGL2D : : setPerVertexJointCount ( )
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
Configuration & setJointCount ( UnsignedInt count , UnsignedInt perVertexCount , UnsignedInt secondaryPerVertexCount = 0 ) ;
/**
* @ brief Material count
*
@ -969,7 +1293,10 @@ class MeshVisualizerGL2D::Configuration {
private :
Flags _flags ;
# ifndef MAGNUM_TARGET_GLES2
UnsignedInt _materialCount = 1 ,
UnsignedInt _jointCount = 0 ,
_perVertexJointCount = 0 ,
_secondaryPerVertexJointCount = 0 ,
_materialCount = 1 ,
_drawCount = 1 ;
# endif
} ;
@ -1171,6 +1498,28 @@ non-indexed @ref MeshPrimitive::Triangles.
arrays are not available in WebGL 1.0 .
@ requires_webgl20 ` gl_VertexID ` is not available in WebGL 1.0 .
@ section Shaders - MeshVisualizerGL3D - skinning Skinning
To render skinned meshes , bind up to two sets of up to four - component joint ID
and weight attributes to @ ref JointIds / @ ref SecondaryJointIds and
@ ref Weights / @ ref SecondaryWeights , set an appropriate joint count and
per - vertex primary and secondary joint count in
@ ref Configuration : : setJointCount ( ) and upload appropriate joint matrices with
@ ref setJointMatrices ( ) . Currently , the mesh visualizer supports only
transforming the mesh vertices for feature parity with other shaders ,
no skinning - specific visualization feature is implemented .
To avoid having to compile multiple shader variants for different per - vertex
joint counts , enable @ ref Flag : : DynamicPerVertexJointCount , set the maximum
per - vertex joint count in @ ref Configuration : : setJointCount ( ) and then adjust
the actual per - draw joint count with @ ref setPerVertexJointCount ( ) .
@ requires_gl30 Extension @ gl_extension { EXT , texture_integer }
@ requires_gles30 Skinning requires integer support in shaders , which is not
available in OpenGL ES 2.0 .
@ requires_webgl20 Skinning requires integer support in shaders , which is not
available in WebGL 1.0 .
@ section Shaders - MeshVisualizerGL3D - instancing Instanced rendering
Enabling @ ref Flag : : InstancedTransformation will turn the shader into an
@ -1190,6 +1539,12 @@ enabled, the @ref TextureOffset attribute (or @ref TextureOffsetLayer in case
@ ref Flag : : TextureArrays is enabled as well ) then can supply per - instance
texture offset ( or offset and layer ) .
For instanced skinning the joint buffer is assumed to contain joint
transformations for all instances . By default all instances use the same joint
transformations , seting @ ref setPerInstanceJointCount ( ) will cause the shader
to offset the per - vertex joint IDs with
@ glsl gl_InstanceID * perInstanceJointCount @ ce .
@ requires_gl33 Extension @ gl_extension { ARB , instanced_arrays }
@ requires_gles30 Extension @ gl_extension { ANGLE , instanced_arrays } ,
@ gl_extension { EXT , instanced_arrays } or @ gl_extension { NV , instanced_arrays }
@ -1223,6 +1578,18 @@ and draw count via @ref Configuration::setMaterialCount() and
every draw . The usage is similar for all shaders , see
@ ref shaders - usage - multidraw for an example .
For skinning , joint matrices are supplied via a @ ref TransformationUniform3D
buffer bound with @ ref bindJointBuffer ( ) . In an instanced scenario the
per - instance joint count is supplied via
@ ref MeshVisualizerDrawUniform3D : : perInstanceJointCount , a per - draw joint
offset for the multidraw scenario is supplied via
@ ref MeshVisualizerDrawUniform3D : : jointOffset . Altogether for a particular
draw , each per - vertex joint ID is offset with
@ glsl gl_InstanceID * perInstanceJointCount + jointOffset @ ce . The
@ ref setPerVertexJointCount ( ) stays as an immediate uniform in the UBO and
multidraw scenario as well , as it is tied to a particular mesh layout and thus
doesn ' t need to vary per draw .
@ requires_gl31 Extension @ gl_extension { ARB , uniform_buffer_object } for uniform
buffers .
@ requires_gl46 Extension @ gl_extension { ARB , shader_draw_parameters } for
@ -1239,7 +1606,8 @@ every draw. The usage is similar for all shaders, see
*/
class MAGNUM_SHADERS_EXPORT MeshVisualizerGL3D : public Implementation : : MeshVisualizerGLBase {
public :
class Configuration ;
/* MSVC needs dllexport here as well */
class MAGNUM_SHADERS_EXPORT Configuration ;
class CompileState ;
/**
@ -1308,6 +1676,64 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL3D: public Implementation::MeshVisua
typedef GenericGL3D : : TextureCoordinates TextureCoordinates ;
# endif
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Joint ids
* @ m_since_latest
*
* @ ref shaders - generic " Generic attribute " , @ ref Magnum : : Vector4ui .
* Used only if @ ref perVertexJointCount ( ) isn ' t @ cpp 0 @ ce .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
typedef GenericGL3D : : JointIds JointIds ;
/**
* @ brief Weights
* @ m_since_latest
*
* @ ref shaders - generic " Generic attribute " , @ ref Magnum : : Vector4 .
* Used only if @ ref perVertexJointCount ( ) isn ' t @ cpp 0 @ ce .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
typedef GenericGL3D : : Weights Weights ;
/**
* @ brief Secondary joint ids
* @ m_since_latest
*
* @ ref shaders - generic " Generic attribute " , @ ref Magnum : : Vector4ui .
* Used only if @ ref secondaryPerVertexJointCount ( ) isn ' t @ cpp 0 @ ce .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
typedef GenericGL3D : : SecondaryJointIds SecondaryJointIds ;
/**
* @ brief Secondary weights
* @ m_since_latest
*
* @ ref shaders - generic " Generic attribute " , @ ref Magnum : : Vector4 .
* Used only if @ ref secondaryPerVertexJointCount ( ) isn ' t @ cpp 0 @ ce .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
typedef GenericGL3D : : SecondaryWeights SecondaryWeights ;
# endif
/**
* @ brief Vertex index
*
@ -1749,7 +2175,30 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL3D: public Implementation::MeshVisua
* @ m_since_latest
* @ todoc rewrite the ext requirements once we have more textures
*/
TextureArrays = 1 < < 17
TextureArrays = 1 < < 17 ,
/**
* Dynamic per - vertex joint count for skinning . Uses only the first
* M / N primary / secondary components defined by
* @ ref setPerVertexJointCount ( ) instead of
* all primary / secondary components defined by
* @ ref Configuration : : setJointCount ( ) at shader compilation time .
* Useful in order to avoid having a shader permutation defined for
* every possible joint count . Unfortunately it ' s not possible to
* make use of default values for unspecified input components as
* the last component is always @ cpp 1.0 @ ce instead of
* @ cpp 0.0 @ ce , on the other hand dynamically limiting the joint
* count can reduce the time spent executing the vertex shader
* compared to going through the full set of per - vertex joints
* always .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders ,
* which is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
* @ m_since_latest
*/
DynamicPerVertexJointCount = 1 < < 18 ,
# endif
} ;
@ -1870,6 +2319,47 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL3D: public Implementation::MeshVisua
return Flag ( UnsignedInt ( Implementation : : MeshVisualizerGLBase : : _flags ) ) ;
}
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Joint count
* @ m_since_latest
*
* If @ ref Flag : : UniformBuffers is not set , this is the number of joint
* matrices accepted by @ ref setJointMatrices ( ) / @ ref setJointMatrix ( ) .
* If @ ref Flag : : UniformBuffers is set , this is the statically defined
* size of the @ ref TransformationUniform3D uniform buffer bound with
* @ ref bindJointBuffer ( ) .
* @ see @ ref Configuration : : setJointCount ( )
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt jointCount ( ) const { return _jointCount ; }
/**
* @ brief Per - vertex joint count
* @ m_since_latest
*
* Returns the value set with @ ref Configuration : : setJointCount ( ) . If
* @ ref Flag : : DynamicPerVertexJointCount is set , the count can be
* additionally modified per - draw using @ ref setPerVertexJointCount ( ) .
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt perVertexJointCount ( ) const { return _perVertexJointCount ; }
/**
* @ brief Secondary per - vertex joint count
* @ m_since_latest
*
* Returns the value set with @ ref Configuration : : setJointCount ( ) . If
* @ ref Flag : : DynamicPerVertexJointCount is set , the count can be
* additionally modified per - draw using @ ref setPerVertexJointCount ( ) .
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt secondaryPerVertexJointCount ( ) const { return _secondaryPerVertexJointCount ; }
# endif
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Material count
@ -1900,6 +2390,37 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL3D: public Implementation::MeshVisua
UnsignedInt drawCount ( ) const { return _drawCount ; }
# endif
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Set dynamic per - vertex skinning joint count
* @ return Reference to self ( for method chaining )
* @ m_since_latest
*
* Allows reducing the count of iterated joints for a particular draw
* call , making it possible to use a single shader with meshes that
* contain different count of per - vertex joints . See
* @ ref Flag : : DynamicPerVertexJointCount for more information . As the
* joint count is tied to the mesh layout , this is a per - draw - call
* setting even in case of @ ref Flag : : UniformBuffers instead of being
* a value in @ ref MeshVisualizerDrawUniform3D . Initial value is same
* as @ ref perVertexJointCount ( ) and
* @ ref secondaryPerVertexJointCount ( ) .
*
* Expects that @ ref Flag : : DynamicPerVertexJointCount is set ,
* @ p count is not larger than @ ref perVertexJointCount ( ) and
* @ p secondaryCount not larger than @ ref secondaryPerVertexJointCount ( ) .
* @ see @ ref Configuration : : setJointCount ( )
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders , which
* is not available in WebGL 1.0 .
*/
MeshVisualizerGL3D & setPerVertexJointCount ( UnsignedInt count , UnsignedInt secondaryCount = 0 ) {
return static_cast < MeshVisualizerGL3D & > ( Implementation : : MeshVisualizerGLBase : : setPerVertexJointCount ( count , secondaryCount ) ) ;
}
# endif
/** @{
* @ name Uniform setters
*
@ -2216,6 +2737,78 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL3D: public Implementation::MeshVisua
*/
MeshVisualizerGL3D & setSmoothness ( Float smoothness ) ;
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Set joint matrices
* @ return Reference to self ( for method chaining )
* @ m_since_latest
*
* Initial values are identity transformations . Expects that the size
* of the @ p matrices array is the same as @ ref jointCount ( ) .
*
* Expects that @ ref Flag : : UniformBuffers is not set , in that case fill
* @ ref TransformationUniform3D : : transformationMatrix and call
* @ ref bindJointBuffer ( ) instead .
* @ see @ ref setJointMatrix ( UnsignedInt , const Matrix4 & )
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
MeshVisualizerGL3D & setJointMatrices ( const Containers : : ArrayView < const Matrix4 > matrices ) ;
/**
* @ overload
* @ m_since_latest
*/
MeshVisualizerGL3D & setJointMatrices ( std : : initializer_list < Matrix4 > matrices ) ;
/**
* @ brief Set joint matrix for given joint
* @ return Reference to self ( for method chaining )
* @ m_since_latest
*
* Unlike @ ref setJointMatrices ( ) updates just a single joint matrix .
* Expects that @ p id is less than @ ref jointCount ( ) .
*
* Expects that @ ref Flag : : UniformBuffers is not set , in that case fill
* @ ref TransformationUniform3D : : transformationMatrix and call
* @ ref bindJointBuffer ( ) instead .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
MeshVisualizerGL3D & setJointMatrix ( UnsignedInt id , const Matrix4 & matrix ) ;
/**
* @ brief Set per - instance joint count
* @ return Reference to self ( for method chaining )
* @ m_since_latest
*
* Offset added to joint IDs in the @ ref JointIds and
* @ ref SecondaryJointIds in instanced draws . Should be less than
* @ ref jointCount ( ) . Initial value is @ cpp 0 @ ce , meaning every
* instance will use the same joint matrices , setting it to a non - zero
* value causes the joint IDs to be interpreted as
* @ glsl gl_InstanceID * count + jointId @ ce .
*
* Expects that @ ref Flag : : UniformBuffers is not set , in that case fill
* @ ref MeshVisualizerDrawUniform3D : : perInstanceJointCount and call
* @ ref bindDrawBuffer ( ) instead .
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
MeshVisualizerGL3D & setPerInstanceJointCount ( UnsignedInt count ) {
return static_cast < MeshVisualizerGL3D & > ( Implementation : : MeshVisualizerGLBase : : setPerInstanceJointCount ( count ) ) ;
}
# endif
/**
* @ }
*/
@ -2367,6 +2960,29 @@ class MAGNUM_SHADERS_EXPORT MeshVisualizerGL3D: public Implementation::MeshVisua
return static_cast < MeshVisualizerGL3D & > ( Implementation : : MeshVisualizerGLBase : : bindMaterialBuffer ( buffer , offset , size ) ) ;
}
/**
* @ brief Bind a joint matrix uniform buffer
* @ return Reference to self ( for method chaining )
* @ m_since_latest
*
* Expects that @ ref Flag : : UniformBuffers is set . The buffer is
* expected to contain @ ref jointCount ( ) instances of
* @ ref TransformationUniform3D .
* @ requires_gl31 Extension @ gl_extension { ARB , uniform_buffer_object }
* @ requires_gles30 Uniform buffers are not available in OpenGL ES 2.0 .
* @ requires_webgl20 Uniform buffers are not available in WebGL 1.0 .
*/
MeshVisualizerGL3D & bindJointBuffer ( GL : : Buffer & buffer ) {
return static_cast < MeshVisualizerGL3D & > ( Implementation : : MeshVisualizerGLBase : : bindJointBuffer ( buffer ) ) ;
}
/**
* @ overload
* @ m_since_latest
*/
MeshVisualizerGL3D & bindJointBuffer ( GL : : Buffer & buffer , GLintptr offset , GLsizeiptr size ) {
return static_cast < MeshVisualizerGL3D & > ( Implementation : : MeshVisualizerGLBase : : bindJointBuffer ( buffer , offset , size ) ) ;
}
/**
* @ }
*/
@ -2497,6 +3113,66 @@ class MeshVisualizerGL3D::Configuration {
}
# ifndef MAGNUM_TARGET_GLES2
/**
* @ brief Joint count
*
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt jointCount ( ) const { return _jointCount ; }
/**
* @ brief Per - vertex joint count
*
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt perVertexJointCount ( ) const { return _perVertexJointCount ; }
/**
* @ brief Secondary per - vertex joint count
*
* @ requires_gles30 Not defined on OpenGL ES 2.0 builds .
* @ requires_webgl20 Not defined on WebGL 1.0 builds .
*/
UnsignedInt secondaryPerVertexJointCount ( ) const { return _secondaryPerVertexJointCount ; }
/**
* @ brief Set joint count
*
* If @ ref Flag : : UniformBuffers isn ' t set , @ p count describes how many
* joint matrices get supplied to each draw by @ ref setJointMatrices ( )
* / @ ref setJointMatrix ( ) . If @ ref Flag : : UniformBuffers is set ,
* @ p count describes size of a @ ref TransformationUniform3D buffer
* bound with @ ref bindJointBuffer ( ) ; as uniform buffers are required
* to have a statically defined size . The per - vertex joints then index
* into the array offset by @ ref MeshVisualizerDrawUniform3D : : jointOffset .
* If @ p count is @ cpp 0 @ ce , skinning is not performed .
*
* The @ p perVertexCount and @ p secondaryPerVertexCount then describe
* how many components are taken from @ ref JointIds / @ ref Weights and
* @ ref SecondaryJointIds / @ ref SecondaryWeights attributes . Both
* values are expected to not be larger than @ cpp 4 @ ce , setting either
* of these to @ cpp 0 @ ce means given attribute is not used at all . If
* @ p count is @ cpp 0 @ ce , both @ p perVertexCount and
* @ p secondaryPerVertexCount is expected to be @ cpp 0 @ ce as well ; if
* @ p count is non - zero at least one of @ p perVertexCount and
* @ p secondaryPerVertexCount is expected to be non - zero as well .
*
* Default value for all three is @ cpp 0 @ ce .
* @ see @ ref MeshVisualizerGL2D : : jointCount ( ) ,
* @ ref MeshVisualizerGL2D : : perVertexJointCount ( ) ,
* @ ref MeshVisualizerGL2D : : secondaryPerVertexJointCount ( ) ,
* @ ref Flag : : DynamicPerVertexJointCount ,
* @ ref MeshVisualizerGL2D : : setPerVertexJointCount ( )
* @ requires_gl30 Extension @ gl_extension { EXT , gpu_shader4 }
* @ requires_gles30 Skinning requires integer support in shaders , which
* is not available in OpenGL ES 2.0 .
* @ requires_webgl20 Skinning requires integer support in shaders ,
* which is not available in WebGL 1.0 .
*/
Configuration & setJointCount ( UnsignedInt count , UnsignedInt perVertexCount , UnsignedInt secondaryPerVertexCount = 0 ) ;
/**
* @ brief Material count
*
@ -2562,7 +3238,10 @@ class MeshVisualizerGL3D::Configuration {
private :
Flags _flags ;
# ifndef MAGNUM_TARGET_GLES2
UnsignedInt _materialCount = 1 ,
UnsignedInt _jointCount = 0 ,
_perVertexJointCount = 0 ,
_secondaryPerVertexJointCount = 0 ,
_materialCount = 1 ,
_drawCount = 1 ;
# endif
} ;