1 | #pragma once
|
---|
2 | #include "renderer.h"
|
---|
3 | #include "RenderPass.h"
|
---|
4 |
|
---|
5 | #define SPTR boost::shared_ptr
|
---|
6 | #define WPTR boost::weak_ptr
|
---|
7 |
|
---|
8 | class RaytraceRenderer :
|
---|
9 | public Renderer
|
---|
10 | {
|
---|
11 |
|
---|
12 | public:
|
---|
13 |
|
---|
14 |
|
---|
15 | RaytraceRenderer(void);
|
---|
16 | ~RaytraceRenderer(void);
|
---|
17 |
|
---|
18 | virtual void init();
|
---|
19 | virtual void render();
|
---|
20 |
|
---|
21 | HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc );
|
---|
22 | virtual HRESULT OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext );
|
---|
23 | void OnLostDevice(void* pUserContext );
|
---|
24 | void OnDestroyDevice(void* pUserContext );
|
---|
25 | void RenderSceneInitialization();
|
---|
26 | IDirect3DTexture9* CreateTexture( int size, D3DFORMAT Format );
|
---|
27 | IDirect3DCubeTexture9* CreateCubeTexture( int size, D3DFORMAT Format );
|
---|
28 | IDirect3DSurface9* CreateDepthStencilSurface( int size );
|
---|
29 | void CreateVertexBuffer();
|
---|
30 | virtual void setCurrentTexture(IDirect3DTexture9* texture);
|
---|
31 | void setFresnelFactor(float _fresnel);
|
---|
32 | void setRefractionIndex(float _refraction);
|
---|
33 | void setNumberOfIterations(int _nbIteration);
|
---|
34 | virtual bool isLowerThan(Renderer* renderer);
|
---|
35 | D3DXMATRIX* getCubeMapProjectionMatrix();
|
---|
36 | D3DXMATRIX getCubeMapView(int nbView);
|
---|
37 | IDirect3DSurface9* getCubeMapSurface(int nbView);
|
---|
38 |
|
---|
39 | void blurDepthPass(int face);
|
---|
40 | void renderRefractionMap();
|
---|
41 | bool needsUpdate();
|
---|
42 | void renderDepth();
|
---|
43 | protected:
|
---|
44 | float nextUpdate;
|
---|
45 | int counter;
|
---|
46 | bool tempRenderMyNode;
|
---|
47 |
|
---|
48 | RenderPass rpDistance;
|
---|
49 |
|
---|
50 | D3DXMATRIX cubeMapProjectionMat;
|
---|
51 | LPDIRECT3DSURFACE9 pCubeMapDistSurf;
|
---|
52 |
|
---|
53 |
|
---|
54 | enum {
|
---|
55 | RENDER_ROOM_COLOR_DISTANCE,
|
---|
56 | RENDER_ROOM_UV,
|
---|
57 | RENDER_REFRACT_OBJECT_SCREEN,
|
---|
58 | };
|
---|
59 |
|
---|
60 | ID3DXEffect* g_pEffect; // D3DX effect interface
|
---|
61 | LPDIRECT3DSURFACE9 g_pRenderTargetSurfaceOld; // Store the original Screen's surface
|
---|
62 | LPDIRECT3DSURFACE9 g_pDepthStencilSurfaceOld; // Store the original Screen's DSS
|
---|
63 |
|
---|
64 | // Cube map textures
|
---|
65 | IDirect3DCubeTexture9* g_pRoomColorDistCubeMapTexture; // CubeMap for store: Color + Distance
|
---|
66 | //IDirect3DCubeTexture9* g_pRoomUVCubeMapTexture; // CubeMap for store: UV + ObjectID
|
---|
67 |
|
---|
68 | IDirect3DSurface9* g_pCubeMapDepthStencilSurface; // Depth-stencil buffer for rendering to cube texture
|
---|
69 | IDirect3DSurface9* g_pDepthStencilSurface; // Depth-stencil buffer for Room Texture
|
---|
70 |
|
---|
71 | bool g_bInitialization; // Initialization is in progress
|
---|
72 | bool g_bUseDistanceImpostors; // Use distance impostor method
|
---|
73 |
|
---|
74 | // Matrices
|
---|
75 | D3DXMATRIXA16 g_mWorldCenterObject; // World matrix of the CenterObject (scaling & offset)
|
---|
76 | D3DXMATRIXA16 g_mWorldViewLight; // Light's worldview matrix
|
---|
77 |
|
---|
78 | // Floats
|
---|
79 | float g_fFresnelFactor; // The Fresnel factor
|
---|
80 | float g_fRefractionIndex; // The Refraction index
|
---|
81 | D3DXVECTOR3 g_vCenterObjectPos; // Define the offset of the CenterObject
|
---|
82 | int g_iNumberOfIteration; // The number of the iteration of the algorithm.
|
---|
83 | };
|
---|