samplers.h

Go to the documentation of this file.
00001 
00002 //
00003 //
00004 //  Sampler Plug-Ins
00005 //
00006 //  Created 11/30/98    Kells Elmquist
00007 //
00008 #pragma once
00009 
00010 #include <WTypes.h>
00011 #include "sfx.h"
00012 // forward declarations
00013 class ShadeOutput;
00014 class ShadeContext;
00015 
00016 // Default Sampler ClassId
00017 #define R25_SAMPLER_CLASS_ID            0x25773211
00018 #define DEFAULT_SAMPLER_CLASS_ID        R25_SAMPLER_CLASS_ID
00019 
00020 typedef ULONG   MASK[2];
00021 typedef SFXParamDlg SamplerParamDlg;
00022 
00029 class SamplingCallback : public InterfaceServer {
00030     public:
00045     virtual BOOL SampleAtOffset( ShadeOutput* pOut, Point2& sample, float sampleScale )=0;
00046 };
00047 
00048 class StdMat2;
00049 
00084 class Sampler : public SpecialFX {
00085     public:
00086         #pragma warning(push)
00087         #pragma warning(disable:4100)
00088         RefResult NotifyRefChanged(
00089             Interval changeInt, 
00090             RefTargetHandle hTarget, 
00091             PartID& partID, 
00092             RefMessage message ) { return REF_SUCCEED; }
00093 
00094         SClass_ID SuperClassID() { return SAMPLER_CLASS_ID; }
00095         
00096         // Saves and loads name. These should be called at the start of
00097         // a plug-in's save and load methods.
00104         IOResult Save(ISave *isave) { return SpecialFX::Save(isave); }
00111         IOResult Load(ILoad *iload) { return SpecialFX::Load(iload); }
00112 
00265         virtual void DoSamples(
00266             ShadeOutput* pOut, 
00267             SamplingCallback* cb, 
00268             ShadeContext* sc, 
00269             MASK mask = NULL) = 0;
00270     
00271         // integer number of samples for current quality
00276         virtual int GetNSamples()=0;    //what return when adaptive? n for max quality.
00277 
00278         // This is the one default parameter
00279         // Quality is nominal, 0...1, 
00280         // 0 is one sample, high about .75, 1.0 shd be awesome
00281         // for adaptive samplers, this sets the maximum quality
00287         virtual void SetQuality( float value )=0;
00295         virtual float GetQuality()=0;
00296         // returns 0 on "unchangeable", otherwise n quality levels
00299         virtual int SupportsQualityLevels()=0;
00300 
00305         virtual void SetEnable( BOOL samplingOn )=0;
00307         virtual BOOL GetEnable()=0;
00308 
00311         virtual MCHAR* GetDefaultComment()=0;
00312 
00313         // Adaptive Sampling, non-reqd methods
00314         // there are various optional params, this defines which ones to show/enable
00334         virtual ULONG SupportsStdParams(){ return 0; }
00335 
00336         // this determines whether to cut down the texture sample size of each sample, 
00337         // or whether to always use 1 pixel texture sample size
00347         virtual void SetTextureSuperSampleOn( BOOL on ){}
00352         virtual BOOL GetTextureSuperSampleOn(){ return FALSE; }
00353 
00361         virtual void SetAdaptiveOn( BOOL on ){}
00366         virtual BOOL IsAdaptiveOn(){ return FALSE; }
00367 
00375         virtual void SetAdaptiveThreshold( float value ){}
00379         virtual float GetAdaptiveThreshold(){ return 0.0f; }
00380 
00381         // there are 2 optional 0.0...max parameters, for whatever
00387         virtual long GetNOptionalParams(){ return 0; }
00395         virtual MCHAR * GetOptionalParamName( long nParam ){ return _M(""); }
00404         virtual float GetOptionalParamMax( long nParam ){ return 1.0f; }
00412         virtual float GetOptionalParam( long nParam ){ return 0.0f; };
00422         virtual void SetOptionalParam( long nParam, float val ){};
00423 
00424         // Put up a modal pop-up dialog that allows editing the sampler extended
00439         virtual void ExecuteParamDialog(HWND hWndParent, StdMat2* mtl ){}
00440 
00441         // Implement this if you are using the ParamMap2 AUTO_UI system and the 
00442         // effect has secondary dialogs that don't have the sampler as their 'thing'.
00443         // Called once for each secondary dialog for you to install the correct thing.
00444         // Return TRUE if you process the dialog, false otherwise.
00461         virtual BOOL SetDlgThing(EffectParamDlg* dlg) { return FALSE; }
00462         #pragma warning(pop)
00463     };
00464 
00465 // There are the standard parameters for samplers
00466 #define IS_ADAPTIVE                 0x1     // adaptive in some way
00467 #define ADAPTIVE_CHECK_BOX          0x2     // enable adaptive check box
00468 #define ADAPTIVE_THRESHOLD          0x4     // enable adaptive threshold spinner
00469 #define SUPER_SAMPLE_TEX_CHECK_BOX  0x8     // enable texture subsampling check box
00470 #define ADVANCED_DLG_BUTTON         0x10    // enable advanced button
00471 #define OPTIONAL_PARAM_0            0x20    // enable optional spinner
00472 #define OPTIONAL_PARAM_1            0x40    // enable optional spinner
00473 
00474 #define R3_ADAPTIVE                 (IS_ADAPTIVE+ADAPTIVE_CHECK_BOX+ADAPTIVE_THRESHOLD)     
00475 
00476 // Chunk IDs saved by base class
00477 #define SAMPLERBASE_CHUNK   0x39bf
00478 #define SAMPLERNAME_CHUNK   0x0100
00479 #define SAMPLER_VERS_CHUNK  0x0200
00480 
00481 
00482