Cortex
10.0.0-a4
|
A class to represent GLSL shaders. More...
#include <Shader.h>
Classes | |
class | Setup |
Public Member Functions | |
IE_CORE_DECLARERUNTIMETYPEDEXTENSION (IECoreGL::Shader, ShaderTypeId, IECore::RunTimeTyped) | |
Shader (const std::string &vertexSource, const std::string &fragmentSource) | |
Shader (const std::string &vertexSource, const std::string &geometrySource, const std::string &fragmentSource) | |
GLuint | program () const |
void | uniformParameterNames (std::vector< std::string > &names) const |
const Parameter * | uniformParameter (const std::string &name) const |
void | vertexAttributeNames (std::vector< std::string > &names) const |
Fills the passed vector with the names of all vertex shader parameters. | |
const Parameter * | vertexAttribute (const std::string &name) const |
IE_CORE_DECLAREPTR (Setup) | |
Source accessors. | |
These functions return the shader source as passed to the constructor. In the case of an empty string being returned, you can determine the effective source by calling defaultVertexSource() or defaultFragmentSource(). | |
const std::string & | vertexSource () const |
const std::string & | geometrySource () const |
const std::string & | fragmentSource () const |
Standard parameters | |
Cortex defines a set of standard shader parameters which are used to pass state to the shaders. These functions provide rapid access to the standard parameters if they exist.
| |
const Parameter * | csParameter () const |
![]() | |
IE_CORE_DECLAREMEMBERPTR (RunTimeTyped) | |
virtual TypeId | typeId () const |
virtual const char * | typeName () const |
virtual bool | isInstanceOf (TypeId typeId) const |
virtual bool | isInstanceOf (const char *typeName) const |
![]() | |
IE_CORE_DECLAREMEMBERPTR (RefCounted) | |
void | addRef () const |
Add a reference to the current object. | |
void | removeRef () const |
Remove a reference from the current object. | |
RefCount | refCount () const |
Returns the current reference count. | |
Static Public Member Functions | |
Common shader sources. | |
These functions return some common shader sources which may be useful in many situations. | |
static const std::string & | defaultVertexSource () |
static const std::string & | defaultGeometrySource () |
static const std::string & | defaultFragmentSource () |
static const std::string & | constantFragmentSource () |
This uses fragmentCs as a constant flat color. | |
static const std::string & | lambertFragmentSource () |
This passes fragmentP and fragmentN to ieDiffuse. | |
Built in shaders | |
These functions provide access to static instances of various simple but useful shaders. | |
static Shader * | constant () |
Returns a shader which shades as a constant flat color. | |
static Shader * | facingRatio () |
Returns a shader which shades as a facing ratio. | |
![]() | |
static TypeId | staticTypeId () |
Returns the TypeId for this class, without needing an instance. | |
static const char * | staticTypeName () |
Returns the type name for this class, without needing an instance. | |
static TypeId | baseTypeId () |
static const char * | baseTypeName () |
static bool | inheritsFrom (TypeId typeId) |
Returns true if this class inherits from the specified type. | |
static bool | inheritsFrom (const char *typeName) |
Returns true if this class inherits from the specified type. | |
static bool | inheritsFrom (TypeId type, TypeId baseType) |
Returns true if type inherits from baseType. | |
static bool | inheritsFrom (const char *typeName, const char *baseTypeName) |
Returns true if typeName inherits from baseTypeName. | |
static TypeId | baseTypeId (TypeId typeId) |
Returns the base type of the given type, or InvalidTypeId if no such base exists. | |
static const std::vector< TypeId > & | baseTypeIds (TypeId typeId) |
static const std::set< TypeId > & | derivedTypeIds (TypeId typeId) |
static TypeId | typeIdFromTypeName (const char *typeName) |
static const char * | typeNameFromTypeId (TypeId typeId) |
static void | registerType (TypeId derivedTypeId, const char *derivedTypeName, TypeId baseTypeId) |
Allows external modules to register their own type ids. | |
Additional Inherited Members | |
![]() | |
typedef RefCounted | BaseClass |
A typedef for the class this class derives from. All RunTimeTyped classes define this typedef. | |
![]() | |
typedef size_t | RefCount |
![]() | |
typedef std::map< TypeId, TypeId > | BaseTypeRegistryMap |
typedef std::map< TypeId, std::vector< TypeId > > | BaseTypesRegistryMap |
typedef std::map< TypeId, std::set< TypeId > > | DerivedTypesRegistryMap |
typedef tbb::spin_rw_mutex | Mutex |
typedef std::map< TypeId, std::string > | TypeIdsToTypeNamesMap |
typedef std::map< std::string, TypeId > | TypeNamesToTypeIdsMap |
![]() | |
static BaseTypeRegistryMap & | baseTypeRegistry () |
static DerivedTypesRegistryMap & | derivedTypesRegistry () |
static BaseTypesRegistryMap & | completeBaseTypesRegistry () |
static DerivedTypesRegistryMap & | completeDerivedTypesRegistry () |
static void | derivedTypeIdsWalk (TypeId typeId, std::set< TypeId > &) |
static TypeIdsToTypeNamesMap & | typeIdsToTypeNames () |
static TypeNamesToTypeIdsMap & | typeNamesToTypeIds () |
![]() | |
static Mutex | g_baseTypeIdsMutex |
static Mutex | g_derivedTypeIdsMutex |
A class to represent GLSL shaders.
IECoreGL::Shader::Shader | ( | const std::string & | vertexSource, |
const std::string & | fragmentSource | ||
) |
Either vertexSource or fragmentSource may be empty to use a simple default shader for that shader component. Throws a descriptive Exception if the shader fails to compile.
IECoreGL::Shader::Shader | ( | const std::string & | vertexSource, |
const std::string & | geometrySource, | ||
const std::string & | fragmentSource | ||
) |
Either vertexSource or fragmentSource may be empty to use a simple default shader for that shader component. If geometrySource is empty then no geometry shader will be used. Throws a descriptive Exception if the shader fails to compile.
const Parameter* IECoreGL::Shader::csParameter | ( | ) | const |
Returns the "uniform vec3 Cs" parameter used to specify constant colours to the shader.
|
static |
Default fragment shader source. This uses fragmentI, fragmentN and fragmentCs to compute a simple facing ratio.
|
static |
Default geometry shader source. This is provided to make a common interface, but is actually just a no-op.
|
static |
Default vertex shader source. This takes vertexP, vertexN, vertexuv, vertexCs and Cs inputs and sets fragmentI, fragmentP, fragmentN, fragmentuv and fragmentCs outputs. It also sets equivalent geometry* outputs which may be used by geometry shaders in calculating new values for the corresponding fragment* outputs.
GLuint IECoreGL::Shader::program | ( | ) | const |
const Parameter* IECoreGL::Shader::uniformParameter | ( | const std::string & | name | ) | const |
void IECoreGL::Shader::uniformParameterNames | ( | std::vector< std::string > & | names | ) | const |
Fills the passed vector with the names of all uniform shader parameters. Structures will use the struct.component convention used in GLSL. Arrays will be returned as a single name, rather than the list array[0], array[n] names used internally in OpenGL.
const Parameter* IECoreGL::Shader::vertexAttribute | ( | const std::string & | name | ) | const |