25#ifndef _SO_SHADER_PROGRAM_H_
26#define _SO_SHADER_PROGRAM_H_
40#include <Inventor/STL/vector>
41#include <Inventor/STL/cassert>
45#include <unordered_map>
46#include <Inventor/renderer/RendererResourceMacro.h>
52#pragma warning(disable:4251)
56class SoGLShaderProgram ;
57class SoGLShaderObject;
65namespace inventor {
namespace helper {
class ShaderLibrary; } }
66namespace inventor {
namespace renderer {
class ShaderStateUniforms; } }
468 virtual void doAction(
SoAction *action);
477 GPU_TYPE_NOT_INITIALIZED = -1,
486 enum { MAX_IMG_UNITS = 8 };
489 static const char* getMainSlotName(SbEnums::ShaderType shaderType);
492 bool hasPrivateMainShaderType(SbEnums::ShaderType shaderType)
const;
495 bool hasPublicMainShaderType(SbEnums::ShaderType shaderType)
const;
498 bool hasMainShaderType(SbEnums::ShaderType shaderType)
const;
501 bool hasFixedPipelineMainShaderType(SbEnums::ShaderType shaderType)
const;
504 bool hasFixedPipelineMain()
const;
507 void getAllParameters(
SoState* state, std::vector<SoUniformShaderParameter*>& shaderParameters);
510 void getShaderObjects(std::vector<SoShaderObject*>& shaderObjectsList)
const;
513 SbString getLinkedShaderFileNames(SbEnums::ShaderType shaderType)
const;
516 void displayLinkedFileNames()
const;
519 static bool isOivReservedName(
const std::string ¶mName);
522 virtual void notify(SoNotList *list);
525 void setDefine(
const char* name,
const char* value);
526 void setDefine(
const char* name,
const SbString& value)
527 { setDefine(name,value.toLatin1()); }
532 bool getDefine(
const char* name,
SbString& value)
const;
535 void removeDefine(
const char* name);
538 void setHeader(
const SbString& filename);
541 void removeHeader(
const SbString& name);
551 static int offsetToTextureUnit(
SoGLRenderAction* action,
const char* offset);
554 static void initClass();
555 static void exitClass();
561 bool isGlslProgram()
const;
564 bool isComputeShader()
const;
567 bool isShadowShader()
const;
573 void setShadowShader(
bool flag);
577 void setHiddenShaderObject(
const char* objName,
SoShaderObject* obj);
580 void removeHiddenShaderObject(
const char* objName);
586 const SbConstCharMap<SoShaderObject*>& getHiddenShaderObjects()
const;
589 static GPUVendorType getGPUVendorType();
599 T* fp = (T*)getHiddenShaderObject(hiddenName);
600 if (!fp || (fp->sourceProgram.getValue() != shaderSource))
604 fp->sourceType = sourceType;
605 setHiddenShaderObject(hiddenName, fp);
611 void removeAllPrivateShaderType(SbEnums::ShaderType shaderType);
614 enum ShaderLibraryState
616 LIBRARY_NOT_INSTALLED,
617 LIBRARY_INSTALLED_EMPTY,
622 ShaderLibraryState getLibraryState( inventor::helper::ShaderLibrary* library )
const;
625 void setLibraryState( inventor::helper::ShaderLibrary* library, ShaderLibraryState libraryState );
627 bool getPreviousNeedDepthPeelingLibrary()
const
629 return m_previousNeedDepthPeelingLibrary;
633 void setIsFixedPipeline(
bool isFixedPipelineShader)
635 m_isFixedPipelineShader = isFixedPipelineShader;
639 bool isFixedPipeline()
const
641 return m_isFixedPipelineShader;
645 typedef std::vector<SoShaderObject*> ShaderObjectVector;
646 typedef SbConstCharMap<SoShaderObject*> ShaderObjectMap;
648 typedef SoShaderObject::DefineMap DefineMap;
649 typedef SoShaderObject::HeaderSet HeaderSet;
659 bool m_isShadowShader;
662 ShaderObjectMap m_hiddenShaderObjects;
667 std::vector<SoShaderObject*> m_prevShaderObject;
668 std::vector< SoNode * > m_toUnrefShaderObjects;
674 DefineMap m_defineMap;
677 HeaderSet m_headerMap;
688 SbBool isValidShaderObjects()
const;
692 SbBool isOneShaderObjectActive();
695 static SoShaderProgram::Members* getMembers(
const SoShaderProgram* prog);
708 void addHiddenShaderObjects(ShaderObjectVector& shaderObjectsList);
714 static SbString getMaxVersion(
const ShaderObjectVector& objList);
721 static SbString getLoosestProfile(
const ShaderObjectVector& objList);
724 bool hasShaderObjectsChanged()
const;
727 void updatePrevShaderObject();
730 static void invalidate(ShaderObjectMap::value_type& p);
733 void addGPUVendorDefine();
747 void notifyAddedShaderObject(
const char* hiddenShaderObjectName);
750 static void fileSensorCB(
void *data,
SoSensor *) ;
753 void updateFileSensor();
756 std::unique_ptr<SoFileSensor> m_fileSensor;
759 bool m_previousNeedDepthPeelingLibrary;
761 typedef std::unordered_map<inventor::helper::ShaderLibrary*, ShaderLibraryState> ShaderLibraryStateMap;
762 ShaderLibraryStateMap m_shaderLibrariesStates;
765 static GPUVendorType s_gpuVendorType;
768 static int s_firstUsedTextureUnit;
771 static bool s_debugCache;
774 bool m_isFixedPipelineShader;
#define GL_TRIANGLE_STRIP
#define SO_NODE_HEADER(className)
Class for smart character strings.
Abstract base class for all actions.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Node that define...
Sensor class that can be attached to Open Inventor fields.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Node that define...
static SoType getClassTypeId()
Returns the type identifier for this class.
Renders a scene graph using Open Inventor's Render Engine.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Node that define...
static SoType getClassTypeId()
Returns the type identifier for this class.
Computes bounding box of a scene.
Abstract base class for all light source nodes.
Multiple-value field containing any number of nodes.
int getNum() const
Returns the number of values currently in the field.
Abstract base class for all database nodes.
Abstract base class for picking objects in a scene.
Field containing a single Boolean value.
Field containing an enumerated value.
Field containing a int32_t integer.
void setValue(const SbString &newValue)
Sets this field to newValue.
Abstract base class for Open Inventor sensors.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract node cl...
SoSFFilePathString sourceProgram
Contains the shader object's source program, specified by a filename (sourceType set to FILENAME) or ...
virtual SoType getTypeId() const
Returns the type identifier for this specific instance.
SourceType
Shader Object source type possible values.
@ FILENAME
Only the name of the file containing the source is given (default).
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Shader parameter...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Shader parameter...
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Shader program p...
virtual SoFragmentShader * setFragmentShader(int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
Convenience method to create a fragment shader with the specified filename and add it at the specifie...
SoSFBool vertexProgramTwoSide
If set to TRUE, vertex shaders will operate in two-sided color mode.
GeometryInputType
Geometry input type.
@ POINTS_INPUT
The input geometry should be interpreted as points.
@ LINES_INPUT
The input geometry should be interpreted as lines.
@ TRIANGLES_INPUT
The input geometry should be interpreted as triangles.
SoTessellationEvaluationShader * getTessellationEvaluationShader(int pos) const
Returns the tessellation evaluation shader at the specified position.
SoSFEnum geometryInputType
Specifies the input primitive type of the current geometry shader if any (not used otherwise).
SoShaderParameterImage * addShaderParameterImage(const SbString &name, SoTexture *tex)
Convenience method to create an SoShaderParameterImage with the specified name and value and add it t...
SoGeometryShader * getGeometryShader(int pos) const
Returns the geometry shader at the specified position.
virtual SoComputeShader * setComputeShader(int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
Convenience method to create a compute shader with the specified filename and add it at the specified...
SoMFNode images
Specifies a list of SoShaderParameterImage nodes to use with this shader.
SoSFBool shadowShader
Only used when an SoShadowGroup is active.
GeometryOutputType
Geometry ouput type.
@ TRIANGLE_STRIP_OUTPUT
Default.
SoSFEnum geometryOutputType
Specifies the output primitive type of the current geometry shader if any (not used otherwise).
SoSFBool generateTransparency
If set to TRUE, then shapes affected by this shader will be considered transparent.
SoFragmentShader * getFragmentShader(int pos) const
Returns the fragment shader at the specified position.
static unsigned int getNumReservedTextures()
Returns the number of reserved texture units.
SoVertexShader * getVertexShader(int pos) const
Returns the vertex shader at the specified position.
SoShaderProgram()
Constructor.
SoTessellationControlShader * getTessellationControlShader(int pos) const
Returns the tessellation control shader at the specified position.
virtual SoVertexShader * setVertexShader(int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
Convenience method to create a vertex shader with the specified filename and add it at the specified ...
SoMFNode shaderObject
Specifies the list of shader objects (i.e., vertex shaders, geometry and fragment shaders) which form...
virtual SoTessellationControlShader * setTessellationControlShader(int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
Convenience method to create a tessellation control shader with the specified filename and add it at ...
virtual SoTessellationEvaluationShader * setTessellationEvaluationShader(int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
Convenience method to create a tessellation evaluation shader with the specified filename and add it ...
SoSFInt32 maxGeometryOutputVertices
Set the maximum number of vertices the geometry shader will emit in one invocation.
SoMFNode bufferObjects
Specifies a list of SoShaderParameterBufferObject to use with this shader.
virtual SoGeometryShader * setGeometryShader(int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
Convenience method to create a geometry shader with the specified filename and add it at the specifie...
SoSFInt32 patchLength
Set the length of the fixed-size collection of vertices used by tessellation shaders.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Node that define...
static SoType getClassTypeId()
Returns the type identifier for this class.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Node that define...
static SoType getClassTypeId()
Returns the type identifier for this class.
Abstract base class for texture mapping nodes.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Node that define...
static SoType getClassTypeId()
Returns the type identifier for this class.