00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _OSGDVRISOSHADER_H_
00040 #define _OSGDVRISOSHADER_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044
00045 #include <vector>
00046
00047 #include <OSGConfig.h>
00048 #include <OSGWindow.h>
00049 #include <OSGGL.h>
00050 #include <OSGSystemDef.h>
00051 #include <OSGDVRShader.h>
00052 #include <OSGDrawActionBase.h>
00053 #include <OSGDVRVolume.h>
00054 #include <OSGDVRVolumeTexture.h>
00055 #include <OSGCamera.h>
00056 #include <OSGColor.h>
00057 #include <OSGFragmentProgramChunk.h>
00058
00059 #include <OSGDVRIsoShaderBase.h>
00060
00061 OSG_BEGIN_NAMESPACE
00062
00063
00067 class OSG_SYSTEMLIB_DLLMAPPING DVRIsoShader : public DVRIsoShaderBase
00068 {
00069 private:
00070
00071 typedef DVRIsoShaderBase Inherited;
00072
00073
00074 public:
00075
00076
00077
00078
00079 virtual bool initialize (DVRVolume *volume,
00080 DrawActionBase *action );
00081
00082
00083 virtual void activate (DVRVolume *volume,
00084 DrawActionBase *action );
00085
00086
00087 virtual void brickActivate (DVRVolume *volume,
00088 DrawActionBase *action,
00089 Brick *brick );
00090
00091
00092 virtual void deactivate (DVRVolume *volume,
00093 DrawActionBase *action );
00094
00095
00096 virtual void cleanup (DVRVolume *volume,
00097 DrawActionBase *action );
00098
00099
00100 virtual void renderSlice (DVRVolume *volume,
00101 DrawActionBase *action,
00102 Real32 *data,
00103 UInt32 vertices,
00104 UInt32 values );
00105
00106
00107 virtual void renderSlice (DVRVolume *volume,
00108 DrawActionBase *action,
00109 DVRRenderSlice *clippedSlice);
00110
00111
00112 virtual bool hasRenderCallback(void );
00113
00114
00115
00116 virtual bool useMTSlabs (void );
00117
00118
00122 virtual void changed(BitVector whichField,
00123 UInt32 origin);
00124
00126
00130 virtual void dump( UInt32 uiIndent = 0,
00131 const BitVector bvFlags = 0) const;
00133
00134
00135 protected:
00136
00137 enum ShadingMode
00138 {
00139 SM_AUTO = 0,
00140 SM_COLORMATRIX_2D,
00141 SM_COLORMATRIX_3D,
00142 SM_REGISTER_COMBINERS_2D,
00143 SM_REGISTER_COMBINERS_MULTI2D,
00144 SM_REGISTER_COMBINERS_3D,
00145 SM_FRAGMENT_PROGRAM_2D,
00146 SM_FRAGMENT_PROGRAM_3D,
00147 SM_NONE
00148 };
00149
00150 struct DirLight
00151 {
00152 Vec3f dir;
00153 Color4f color;
00154 };
00155
00156 typedef std::vector<DirLight> DirLightList;
00157
00158
00159 ImagePtr m_gradientImage;
00160
00161 bool m_hasPerStageConstants;
00162 GLint m_maxCombiners;
00163
00164 UInt8 m_shadingMode;
00165
00166 FragmentProgramChunkPtr m_pFragProg;
00167
00168 Int32 m_textureId;
00169
00170 GLint m_colorWriteMask[4];
00171
00172
00176 DVRIsoShader(void);
00177 DVRIsoShader(const DVRIsoShader &source);
00178
00180
00184 virtual ~DVRIsoShader(void);
00185
00188
00189 ImagePtr createGradientImage(DVRVolumeTexturePtr volTex);
00190
00191
00192
00193
00194
00195 bool checkGLVersion (GLfloat version );
00196
00197
00198 bool isModeSupported (DVRVolume *volume,
00199 DrawActionBase *action,
00200 UInt8 mode );
00201
00202
00203 UInt8 selectMode (DVRVolume *volume,
00204 DrawActionBase *action );
00205
00206
00207 bool tryMode (DVRVolume *volume,
00208 DrawActionBase *action,
00209 UInt8 mode );
00210
00211
00212 void getLightSources (DirLightList &diffuseLights,
00213 DirLightList &specularLights,
00214 Color4f &ambientLight );
00215
00216 void getCoveredScreenRect (DVRVolume *volume,
00217 DrawActionBase *action,
00218 GLfloat screenRect[4] );
00219
00220
00221 void activate_ColorMatrixShading (DVRVolume *volume,
00222 DrawActionBase *action );
00223
00224
00225 void deactivate_ColorMatrixShading (DVRVolume *volume,
00226 DrawActionBase *action );
00227
00228
00229 void activate_NVRegisterCombinerShading (DVRVolume *volume,
00230 DrawActionBase *action );
00231
00232
00233 void deactivate_NVRegisterCombinerShading (DVRVolume *volume,
00234 DrawActionBase *action );
00235
00236
00237 void activate_FragmentProgramShading (DVRVolume *volume,
00238 DrawActionBase *action );
00239
00240
00241 void deactivate_FragmentProgramShading (DVRVolume *volume,
00242 DrawActionBase *action );
00243
00244
00245 void renderSlice_NVRegisterCombinerShading(DVRVolume *volume,
00246 DrawActionBase *action,
00247 Real32 *data,
00248 UInt32 vertices,
00249 UInt32 values );
00250
00251
00252 void renderSlice_NVRegisterCombinerShading(DVRVolume *volume,
00253 DrawActionBase *action,
00254 DVRRenderSlice *clippedSlice );
00255
00256
00257 void renderSlice_FragmentProgramShading (DVRVolume *volume,
00258 DrawActionBase *action,
00259 Real32 *data,
00260 UInt32 vertices,
00261 UInt32 values );
00262
00263
00264 void renderSlice_FragmentProgramShading (DVRVolume *volume,
00265 DrawActionBase *action,
00266 DVRRenderSlice *clippedSlice );
00267
00268
00269 void setupCombinerParametersDiffuse (DVRVolume *volume,
00270 DrawActionBase *action );
00271
00272
00273 void setupCombinerParametersSpecular (DVRVolume *volume,
00274 DrawActionBase *action );
00275
00276
00277 void initCombiners_IsoSurfaceDiffuse (DrawActionBase *action );
00278
00279
00280
00281
00282 void initCombiners_Diffuse2Combiners (DrawActionBase *action );
00283
00284
00285
00286
00287
00288
00289 void initCombiners_DiffuseMultiCombiners (DrawActionBase *action );
00290
00291
00292 void initCombiners_IsoSurfaceSpecular (DrawActionBase *action );
00293
00294
00295
00296
00297
00298 void initCombiners_Specular2Combiners (DrawActionBase *action );
00299
00300
00301
00302
00303
00304 void initCombiners_SpecularMultiCombiners (DrawActionBase *action );
00305
00306
00307
00308 static char _fragProg2D[];
00309 static char _fragProg3D[];
00310
00311
00312 static UInt32 _ARB_multitexture;
00313 static UInt32 _EXT_texture3D;
00314 static UInt32 _EXT_secondary_color;
00315
00316 static UInt32 _NV_register_combiners;
00317 static UInt32 _NV_register_combiners2;
00318
00319 static UInt32 _SGI_color_matrix;
00320
00321 static UInt32 _ARB_fragment_program;
00322
00323
00324 static UInt32 _funcActiveTextureARB;
00325 static UInt32 _funcMultiTexCoord2dARB;
00326 static UInt32 _funcTexImage3DEXT;
00327
00328 static UInt32 _funcCombinerParameteriNV;
00329 static UInt32 _funcCombinerParameterfvNV;
00330 static UInt32 _funcCombinerStageParameterfvNV;
00331 static UInt32 _funcCombinerInputNV;
00332 static UInt32 _funcCombinerOutputNV;
00333 static UInt32 _funcFinalCombinerInputNV;
00334
00335 static UInt32 _funcSecondaryColor3fEXT;
00336 static UInt32 _funcSecondaryColor3fvEXT;
00337
00338
00339
00340 private:
00341
00342 friend class FieldContainer;
00343 friend class DVRIsoShaderBase;
00344
00345 static void initMethod(void);
00346
00347
00348 void operator =(const DVRIsoShader &source);
00349 };
00350
00351 typedef DVRIsoShader *DVRIsoShaderP;
00352
00353 OSG_END_NAMESPACE
00354
00355 #include "OSGDVRIsoShader.inl"
00356 #include "OSGDVRIsoShaderBase.inl"
00357
00358 #define OSGDVRISOSHADER_HEADER_CVSID "@(#)$Id: $"
00359
00360 #endif