25#ifndef _SO_SHADER_PROGRAM_H_ 
   26#define _SO_SHADER_PROGRAM_H_ 
   28#include <Inventor/SbBasic.h> 
   29#include <Inventor/nodes/SoNode.h> 
   30#include <Inventor/nodes/SoNode.h> 
   31#include <Inventor/fields/SoMFNode.h> 
   32#include <Inventor/nodes/SoShaderParameter.h> 
   33#include <Inventor/nodes/SoFragmentShader.h> 
   34#include <Inventor/nodes/SoVertexShader.h> 
   35#include <Inventor/nodes/SoTessellationControlShader.h> 
   36#include <Inventor/nodes/SoTessellationEvaluationShader.h> 
   37#include <Inventor/nodes/SoTexture.h> 
   38#include <Inventor/nodes/SoGeometryShader.h> 
   39#include <Inventor/nodes/SoShaderParameterImage.h> 
   40#include <Inventor/STL/vector> 
   41#include <Inventor/STL/cassert> 
   42#include <Inventor/helpers/SbConstCharMap.h> 
   43#include <Inventor/elements/SoEnvironmentElement.h> 
   45#include <unordered_map> 
   46#include <Inventor/renderer/RendererResourceMacro.h> 
   47#include <Inventor/sensors/SoFileSensor.h> 
   52#pragma warning(disable:4251) 
   56class SoGLShaderProgram ;
 
   57class SoGLShaderObject;
 
   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  enum NotificationsPolicy
 
  527    DISABLE_NOTIFICATIONS,
 
  528    ENABLE_NOTIFICATIONS,
 
  532  void setDefine(
const char* name, 
const char* value, NotificationsPolicy notifPolicy = DISABLE_NOTIFICATIONS);
 
  534  void setDefine(
const char* name, 
const SbString& value, NotificationsPolicy notifPolicy = DISABLE_NOTIFICATIONS)
 
  536    setDefine(name, value.toLatin1(), notifPolicy);
 
  542  bool getDefine(
const char* name, SbString& value) 
const;
 
  545  void removeDefine(
const char* name);
 
  548  void setHeader(
const SbString& filename);
 
  551  void removeHeader(
const SbString& name);
 
  556  static GLint offsetToGLTextureUnit(SoGLRenderAction* action, 
const char* offset);
 
  561  static int offsetToTextureUnit(SoGLRenderAction* action, 
const char* offset);
 
  564  static void initClass();
 
  565  static void exitClass();
 
  571  bool isGlslProgram() 
const;
 
  574  bool isComputeShader() 
const;
 
  577  bool isShadowShader() 
const;
 
  583  void setShadowShader(
bool flag);
 
  587  void setHiddenShaderObject(
const char* objName, SoShaderObject* obj);
 
  590  void removeHiddenShaderObject(
const char* objName);
 
  593  SoShaderObject* getHiddenShaderObject(
const char* objName) 
const;
 
  596  const SbConstCharMap<SoShaderObject*>& getHiddenShaderObjects() 
const;
 
  599  static GPUVendorType getGPUVendorType();
 
  609    T* fp = (T*)getHiddenShaderObject(hiddenName);
 
  610    if (!fp || (fp->sourceProgram.getValue() != shaderSource))
 
  613      fp->sourceProgram.setValue(shaderSource);
 
  614      fp->sourceType = sourceType;
 
  615      setHiddenShaderObject(hiddenName, fp);
 
  621  void removeAllPrivateShaderType(SbEnums::ShaderType shaderType);
 
  624  enum ShaderLibraryState
 
  626    LIBRARY_NOT_INSTALLED,
 
  627    LIBRARY_INSTALLED_EMPTY,
 
  632  ShaderLibraryState getLibraryState( inventor::helper::ShaderLibrary* library ) 
const;
 
  635  void setLibraryState( inventor::helper::ShaderLibrary* library, ShaderLibraryState libraryState );
 
  637  bool getPreviousNeedDepthPeelingLibrary()
 const 
  639    return m_previousNeedDepthPeelingLibrary;
 
  643  void setIsFixedPipeline(
bool isFixedPipelineShader)
 
  645    m_isFixedPipelineShader = isFixedPipelineShader;
 
  649  bool isFixedPipeline()
 const 
  651    return m_isFixedPipelineShader;
 
  655  void setVertexProgramTwoSide(SoState* state, 
bool allowVertexTwoSideLighting = 
true);
 
  666  SoSFBool multiSampling;
 
  669  typedef std::vector<SoShaderObject*> ShaderObjectVector;
 
  670  typedef SbConstCharMap<SoShaderObject*> ShaderObjectMap;
 
  672  typedef SoShaderObject::DefineMap DefineMap;
 
  673  typedef SoShaderObject::HeaderSet HeaderSet;
 
  683    bool m_isShadowShader;
 
  686    ShaderObjectMap m_hiddenShaderObjects;
 
  691    std::vector<SoShaderObject*> m_prevShaderObject;
 
  692    std::vector< SoNode * > m_toUnrefShaderObjects;
 
  698    DefineMap m_defineMap;
 
  701    HeaderSet m_headerMap;
 
  712  SbBool isValidShaderObjects() 
const;
 
  716  SbBool isOneShaderObjectActive();
 
  719  static SoShaderProgram::Members* getMembers(
const SoShaderProgram* prog);
 
  723  SoMFNode prevShaderObject;
 
  726  void addDefines(SoShaderObject* obj);
 
  729  void addHeaders(SoShaderObject* obj);
 
  732  void addHiddenShaderObjects(ShaderObjectVector& shaderObjectsList);
 
  735  static bool lessVersion(SoShaderObject* obj1, SoShaderObject* obj2);
 
  738  static SbString getMaxVersion(
const ShaderObjectVector& objList);
 
  741  static bool lessProfile(SoShaderObject* obj1, SoShaderObject* obj2);
 
  745  static SbString getLoosestProfile(
const ShaderObjectVector& objList);
 
  748  bool hasShaderObjectsChanged() 
const;
 
  751  void updatePrevShaderObject();
 
  754  static void invalidate(ShaderObjectMap::value_type& p);
 
  757  void addGPUVendorDefine();
 
  760  void setShaderBufferObject(SoGLRenderAction* action);
 
  763  void setShaderTextureImages(SoGLRenderAction* action) 
const;
 
  769  void notifyAddedShaderObject(
const char* hiddenShaderObjectName);
 
  772  static void fileSensorCB(
void *data, SoSensor *) ;
 
  775  void updateFileSensor();
 
  778  std::unique_ptr<SoFileSensor> m_fileSensor;
 
  781  bool m_previousNeedDepthPeelingLibrary;
 
  783  typedef std::unordered_map<inventor::helper::ShaderLibrary*, ShaderLibraryState> ShaderLibraryStateMap;
 
  784  ShaderLibraryStateMap m_shaderLibrariesStates;
 
  787  static GPUVendorType s_gpuVendorType;
 
  790  static int s_firstUsedTextureUnit;
 
  793  static bool s_debugCache;
 
  796  bool m_isFixedPipelineShader;
 
 
Class for smart character strings.
<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.
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.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a>  Abstract node cl...
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...
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).
friend class SoUniformShaderParameter
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.