00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #pragma once
00015 #include "maxheap.h"
00016 #include "ref.h"
00017 #include "plugapi.h"
00018 #include "render.h"
00019
00020
00021 class LightObject;
00022 class ObjLightDesc;
00023 class RendContext;
00024 class RenderGlobalContext;
00025 class ShadeContext;
00026 class Color;
00027
00029
00030
00031
00032
00033
00034 #define SHAD_PARALLEL 2 // light is directional, parallel projection
00035 #define SHAD_OMNI 4 // generator can do omni, so do it on create
00036 #define SHAD_2SIDED 8 // both sides of geometry shd cast shadows
00037 #define MIN_SHADOW_MAP_SIZE 1.0f // Minimum allowed value for the shadow map size property
00038 #define MAX_SHADOW_MAP_SIZE 10000.0f // Maximum allowed value for the shadow map size property
00039 #define MIN_SHADOW_BIAS_VALUE 0.0f // Minimum allowed value for the shadow map bias property
00040 #define MAX_SHADOW_BIAS_VALUE 10000.0f // Maximum allowed value for the shadow map bias property
00041 #define MIN_SHADOW_SAMPLE_RANGE 0.01f // Minimum allowed value for the shadow map sample range property
00042 #define MAX_SHADOW_SAMPLE_RANGE 50.0f // Maximum allowed value for the shadow map sample range property
00043
00044 class ShadowGenerator;
00045 class AreaShadowGenerator;
00046 class IAreaShadowType;
00047 class ParamBlockDescID;
00048 class IParamBlock;
00049
00050 #pragma warning(push)
00051 #pragma warning(disable:4100)
00052
00053
00061 class ShadowParamDlg: public MaxHeapOperators {
00062 public:
00064 virtual ~ShadowParamDlg() {}
00066 virtual void DeleteThis()=0;
00067 };
00068
00069
00070
00071
00072
00073
00074 #define AREA_SHADOW_TYPE_INTERFACE_ID Interface_ID(0x68436888, 0x5b5b2ab0)
00075
00111 #pragma warning(push)
00112 #pragma warning(disable:4239)
00113 class ShadowType: public ReferenceTarget {
00114 public:
00115 SClass_ID SuperClassID() { return SHADOW_TYPE_CLASS_ID;}
00116 virtual ShadowParamDlg *CreateShadowParamDlg(Interface *ip) { return NULL; }
00117 virtual ShadowGenerator* CreateShadowGenerator(LightObject *l, ObjLightDesc *ld, ULONG flags)=0;
00118 virtual BOOL SupportStdMapInterface() { return FALSE; }
00119
00120 BOOL BypassPropertyLevel() { return TRUE; }
00121
00122
00123
00124
00125
00126 virtual BOOL CanDoOmni() { return FALSE; }
00127
00128
00129
00130 virtual void ConvertParamBlk( ParamBlockDescID *descOld, int oldCount, IParamBlock *oldPB ) { }
00131
00132
00133 virtual int MapSize(TimeValue t) { return 512; }
00134
00135
00136 virtual void SetMapRange(TimeValue t, float f) {}
00137 virtual float GetMapRange(TimeValue t, Interval& valid = Interval(0,0)) { return 0.0f; }
00138 virtual void SetMapSize(TimeValue t, int f) {}
00139 virtual int GetMapSize(TimeValue t, Interval& valid = Interval(0,0)) { return 0; }
00140 virtual void SetMapBias(TimeValue t, float f) {}
00141 virtual float GetMapBias(TimeValue t, Interval& valid = Interval(0,0)) { return 0.0f; }
00142 virtual void SetAbsMapBias(TimeValue t, int a) {}
00143 virtual int GetAbsMapBias(TimeValue t, Interval& valid = Interval(0,0)) { return 0; }
00144
00145
00146 virtual float GetRayBias(TimeValue t, Interval &valid = Interval(0,0)) { return 0.0f; }
00147 virtual void SetRayBias(TimeValue t, float f) {}
00148 virtual int GetMaxDepth(TimeValue t, Interval &valid = Interval(0,0)) { return 1; }
00149 virtual void SetMaxDepth(TimeValue t, int f) {}
00150
00151
00152
00153 IAreaShadowType* GetAreaShadowType();
00154
00155 };
00156
00157 #pragma warning(pop) // C4239
00158
00159
00160
00161 class IAreaShadowType : public BaseInterface {
00162 public:
00163
00164 virtual AreaShadowGenerator* CreateAreaShadowGenerator(LightObject *l, ObjLightDesc *ld, ULONG flags)=0;
00165
00166
00167
00168
00169 virtual void EnableAreaUI(bool onoff) {}
00170
00171
00172
00173 virtual float GetLength(TimeValue t) { return 0.0f; }
00174 virtual void SetLength(TimeValue t, float w) {}
00175 virtual float GetWidth(TimeValue t) { return 0.0f; }
00176 virtual void SetWidth(TimeValue t, float w) {}
00177 };
00178
00179 inline IAreaShadowType* ShadowType::GetAreaShadowType()
00180 {
00181 return static_cast<IAreaShadowType*>(GetInterface(AREA_SHADOW_TYPE_INTERFACE_ID));
00182 }
00183
00185
00186
00187
00188
00189
00190 #define TWO_SIDED_SHADOW_DEFAULT FALSE
00191
00192
00193
00214 class ShadowGenerator: public MaxHeapOperators {
00215 public:
00217 virtual ~ShadowGenerator() {}
00218
00252 virtual int Update(
00253 TimeValue t,
00254 const RendContext& rendCntxt,
00255 RenderGlobalContext *rgc,
00256 Matrix3& lightToWorld,
00257 float aspect,
00258 float param,
00259 float clipDist = DONT_CLIP
00260 )=0;
00261
00274 virtual int UpdateViewDepParams(const Matrix3& worldToCam)=0;
00275
00278 virtual void FreeBuffer()=0;
00280 virtual void DeleteThis()=0;
00281
00282
00283
00301 virtual float Sample(ShadeContext &sc, Point3 &norm, Color& color) { return 1.0f; }
00302
00303
00304
00305
00306
00338 virtual float Sample(ShadeContext &sc, float x, float y, float z, float xslope, float yslope) { return 1.0f; }
00358 virtual BOOL QuickSample(int x, int y, float z) { return 1; }
00389 virtual float FiltSample(int x, int y, float z, int level) { return 1.0f; }
00421 virtual float LineSample(int x1, int y1, float z1, int x2, int y2, float z2) { return 1.0f; }
00422
00423 };
00424
00425 #pragma warning(pop) // C4100
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436 class AreaShadowSampler;
00437
00438
00439 class AreaShadowGenerator : public ShadowGenerator {
00440 public:
00441
00442 virtual int GetSamplerSize() = 0;
00443
00444
00445
00446 virtual AreaShadowSampler* InitializeSampler(void* memory, ShadeContext& sc, bool antialias) = 0;
00447
00448
00449
00450 virtual int GetNumSamples() { return 1; }
00451 };
00452
00453
00454
00455 class AreaShadowSampler: public MaxHeapOperators {
00456 public:
00457 virtual ~AreaShadowSampler() {}
00458
00459
00460
00461
00462
00463
00464
00465
00466 virtual float Sample(
00467 ShadeContext& sc,
00468 const Point3& sourcePnt,
00469 Point3& norm,
00470 Color& color
00471 ) = 0;
00472 };
00473
00474
00477 CoreExport ShadowType *NewDefaultShadowMapType();
00478
00479
00482 CoreExport ShadowType *NewDefaultRayShadowType();
00483
00484