Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoVolumeShader.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : Benjamin GRANGE (Aug 2005)
22**=======================================================================*/
23
24
25#ifndef _SO_VOLUME_SHADER_H_
26#define _SO_VOLUME_SHADER_H_
27
28
29#include <Inventor/nodes/SoShaderProgram.h>
30#include <Inventor/nodes/SoShaderObject.h>
31#include <Inventor/nodes/SoFragmentShader.h>
32#include <Inventor/nodes/SoVertexShader.h>
33#include <Inventor/nodes/SoTextureUnit.h>
34#include <VolumeViz/nodes/SoVolumeRender.h>
35
36#include <Inventor/STL/cassert>
37#include <Inventor/STL/string>
38#include <Inventor/STL/vector>
39#include <Inventor/STL/map>
40
41/*----------------------------------------------------------------------------*/
42
43#ifdef _WIN32
44#pragma warning(push)
45#pragma warning(disable : 4251)
46#endif
47
48class SoVolumeData;
49class SoIsosurfaceTexture;
54class SoGroup;
55class SoTexture;
56
293
294 SO_NODE_HEADER(SoVolumeShader);
295
296public:
301
654
671
672
688
695 static SbBool isSupported(SoState* state=NULL) ;
696
701 virtual SoFragmentShader* setFragmentShader(int pos, const SbString& filenameOrSource,
703
709 virtual SoVertexShader* setVertexShader(int pos, const SbString& filenameOrSource,
711
712#ifndef HIDDEN_FROM_DOC
713private:
714
719 template<typename T>
720 T* getCustomShader(const ShaderPosition pos)
721 {
722 if (shaderObject.getNum() > pos )
723 return static_cast<T*>(shaderObject[pos]);
724 return NULL;
725 }
726
730 template<typename T>
731 T* setupPublicShaderStage(const ShaderPosition stagePos, const char* hiddenName, T* defaultShader)
732 {
733 T* fp = getCustomShader<T>(stagePos);
734 // There is no custom shader for this stage
735 if ( !fp )
736 return setupPrivateShaderStage<T>(hiddenName,defaultShader);
737 else
738 removeHiddenShaderObject(hiddenName);
739 return fp;
740 }
741
742
746 template<typename T>
747 T* setupPublicShaderStage(const ShaderPosition stagePos, const char* hiddenName, const SbString& shaderSource)
748 {
749 T* fp = getCustomShader<T>(stagePos);
750 // There is no custom shader for this stage
751 if ( !fp )
752 return setupPrivateShaderStage<T>(hiddenName, shaderSource);
753 else
754 removeHiddenShaderObject(hiddenName);
755 return fp;
756 }
757
762 template<typename T>
763 T* setupPrivateShaderStageNoOverride(const char* hiddenName, const SbString& shaderSource)
764 {
765 T* fp = (T*) getHiddenShaderObject(hiddenName);
766 if (fp == nullptr)
767 {
768 fp = new T;
769 fp->sourceProgram.setValue(shaderSource);
770 setHiddenShaderObject(hiddenName, fp);
771 }
772 return fp;
773 }
774
779 template<typename T>
780 T* setupPublicShaderStageNoOverride(const ShaderPosition stagePos, const char* hiddenName, const SbString& shaderSource)
781 {
782 T* fp = getCustomShader<T>(stagePos);
783 if (fp == nullptr)
784 return setupPrivateShaderStageNoOverride<T>(hiddenName, shaderSource);
785 else
786 removeHiddenShaderObject(hiddenName);
787 return fp;
788 }
789
793 bool isInternalFragment(SoFragmentShader* frag) const;
794
798 bool isInternalShaderObject(SoShaderObject* obj) const;
799
800 virtual void doAction(SoAction *action);
801
805 virtual void GLRender( SoGLRenderAction *action );
806
810 void installShaderProgram( SoGLRenderAction *action );
811
812 virtual void doRendering(SoGLRenderAction *action);
813
815 static void initClass() ;
816
818 static void exitClass() ;
819
824 SbBool isForVolumeOnly() { return forVolumeOnly.getValue(); }
825
830 static void setTexCoordVolUniform(SoState*state, SoVolumeData* vd, SoNode* node);
831
832 static int getFirstUsedTextureUnit(SoGLRenderAction* action);
833
835 void chooseLightConfig(SoState* state, bool forbidVertexTwoSide = false);
836
838 virtual void installTextures(SoGLRenderAction* ) {}
839
841 virtual SbBool isRaycastingEnabled(SoState* state) const;
842
844 virtual SbBool isVolumeGroupEnabled(SoState* state) const;
845
847 virtual void allocateTextureUnit(SoGLRenderAction *) const {}
848
852 static SbBool isTextureArrayEXTSupported(SoState* state);
853
858 static bool isRaycastingDefault()
859 { return s_forceRaycasting; };
860
861
862#if 1 SoDEPRECATED
864 void createRenderModeShaders(){}
865#endif
868 virtual bool isInterpolationActive(SoGLRenderAction* action);
869
871 bool mustUseOrthoCamera( SoState* state );
872
873private:
874
876 virtual void notify(SoNotList *list);
877
881 void installJitteringTexture(SoGLRenderAction* action);
882
886 void uninstallJitteringTexture();
887
889
890 // Clean a specified path:
891 // - converts the path to unix path.
892 // - removes the drive is the path is a windows path.
893 static SbString cleanUpFilePath( const SbString& string );
894
896 virtual SoShaderProgram* generateShadowShader() const;
897
902 void updateShaderSlots( SoState* state );
903
907 static const float DEFAULT_GRADIENT_THRESHOLD;
908
909 static const float DEFAULT_EDGE_THRESHOLD;
910
911 static const float DEFAULT_BOUNDARY_THRESHOLD;
912 static const float DEFAULT_BOUNDARY_INTENSITY;
913
914#endif //HIDEN_FROM_DOC
915
916#if 1
918SoINTERNAL private:SoDEPRECATED
920 SoSFBool raycasting;
921#endif
923private:
924
925 static const size_t JITTER_TEX_SIZE;
926
930 void createJitterTex();
931
936 bool hasToHandleFakeSoVolumeIsosurfaceStyle(SoState* state);
937 void handleFakeSoVolumeIsosurfaceStyle(SoGLRenderAction* action);
938
939 SoRef<SoGroup> m_jitterTextureGroup;
940 SoRef<SoTextureUnit> m_jitterTextureUnit;
941 SoRef<SoTexture2> m_jitterTexture;
942
944 SoVolumeDataDrawStyle* m_volumeDataDrawStyle;
945
946 static int s_texture_array_EXT_extensionID;
947 static bool s_forceRaycasting;
948};
949
950#ifdef _WIN32
951#pragma warning(pop)
952#endif
953
954#endif /*_SO_VOLUME_SHADER_H_*/
955
956
Class for smart character strings.
Definition SbString.h:202
Abstract base class for all actions.
Definition SoAction.h:132
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Node that define...
Renders a scene graph using Open Inventor's Render Engine.
Base class for all group nodes.
Definition SoGroup.h:122
Field interactive complexity node.
int getNum() const
Returns the number of values currently in the field.
Definition SoMField.h:146
This class is a cache handler that can be used to monitor the modifications made to elements or field...
Abstract base class for all database nodes.
Definition SoNode.h:145
Smart pointer for any class inheriting SoRefCounter.
Definition SoRef.h:90
Field containing a single Boolean value.
Definition SoSFBool.h:79
SbBool getValue() const
Returns this field's value.
Definition SoSFBool.h:82
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract node cl...
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 program p...
SoMFNode shaderObject
Specifies the list of shader objects (i.e., vertex shaders, geometry and fragment shaders) which form...
Traversal state.
Definition SoState.h:74
Abstract base class for texture mapping nodes.
Definition SoTexture.h:155
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Node that define...
<a href="IconLegend.html"><img src="extVR.gif" alt="VolumeViz" border="0"></a> Volume draw style.
<a href="IconLegend.html"><img src="extVR.gif" alt="VolumeViz" border="0"></a> Volume data property ...
<a href="IconLegend.html"><img src="extVR.gif" alt="VolumeViz" border="0"></a> Volume rendering qual...
<a href="IconLegend.html"><img src="extVR.gif" alt="VolumeViz" border="0"></a> Shader node for volum...
SoSFBool interpolateOnMove
When set to FALSE, interpolation between LDM tiles (across the tile boundary) is not done when render...
virtual SoVertexShader * setVertexShader(int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
Creates a vertex shader with the given filename and adds it at the given pos.
static SbBool isSupported(SoState *state=NULL)
Returns TRUE if SoVolumeShader is supported by the current graphics board.
virtual SoFragmentShader * setFragmentShader(int pos, const SbString &filenameOrSource, SoShaderObject::SourceType sourceType=SoShaderObject::FILENAME)
Creates a fragment shader with the given filename and add it at the given pos.
SoVolumeShader()
Constructor.
SoSFBool forVolumeOnly
Set to TRUE if the shader should be called for volume rendering (SoVolumeRender).
ShaderPosition
Specifies the position of the shader pipeline stages in the field shaderObject.
@ VERTEX_MAIN
Main vertex shader used for rendering.
@ TESS_VERTEX_SHIFT
Shader function used to modify the position of vertices during HeightField rendering.
@ CLIPPING_FUNCTION
This method can be used to implement a custom clipping algorithm.
@ CUSTOM_SHADER
This position and all subsequent positions CUSTOM_SHADER+x are freely available for user-defined shad...
@ GEOMETRY_MAIN
The main geometry program used for rendering.
@ FRAGMENT_MAIN
Main fragment shader used for rendering.
@ DATA_COMBINE_FUNCTION
This shader is used for GPU multi-data composition.
@ FRAGMENT_COMPUTE_COLOR
This shader is used to compute the current fragment color.
@ VERTEX_POSTPROCESSING
Method called at the end of the VolumeViz vertex shader stage.
@ GET_DATA_FUNCTION
This shader is used to access datasets.
int SbBool
Boolean type.
Definition SbBase.h:87