#pragma once #include "renderer.h" #include "RenderPass.h" #define SPTR boost::shared_ptr #define WPTR boost::weak_ptr class RaytraceRenderer : public Renderer { public: RaytraceRenderer(void); ~RaytraceRenderer(void); virtual void init(); virtual void render(); HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc ); virtual HRESULT OnResetDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ); void OnLostDevice(void* pUserContext ); void OnDestroyDevice(void* pUserContext ); void RenderSceneInitialization(); IDirect3DTexture9* CreateTexture( int size, D3DFORMAT Format ); IDirect3DCubeTexture9* CreateCubeTexture( int size, D3DFORMAT Format ); IDirect3DSurface9* CreateDepthStencilSurface( int size ); void CreateVertexBuffer(); virtual void setCurrentTexture(IDirect3DTexture9* texture); void setFresnelFactor(float _fresnel); void setRefractionIndex(float _refraction); void setNumberOfIterations(int _nbIteration); virtual bool isLowerThan(Renderer* renderer); D3DXMATRIX* getCubeMapProjectionMatrix(); D3DXMATRIX getCubeMapView(int nbView); IDirect3DSurface9* getCubeMapSurface(int nbView); void blurDepthPass(int face); void renderRefractionMap(); bool needsUpdate(); void renderDepth(); protected: float nextUpdate; int counter; bool tempRenderMyNode; RenderPass rpDistance; D3DXMATRIX cubeMapProjectionMat; LPDIRECT3DSURFACE9 pCubeMapDistSurf; enum { RENDER_ROOM_COLOR_DISTANCE, RENDER_ROOM_UV, RENDER_REFRACT_OBJECT_SCREEN, }; ID3DXEffect* g_pEffect; // D3DX effect interface LPDIRECT3DSURFACE9 g_pRenderTargetSurfaceOld; // Store the original Screen's surface LPDIRECT3DSURFACE9 g_pDepthStencilSurfaceOld; // Store the original Screen's DSS // Cube map textures IDirect3DCubeTexture9* g_pRoomColorDistCubeMapTexture; // CubeMap for store: Color + Distance //IDirect3DCubeTexture9* g_pRoomUVCubeMapTexture; // CubeMap for store: UV + ObjectID IDirect3DSurface9* g_pCubeMapDepthStencilSurface; // Depth-stencil buffer for rendering to cube texture IDirect3DSurface9* g_pDepthStencilSurface; // Depth-stencil buffer for Room Texture bool g_bInitialization; // Initialization is in progress bool g_bUseDistanceImpostors; // Use distance impostor method // Matrices D3DXMATRIXA16 g_mWorldCenterObject; // World matrix of the CenterObject (scaling & offset) D3DXMATRIXA16 g_mWorldViewLight; // Light's worldview matrix // Floats float g_fFresnelFactor; // The Fresnel factor float g_fRefractionIndex; // The Refraction index D3DXVECTOR3 g_vCenterObjectPos; // Define the offset of the CenterObject int g_iNumberOfIteration; // The number of the iteration of the algorithm. };