Home

Documentation - Mahmoud Zeidan

image

Contents

1. Sets whether or not the depth buffer check is performed before a pixel write param enabled If true the depth buffer is tested for each pixel and the frame buffer is only updated if the depth function test succeeds If false no test is performed and pixels are always written g virtual wold seltDepthButterCheckEnabled bBeol enabled Trus 0 Sets whether or not the depth buffer is updated after a pixel write param enabled If true the depth buffer is updated with the depth of the new pixel if the depth test succeeds If false the depth buffer is left unchanged even if a new pixel is written ifi virtual void setDepthBufferWriteEnabled bool enabled true 0 Sets the comparison function for the depth buffer check Advanced use only allows you to choose the function applied to compare the depth values of new and existing pixels in the depth buffer Only an issue 1f the deoth buffer check is enabled Bee serDeprihbu rrercheckEnabled param func The comparison between the new depth and the existing depth which must return true for the new pixel to be written jr virtual valid setDeptaButterFunetion ComparerFunction func CMPF LESS EQUAL 0 Sets the depth bias NB you should use the Material version DEI TAS remarks When polygons are coplanar you can get problems with depth fighting where the pixels from the two polys compete for the same screen pixel This is particularly a problem for decals p
2. Detaches the render target with the passed name from the render system and returns a pointer to it note If the render target cannot be found NULL is returned sf Ps virtual RenderTarget detachRenderTarget const String amp name Returns a description of an error code ia virtual CString getErrorDescription long errorNumber 0 Defines whether or now fullscreen render windows wait for the vertical blank before flipping buffers remarks By default all rendering windows wait for a vertical blank when the CRT beam turns off briefly to move from the bottom right of the screen back to the top left before flipping the screen buffers This ensures that the image you see on the screen is steady However it restricts the frame rate to the refresh rate of the monitor and can slow the frame rate down You can speed this up by not waiting for the blank but this has the downside of introducing tearing artefacts where part of the previous frame is still displayed choose affects quality monitor classes as the buffers are switched Speed vs quality you note Has NO effect on windowed mode render targets Only fullscreen mode param enabled If true the system waits for vertical blanks over speed If false it doesn t speed over quality sf void setWaitForVerticalBlank bool enabled Returns true if the system is synchronising frames with the vertical blank ar bool getWait
3. Real pNormals The Stride between sets of normal data 0 indicates data is packed with no gaps unsigned short normalStride Optional texture coordinates for vertices float u v w numVertices remarks There can be up to 8 sets of texture coordinates and the number of components per vertex depends on the number of texture dimensions 2 1s most common wy Real pTexCoords MAX TEXTURE COORD SETS The Stride between each set of texture data 0 indicates data is packed with no gaps unsigned short texCoordStride MAX TEXTURE COORD SETS Number of groups of u v w int numTextureCoordSets Number of dimensions in each corresponding texture coordinate set note There should be 1 4 dimensions on each set int numTextureDimensions MAX TEXTURE COORD SETS Optional pointer to a list of diffuse vertex colours 32 bit RGBA numVertices RGBA pDiffuseColour The Stride between sets of diffuse colour data 0 indicates data is packed with no gaps unsigned short diffuseStride Optional pointer to a list of specular vertex colours 32 bit RGBA numVertices RGBA pSpecularColour The Stride between sets of specular colour data 0 indicates data is packed with no gaps unsigned short specularStride Pointer to a list of vertex indexes describing faces only used if uselndexes is true note Bach group of 3 describes a face anticlockwise winding or
4. Veer SIA Under Supervision of Dr Zaki Taha Project Team Mahmoud Mostafa Mahmoud Zeidan Ahmed Ismaiel Zakaria Ahmed Mohamed Hamdy Amr Gamgom Salma Hamdy Assistants Photonix is a Real time 3D CAD Modeler that support most of special effects and accurate light model using photon mapping with best performance Acknowledgements Weindebted to our families who helped and took care of us We are grateful to our supervisor Dr Zaki Taha Ain Shams University We also wish to thank our assistants Amro Gamgom and Salma Hamdy Many thanks to our teachers during our early learning years and our professors during our collegiate years and our kind assistants Preface Computer graphics represent a technology that is rooted in many disciplines Virtual reality Particle Real life Simulation fog fire smoke etc Character modeling and animation Entertainment movies Games Physics laser lighting applications Computer aided design CAD computer aided manufacturing CAM and Advertising As the computer Hard Ware technology is increasingly updating computer graphics also follow the same steps of developing The final goal of computer graphics is to generate realistic images as same as it was taken by human eye and to simulate realistic images as much as possible So our project is a large step to this goal which get a realistic images as the same as it was taken by a photographic camera using a new technique for
5. be endif 3 OpenGL Render System Implementation ifndef GLRenderSystem H _ define GLRenderSystem H _ include GLPrerequisites h include GSMIncludes h include stdimage h include GLSupport h include GSMIncludes h include RenderSystem h Implementation of SDL as a rendering system ui class GLRenderSystem public RenderSystem publis static GLenum m ImageComponents STDImage IT QUANTITY static GLenum m ImageFormats STDImage IT QUANTITY maps from Magic enums to OpenGL enums static GLenum m TextureCorrection Material TextureLayer CM QUANTITY static GLenum m TextureApply Material TextureLayer AM QUANTITY static GLenum m TextureFilter Material TextureLayer EM QUANTITY static GLenum m TextureCombineFunc Material TextureLayer ACF QUANTITY static GLenum m TextureCombineSrc Material TextureLayer ACS QUANTITY static GLenum m TextureCombineOperand Material TextureLayer ACO QUANTITY static GLfloat m TextureCombineScale Material TextureLayer ACSC QUANTITY static GLenum m TextureMipmap Material TextureLayer MM QUANTITY Array of up to 8 lights indexed as per API Note that a null value indicates a free slot define MAX LIGHTS 8 Light mLights MAX LIGHTS view matrix to set world against Matrix4 mViewMatrix Matrix4 mWorldMatrix Matrix4 mTextureMatrix XXX 8 max texture units int mTextureCoordIndex MAX TEXTURE COORD SETS v
6. Login Form Hi admin Logout Photonix Microsoft Internet Explorer File Edit View Favorites Toole Help Home G Downloads 3 Screenshots 3 Contact Us F Home Downloads RR AAA o SS ASAS SA EEE EEE PLU E HN HH LEE EL Who s Online User Menu we hawe 1 member online Tour Details Submit News Main Menu Home Login Form Downloads Hi admin Screenshots Logout Contact Us Photonix File Repository Category Files se Demos i source code 1 Executables 1 Ee Hit Counter 18 visitors CA Search Submit File Repository ln Figure2 19 Download Page Applications Virtual reality Particle Real life Simulation fog fire smoke etc Character modeling and animation Entertainment movies Games Physics laser lighting applications CAD CAM designing Advertising e Virtual reality As the photon mapping algorithm reach the computer graphics to high degree of reality so we can use computers to simulate real environments and real scenes e Particle Real life Simulation fog fire smoke etc This on of the main applications of the photon mapping technique since smoke and fires are the hardest particle system simulations and photon mapping ease the modeling of these systems e Character modeling and animation Photon mapping reach a reality in images of human skin using a technique called Digital Face Cloning invented by Henrik Wann Jensen and next figure indicate the
7. The number specified after the keyword controls how much adapt ve sampling is used The higher the number the more accurate your shadows will be but the longer they will take to render When performing adaptive sampling it starts by shooting a test ray at each of the four corners of the area light If the amount of light received from all four corners is approximately the same then the area light is assumed to be either fully in view or fully blocked The light intensity is then calculated as the average intensity of the light received from the four corners However 1f the light intensity from the four corners differs significantly then the area light is partially blocked The area light is split into four quarters and each section is sampled as described above This allows to rapidly approximating how much of the area light is in view without having to shoot a test ray at every light in the array Visually the sampling goes like shown below level 0 level 1 level 2 2x2 rays 3X3 rays 5x5 rays e O oO 000 O eee eee 000 O Figure 2 5 e OS 0 OOO new ray samples O samples reused from the previous level Area light adaptive samples While the adaptive sampling method is fast relatively speaking it can sometimes produce inaccurate shadows The solution is to reduce the amount of adaptive sampling without completely turning it off The number after the adaptive keyword adjusts the number of times that the area light will be split befo
8. SetViewport CViewPort vp See RenderSystem void beginFrame void See RenderSystem K void render RenderOperation Op See RenderSystem void endFrame void See RenderSystem void setCullingMode CullingMode mode See RenderSystem ui void setDepthBufferParams bool depthTest true bool depthWrite true CompareFunction depthrFunction CMPF LESS EQUAL See RenderSystem a void setDepthBufferCheckEnabled bool enabled true See RenderSystem m void setDepthBufferWriteEnabled bool enabled true See RenderSystem 7 void setDepthBufferFunction CompareFunction func CMPF LESS EQUAL See RenderSystem sy void setDepthBias ushort bias See RenderSystem m7 void setFog FogMode mode ColourValue colour Real density Real start Real end See RenderSystem g void makeProjectionMatrix Real fovy Real aspect Real nearPlane Real farPlane Matrix4 amp dest See RenderSystem a void setRasterisationMode SceneDetailLevel level See RenderSystem void setStencilCheckEnabled bool enabled See RenderSystem sy bool hasHardwareStencil void See RenderSystem I ushort getStencilBufferBitDepth void See RenderSystem S void setStencilBufferFunction CompareFunction func See RenderSystem void setStencilBufferReferenceValue ulong refValue See RenderSystem sy void setStencilBufferMask ulong
9. a similar size rectangular area light Increase your axis vectors accordingly if you wish to keep the light source area constant e 3D Editor and Modeler Engine The 3D Editor phase is the most important phase in the project because it helps the users to interact with the application and produce output generated using the global 1llumination algorithms specified above The 3D Engine we made to build our 3d modeler above 1t mainly consists of 1 Renderables Al IRenderable ri GUDIWnd LineMesh TorusMesh GUIButton Mesh GUIWindow k MeshBox j Boxbesh ocene ode Conelvlesh Spherellesh d Gridhlesh 1 SuperElipsoid i Rendering aria u EE Figure 2 6 Win32Window_ RenderTexure G GLRenderTexture Which they are the set of classes that can be rendered on the screen using different Graphics platforms Like Opengl amp DirectX The figure shown is the hierarchy chart of base class and inheritance And here are some of the classes and its description GUIWindow Representation of a regular window Representation of bounding box Representation of cone object SceneNode Base node in the hierarchy tree 2 Event Providers IEventFrovider FrameProvider _TWindowMessageProvider Render Window IMessageProvider lienericldessageFrowider IMouseProvider GUIWindow This is the part where the events of the operating system are ha
10. algor thm Difference between Direct and Indirect illumination Soft Shadow Effect output image without and with Focal Blur Effect Output of Participating media and particle system direct light specular light indirect light and caustics Visualization of the four terms evaluated for each pixel The four terms added together forming the final image 4x4 Area Light location and vectors Area Light Adaptive samples Renderable Class design Event Provides Class Design Utilities design Screen Shots of the Application Screen Shot of the application Screen Shot of the application Photon Mapping Output Soft Shadows Focal Blur Atmospheric Media Fog Sky Sphere Systems Project Web Site Download Page Real Life Particle Simulations Character Modeling Facial Animation and games Laser Lighting Applications Advertising Application Page Number 5 5 5 6 6 10 10 10 14 15 16 17 18 19 20 21 22 23 24 25 26 23 27 21 28 1 Introduction The use of computer graphics is today growing faster than ever Especially in the entertainment industry but also in the product developing industry in general where it is an invaluable tool for construction design and visualization Much work has been done to make the computer generated images as realistic as possible The goal is to produce images that cannot be distinguished from real life I II Problem Definition The project tries to find answers to th
11. applications since the SceneManager and various support classes will be responsible for calling this method Can only be called between beginScene and endScene param op A rendering operation instance which contains details of the operation to be performed y virtual void render RenderOperation op Jee Ends rendering of a frame to the current viewport itd virtual void endFrame void 0 RR Sets the provided viewport as the active one for future rendering operations This viewport is aware of it s own camera and render target Must be implemented by subclass param target Pointer to the appropriate viewport 7 amp virtual void setViewport Viewport vp Get the current active viewport for rendering amp virtual Viewport getViewport void Sets the culling mode for the render system based on the vertex winding A typical way for the rendering engine to cull triangles is based on the vertex winding of triangles Vertex winding refers to the direction in which the vertices are passed or indexed to in the rendering operation as viewed from the camera and will wither be clockwise or anticlockwise that s counterclockwise for you Americans dut there The default is CULL CLOCKWISE i e that only triangles whose vertices are passed indexed in anticlockwise order are rendered this is a common approach and is used in 3D studio models for example You can alter this culling mode if you wi
12. be stand alone Otherwise specify a pointer to a RenderWindow which represents the parent window e virtual RenderWindow createRenderWindow const CString name int width int height int colourDepth bool fullScreen int left 0 int top 0 bool depthBuffer true HWND parentWindowHandle 0 0 Creates and registers a render texture object param name The name for the new render texture Note that names must be unique Qparam width The requested width for the render texture See Remarks for more info param height The requested width for the render texture See Remarks for more info returns On succes a pointer to a new platform dependernt RenderTexture derived class is returned On failiure NULL is returned remarks Because a render texture is basically a wrapper around a texture object the width and height parameters of this method just hint the preferred size for the texture Depending on the hardware driver or the underlying API these values might change when the texture is created ap amp virtual RenderTexture createRenderTexture const String amp name int width int height 0 Attaches the passed render target to the render system i E ds virtual void attachRenderTarget RenderTarget target Returns a pointer to the render target with the passed name or NULL if that render target cannot be found ue EE virtual RenderTarget getRenderTarget const String amp name
13. combining subsequent renders with the existing frame contents The result of the blending operation is lt p gt lt p align center gt final texture sourceFactor pixel destPaptaor lt p gt Bach of the factors is specified as one of a number of options as specified in the SceneBlendFactor enumerated type param sourceFactor The source factor in the above calculation i e multiplied by the texture colour components param destFactor The destination factor in the above calculation i e multiplied by the pixel colour components 7 virtual void setSceneBlending SceneBlendFactor sourceFactor oceneBlendbactor destEactor 0 Sets the global alpha rejection approach for future renders By default images are rendered regardless of texture alpha This method lets you change that param func The comparison function which must pass for a pixel to be written param val The value to compare each pixels alpha value to recommended 0 or 128 for compatibility y virtual void setAlphaRejectsettings CompareFunction func unsigned char value 0 Signifies the beginning of a frame ie the start of rendering on a single viewport Will occur several times per complete frame if multiple viewports exist d virtual void beginkFrame void 0 Render something to the active viewport Low level rendering interface to perform rendering operations Unlikely to be used directly by client
14. every time wy virtual void pushRenderState void 0 Restores the render state to a previous state virtual void popRenderState void 0 Sets the world transform matrix virtual void setWorldMatrix const Matrix4 amp m 0 Sets multiple world matrices vertex blending virtual void setWorldMatrices const Matrix4 m unsigned short count Sets the view transform matrix virtual void setViewMatrix const Matrix4 m 0 Sets the projection transform matrix virtual void setProjectionMatrix const Matrix4 amp m 0 Utility function for setting all the properties of a texture unit at once This method is also worth using over the individual texture unit settings because it only sets those settings which are different from the current settings for this unit thus minimising render state changes y virtual void setTextureUnitSettings int texUnit Material TextureLayer amp tl Turns off a texture unit virtual void disableTextureUnit int texUnit Sets the surface properties to be used for future rendering This method sets the the properties of the surfaces of objects to be rendered after it In this context these surface properties are the amount of each type of light the object reflects determining it s colour under different types of light whether it emits light itself and how shiny it is Textures are not dealt with here see the seLtTetxure meth
15. faster in 32 but colour than in 16 bit which may seem odd to some people virtual bool hasHardwareStencil void 0 Determines the bit depth of the hardware accelerated stencil buffer if supported remarks If hardware stencilling is not supported the software will provide an 8 bit software stencil sf virtual ushort getStencilBufferBitDepth void 0 This method allows you to set all the stencil buffer parameters in one call remarks The stencil buffer is used to mask out pixels in the render target allowing you to do effects like mirrors cut outs stencil shadows and more Each of your batches of rendering is likely to ignore the stencil buffer update it with new values or apply it to mask the output of the render The stencil test is lt PRE gt Reference Value amp Mask CompareFunction Stencil Buffer Value amp Mask lt PRE gt The result of this will cause one of 3 actions depending on whether the test fails succeeds but with the depth buffer check still failing or succeeds with the depth buffer check passing too par Unlike other render states stencilling is left for the application to Turn on and off when 1t requires This is because you are likely to want to change parameters between batches of arbitrary objects and control the ordering yourself In order to batch things this way you ll want to use GSM s separate render queue groups see RenderQueue and register a RenderQueueListener t
16. light from other surfaces is calculated with a Monte Carlo integration over the hemisphere Often hundreds or thousands of gathering rays are needed to get an acceptable integration estimate with low variance This large number of rays can be reduced with importance sampling methods It 1s also possible to reduce the number of Monte Carlo integrations using Ward s interpolation scheme WAR88 WAR92 The Monte Carlo gathering rays hitting geometry would normally generate secondary gathering rays which in turn would generate third generation rays etc We can get an irradiance value from the global photon map instead of generating secondary gathering rays The position and incident direction where a gathering ray hits geometry is used to query the photon map for an irradiance value The result we get from such a query contains both direct and indirect light as well as caustics effects Figure Al d illustrates how caustics are added to the solution by querying the caustics photon map at the intersection point A photon density calculation is used to estimate an irradiance value for both the global photon map and the caustics photon map This density calculation can be imagined as expanding a sphere around the query point until enough photons have been collected or until a maximum radius is reached Typically 50 500 photons are used The density is then calculated as total photon power divided by the squared radius The volume is not used sin
17. rendering of human face by photon mapping techniques Figure 3 2 Character Modeling e Entertainment movies The will no need for directors to make a lot of tricks because computers will generate a lot of real scenes e Games The animated characters in the current games will be soon as real as the people see them in real world computer will generate the parson from his model as real as he appear Figure 3 3 Facial Animation and games e Physics laser lighting applications The photon mapping technique can easily simulate the laser lighting effect as shown in the picture bellow Figure 3 4 Laser Lighting Applications e CAD CAM designing The photon mapping can be used to model architectures and building The new technique of photon mapping can be used in famous applications like 3dmax and AutoCAD e Advertising The photon mapping technique will give the advertising techniques alt of variations for announcing prducts Figure 3 5 Advertising Application 3 Tools o Microsoft Visual Studio o nVidia Cg SDK 6 0 o DirectX SDK 9 0 4 Sample Source Code From The Project 1 Render Operation ifndef RenderOperation H _ define RenderOperation H include Colourvalue h sinclude Material h is include jisasveload h class RenderOperation publie enum OpType OT POINT LIST OT LINE LIST OT LINE STRIP OT TRIANGLE LIST OT TRIANGLE STRIP OT TRIANGLE FAN Vertex options which elements
18. the GSM library do not have to use this automatic rendering loop It is there as a convenience and is most useful for high frame rate applications e g games For applications thart don t need to constantly refresh the rendering targets e g an editor utility it is better to manually refresh each render target only when required by calling RenderTarget update Qpar This frees up the CPU to do other things in between refreshes since in this case frame rate is less important S virtual void Sets the directionless light Tyr virtual void Sets the Gouraud virt al void Sets the remarks startRendering void colour amp strength of the ambient global in the world setAmbientLight float r float g float b 0 type of light shading required default setShadingType ShadeOptions so 0 type of texture filtering used when rendering This method sets the kind of texture filtering applied when rendering textures onto primitives Filtering covers how the effects of minification and magnification are disguised by resampling param fo The type of filtering to apply described in The options are TextureFilterOptions a virtual void setTextureFiltering TextureFilterOptions fo OF Sets whether or not dynamic lighting is enabled param enabled If true dynamic lighting is performed on geometry with normals supplied geometry without normals will not
19. the type of event to be considered by calculatebEventTimet enum FrameEventTimeType FETI ANY FEIT STARTED FETT ENDE Internal method for calculating the average time between recently fired events param now The current time in ms param type The type of event to be considered ay T a Real calculateEventTime unsigned long now FrameEventTimeType type The render targets 27 RenderTargetMap mRenderTargets The render targets ordered by priority P ae RenderTargetPriorityMap mPrioritisedRenderTargets The Active render target IRendering mActiveRenderin Texture manager A concrete class of this will be created and made available under the TextureManager singleton managed by the RenderSystem UP is TextureManager mTextureManager CullingMode mCullingMode bool mVoyne Store record of texture unit settings for efficient alterations Material TextureLayer mTextureUnits MAX TEXTURE LAYERS bool mTextureBlank MAX TEXTURE LAYERS unsigned int mFaceCount unsigned int mVertexCount Saved set of world matrices Matrix4 mWorldMatrices 256 bool m CapMultitexture bool m CapSpecularAfterTexture bool m CapPlanarReflection bool m CapPlanarShadow bool m CapTextureclampToBoraer bool m CapTextureApplyAdd bool m CapTextureApplyCombine bool m CapTextureApplyCombineDot3 bool m CapDot3BumpMapping virtual void SetViewport CViewPort vp 0 Active
20. to include remarks Vertices must include their elements in the following order posrtion normal texture co ords 1 3 dimensions 1 4 sets diffuse colour specular colour Only position is mandatory although at least ONE OF the following should be Specified even if ambient light on flat coloured objects only is being used yr enum VertexOptions vertex normals included for lighting VO NORMALS 1 at least one set of texture coords exact number Specified in class VO TEXTURE COORDS 2 Nertex colours diffuse VO DIFFUSE COLOURS 4 Nertex colours specular VO SPECULAR COLOURS 8 te Vertex blend info struct VertexBlendData unsigned short matrixIndex Real blendWeight true to use pIndexes to reference individual lines triangles rather than embed Allows vertex reuse bool uselndexes Number of vertices applies to all components unsigned int numVertices No memory allocation here assumed that all pointers are pointing elsewhere e g model class data Pointer to list of vertices float x y z numVertices remarks If useIndexes is false each group of 3 vertices describes a face anticlockwise winding in trianglelist mode Real pVertices fil The Stride between sets of vertex data 0 indicates data is packed with no gaps unsigned short vertexStride Optional vertex normals for vertices float x y z numVertices
21. 0 00 03 Figure 2 12 2 13 Screen Shot of the ViewPort Prespective Width 640 application Render Settings Use Photon Mapping True Height 480 Use Participating Media False Anti Aliasing False Scene Statistics Number of Objects 2 Number of Lights MO Pause Cancel Screen Shots of the OutPut Pigment Normals Reflection N P N mre s d LI emm N Figure 2 13 Photon Mapping Output A vd M m b h d ili Figure 2 14 Soft Shadows Figure 2 15 Focal Blur Figure 2 16 Atmospheric Media Fog Figure 2 17 Sky Sphere Systems http mars connectedits com Photonix Microsoft Internet Explorer File Edit View Favorites Tools Help Home Downloads Screenshots Contact Us Phetenix Who s Online We have 1 member online Main Menu Welcome to Photonix Frontpage Home Photonix Version 1 0 Released A Downloads Written by Web Master Screenshots Contact Us Wednesday 14 April 2004 Photonix is a new 3D Modeler and renderer which has a new intention to reach 3d max to produce high quality images Photonix Contains 3D categories 1 3D Engine 2 Ray Tracing Engine 3 3D Modeling Tool Based On The 3D Engine It has support For 1 Photon Mapping 2 Focal blur T 3 Texturing Hit Counter 4 Participating Media 18 Visitors Last Updated Saturday 17 April 2004 Read more Figure 2 18 Project Web Site User Menu Your Details Submit News
22. ForVerticalBlank void Ti Internal Rendering Access All methods below here are normally only called by other GSM They can be called by library user if required jj esee essc eiu OO A A O cce cues teer Adds a light to the renderers list of active lights This method should not be called directly by user processes this is adding a light at the rendering level User processes should add lights using the SceneNode attachLight method 7 virtual vola addLight Light ALL 0 Removes a light from the renderers list AS with Renderoystem addblght this method is for use internally not by user processes See SceneNode for user level light maintenance dA virtual void removeLight Light 1t 07 Modifies a light in the renderer Modifies a light which has already been added using _adadL1ght a virf usl void modiiyLight Light It 0 Clears all the lights from the renderer As with RenderSystem addLight this method is for use internally not by user processes See SceneManager for user level light maintenance ay virtual void removeAllLights void 0 Saves the current rendering state Stores the current rendering state on the render state stack The state may then be altered and restored back to it s previous state using RenderSystem popRenderState Used internally by me to manage changes like model view matrices active materials textures without having to repecify them
23. Journal of Graphic Tools vol 4 no 3 pp 1 10 1999 COH93 Cohen M F and J R Wallace Radiosity and Realistic Image Syntesis Academic Press Professional Boston 1993 CORO2 The Cornell Box http www graphics cornell edu online box 2002 GLA89 Glassner Andrew S An introduction to ray tracing Academic Press San Diego 1989 JARO1 Jarosz Wojciech and Michael Garland renderBitch An Implementation of Global Illumination using Irradiance Caching and Photon Maps Dept of Computer Science University of Illinois Urbana Champaign JENOla Jensen Henrik W Realistic Image Synthesis using Photon Mapping AK Peters 2001 JENO1b Jensen Henrik W Per H Christensen and Frank Suykens A Practical Guide to Global Illumination using Photon Mapping SIGGRAPH Course 38 2001 JEN96 Jensen Henrik W Global Illumination using Photon Mapping Rendering Techniques 96 pp 21 30 1996 KAJ86 Kajiya James T The Rendering Equation Computer Graphics SIGGRAPH 86 Proceedings vol 20 no 4 pp 143 150 1986 MA02 Ma Vincent C H and Michael D McCool Low Latency Photon Mapping Using Block Hashing Graphics Hardware pp 1 11 2002 SPO02 Sponza Atrium http hdri cgtechniques com 7Esponza 2002 STA02 Stanford Computer Graphics Laboratory http www graphics stanford edu 2002 WALO1 Wald Ingo and Slusallek Philipp State of the Art in Intera
24. N TEXCALC ENVIRONMENT MAP NORMAL enum StencilOperation SOP KEEP SOP ZERO SOP REPLACE SOP INCREMENT SOP DECREMENT SOP INVERT include supportedinterfaces h class CViewPort class RenderSystem public FrameProvider DIS LIE RenderSystem virtual RenderSystem Returns the name of the rendering system uns virtual const CString amp getName void const 0 Returns the details of this API s configuration options remarks Each render system must be able to inform the world of what options must can be specified for it s operation par These are passed as strings for portability but grouped into a Structure Conrtig ption which includes both options and current value par Note that the settings returned from this call are affected by the options that have been set so far since some options are interdependent par This routine is Called automatically by the default configuration dialogue produced by Root showConfigDialog or may be used by the caller for custom settings dialogs returns A map or options 2 81 a list Of options which is also indexed by option name ey virtual CMapStringToOb amp getConfigOptions void 0 Sets an option for this API remarks Used to confirm the settings normally chosen by the user in order to make the renderer able to initialise with the settings as required This may be video mode D3D driver full screen windowed etc Call
25. Real expDensity 1 0 Real linearStart 0 0 Real linearEnd 1 0 0 The RenderSystem will keep a count of tris rendered this resets the count virtual void beginGeometryCount void Reports the number of tris rendered since the last beginGeometryCount call virtual unsigned int getFaceCount void Reports the number of vertices passed to the renderer since the last beginGeometryCount call virtual unsigned int getVertexCount void Generates a packed data version of the passed in ColourValue suitable for use as with this RenderSystem remarks Since different render systems have different colour data formats eg RGBA for GL ARGB for D3D this method allows you to use 1 method for all param colour The colour to convert param pDest Pointer to location to put the result y virtual void convertColourValue const ColourValue amp colour unsigned long pDest 0 Returns whether or not this RenderSystem supports hardware vertex blending ie multiple world matrices per vertex with blending weights tf virtual bool isVertexBlendSupported void Returns the number of matrices available to hardware vertex blending for this rendering system virtual unsigned short getNumVertexBlendMatrices void Builds a perspective projection matrix suitable for this render system remarks Because different APIs have different requirements some incompatible for the projection matrix t
26. be displayed If false no lighting is applied and all geometry will be full brightness virtual void setLightingEnabled bool enabled 0 Creates a new rendering window remarks This method creates a new rendering window as specified by the paramteters The rendering system could be responible for only a single window e g in the case of a game or could be in charge of multiple ones in the case of a level editor The option to create the window as a child of another is therefore given This method will create an appropriate subclass of RenderWindow depending on the API and platform implementation Qpar After creation this window can be retrieved using getRenderTarget param name The name of the window Used in other methods later like setRenderTarget and getRenderWindow param width The width of the new window param height The height of the new window param colourDepth The colour depth in bits per pixel Only applicable if fullScreen true param fullScreen Specify true to make the window full screen without borders title bar or menu bar Qparam left The x position of the new window Only applicable if fullScreen is false Units are relative to the parent window if applicable otherwise they are in screen coordinates param top The y position of the new window param depthBuffer If true a depth buffer will be assigned to this window Qparam parentWindowHandle Should be null if this window is to
27. ce the photons found are most likely located on a surface 1 e the expanding sphereforms a circle on the surface Figure A2 shows a rendering of the Cornell box where each of the four light contributions is rendered as a separate image Figure A3 shows the four terms added together forming the final image Figure 2 1 Illustration of the four terms evaluated for each pixel From left to right direct light specular light indirect light and caustics The red arrow represents a primary ray sent from the camera The two ellipses are objects in the scene The blue object is both diffuse and specular The yellow circles represent two light sources Figure 2 2 Visualization of the four terms evaluated for each pixel From left to right direct light specular light indirect light and caustics Figure 2 3 The four terms added together forming the final image E Mathematical Basis Bi directional path tracing connects a single gathering walk to a single shooting walk However f the effects of a shooting walk for instance could be stored then when a new gathering walk is computed t could be connected to all of them s multaneously This is exactly what Jensen 19 18 and 20 proposed also giving the definition of a data structure called the photon map which can efficiently store the effects of many shooting walks A photon map is a collection of photon hits generated in the shooting phase of the algor thm The photo
28. ct and Indirect illumination 5 Soft shadows provides an elegant way to simulate florescent and laser light by not providing a single sharp shadow maps by with providing shadows in realistic way Figure 1 3 Soft Shadow Effect 6 Focal blur simulate the human eye by limiting eye near and far distance planes and providing a focal point where picture is distorted outside this range u Figure 1 4 output images without and with Focal Blur Effect 7 Participating Media and Particle systems by providing correct Light transport through physical medias In the same way we interact with space as media helps s mulate light scattering in Natural phenomena smoke fire rain and fluids ET ig En Figure 1 5 Output of Participating media and particle system 2 Project Details I Ray Tracing Ray tracing is one of the most popular methods used in 3D computer graphics to render an image It works by tracing the path taken by a ray of light through the scene and calculating reflection refraction or absorption of the ray whenever it intersects an object in the world hence the name For example starting at a light source we may trace a ray of light to a surface which is transparent but refracts the light beam in a different direction while absorbing some of the spectrum and altering the color From here the beam may strike another surface which is not transparent and so the light undergoes both absorption furthe
29. ctive Ray Tracing Computer Graphics Group Saarland University 2001 WAL02 Wald Ingo Thomas Kollig Carsten Benthin Alexander Keller and Philipp Slusallek Interactive Global Illumination Technical Report Computer Graphics Groups Saarland University 2002 WAR92 Ward Greg and Paul Heckbert Irradiance Gradients Eurographics Rendering Workshop 1992 pp 85 98 WARS88 Ward Greg Francis M Rubinstein and Robert D Clear A ray tracing solution for diffuse interreflection ACM SIGGRAPH Computer Graphics v 22 n 4 pp 85 92 1988
30. der r1 unsigned short pIndexes The number of vertex indexes must be a multiple of 3 unsigned int numIndexes Flags indicating vertex types int vertexOptions The type of rendering operation OpType operationType Material mMaterial int References RenderOperation void AddRef void Free J7 Void DoSerializeil5baveLoad archive 7 Example usage camera at 0 0 0 pointing down Z lookAt 0 0 300 RenderOperation ro float vertexData 9 14 005 Oy eU Je 200 300 100 Oy 300 ES float normalData 9 0 O 1 D D ds Os Us dis fo operationType RenderOperation Of TRIANGLE LIST ro numVertices 3 ro uselndexes false PO VeEPLEXUPtLONe Render perat19n 70 NORMAL ro pVertices vertexData ro pNormals normalData mDestrencastoystem gt fender ra a endif 2 Render System RenderSystem h interface for the RenderSystem class 4 ETAPA EA TS SE DIS TEN EINIG LEISTET TRITT I ifndef _ RENDERSYSTEM H define RENDERSYSTEM H include rendertexture h include Material h include GSMIncludes h tinclude RenderOperation h Enum describing the ways to generate texture coordinates enum TexCoordCalcMethod No calculated texture coordinates TEXCALC NONE Environment map based on vertex normals TEXCALC ENVIRONMENT MAP Environment map based on vertex positions TEXCALC ENVIRONMENT MAP PLANAR TEXCALC ENVIRONMENT MAP REFLECTIO
31. e RenderSystem y void removeAllLights void See RenderSystem ui void pushRenderState void See RenderSystem mr void popRenderState void See RenderSystem gt void setWorldMatrix const Matrix4 amp m See RenderSystem ar void setViewMatrix const Matrix4 amp m See RenderSystem RJ void setProjectionMatrix const Matrix4 amp m See RenderSystem ny void setSurfaceParams const ColourValue amp ambient const ColourValue amp diffuse const ColourValue amp specular const ColourValue amp emissive Real shininess See RenderSystem sf int getNumTextureUnits void See RenderSystem y Wold setTexturelint unit bool enabled const CString amp texname bm tam See RenderSystem I void SsetlextureCoordoet inL stage Mk index See RenderSystem gt void setTextureCoordCalculation int stage TexCoordCalcMethod See RenderSystem E void setTextureBlendMode int stage const LayerBlendModeEx4 See RenderSystem gt void setTextureAddressingMode int stage TextureAddressingMode See RenderSystem x void setTextureMatrix int stage const Matrix4 amp xform See RenderSystem u void setSceneBlending SceneBlendFactor sourceFactor SceneBlendFactor destFactor See RenderSystem 2 void setAlphaRejectSettings CompareFunction func unsigned char value See RenderSystem void
32. e following questions l Can the computer generate images realistic as real life images 2 To what extent is the generated image is close to real life images By answering these questions we could find that Lighting is the most important factor in providing live to images that can produce effects like direct indirect illumination shadows Existing Algorithms Limitations There are many available tools like 3d Studio Max Maya and SoftImage and modeling Software development kits SDK such as Opengl and Directx provides different solutions for producing computer images But these images are not very like to real life because the following problems in existing Algorithms In Software development kits It does not support real lighting effects based on Ray Tracing such as reflections refraction and absorption 2 It don t care about scene geometrical description In Existing Modeling Tools 1 It does not support real lighting models because it doesn t use photon mapping and global illumination found in real life 2 It doesn t support object Media and interior such as glass crystal and fluids III Objective Our project target is to develop a modeling tool that can produce high realistic images using Different Global illumination algorithms like photon mapping Radiosity IV Project Feature The Main Features of our project can be summarized in the following points Rendering Package Fully Feature Ray Tracing Package Su
33. e know the BRDF fr at point x Lx 500 o 60 0 t The reflected radiance A Lx ex F Lx ss me yA A a 9 1 is approximated as where r is the distance to the farthest photon p e kd trees Dimension of data 1s k but common to say k d tree of dimension 3 instead of 3d tree Kd trees are binary trees Designed to handle spatial data in a simple way For n points O n space O log n height 1f balanced supports range and nearest neighbor queries Node consists of e Two child pointers e Satellite information such as name e Akey Either a single float representing a coordinate value or a pair of floats representing a dimension of a rectangle p B 2x E m QU rm w i un F 10 75 70 80 A Fu FJ A Eu r r a n a f ri mm 60m A aL EN al i 247048 p E Vd a 70 39 490 50 N Fi A r 2 a ae an y E af I 5025 A Pi LES E Basic Idea Behind kd trees Construct a binary tree At each step choose one of the coordinate as a basis of dividing the rest of the points For example at the root choose x as the basis e Like binary search trees all items to the left of root will have the x coordinate less than that of the root e All items to the right of the root will have the x coordinate greater than or equal to that of the root Choose y as the basis for discrimination for the root s children And choose x again for the root s grandchi
34. ect intended to be a modeling tool that helps 3D designers to develop large scenes and render it with high quality using the new global illumination Algorithms specified next l Ray tracing is one of the most popular methods used in 3D computer graphics to render an image It works by tracing the path taken by a ray of light through the scene and calculating reflection refraction or absorption of the ray whenever it intersects an object in the world 2 Object Models providing different object model for testing purposes sphere box Constructive solid geometry Mesh Patches 3 photon mapping is a ray trac ng technique by which the transport of light from a light source through a physical medium such as a glass or a window can be simulated to produce effects similar to those in real life Figure 1 1 Output of photon mapping algorithm 4 Radiosity The idea was to simulate energy light transference from diffuse surfaces Diffuse surfaces are surfaces that reflect light equally in all directions the opposite of a shiny surface Radiosity is quite similar to photon map based techniques However instead of using ray tracing for final gather the photons in the photon map are used as light sources and fast and hardware supported visibility and shadow algorithms are applied Am Tm pine l a FUR EE USE Arber RE VEE EE ae dd eL ps us Phi n N os n ma Here Figure 1 2 Difference between Dire
35. ed automatically by the default configuration dialog and by the restoration of saved settings These settings are stored and only activated when RenderSystem initialise or RenderSystem reinitialise are called Qpar If using a custom configuration dialog it 18 advised that the caller calls RenderSystem getConfigOptions again since some options can alter resulting from a selection Qparam name The name of the option to alter Qparam value The value to set the option to Sur virtual void setConfigOption const CString amp name const CString amp value 0 Validates the options set for the rendering system returning a message if there are problems anote If the returned string is empty there are no problems virtual CString validateConfigOptions void 0 Start up the renderer using the settings selected Or the defaults if none have been selected remarks Called by Root setRenderSystem Shouldn t really be called directly although this can be done if the app wants nep param autoCreateWindow If true creates a render window automatically based on settings chosen so far This saves an extra call to RenderSystem createRenderWindow for the main render window Qpar If an application has more specific window requirements however e g a level design app it should specify false for this parameter and do it manually returns A pointer to the automatically created window if requested otherw
36. ertex3 virtual void Polygon Real Vertices int NumVertices RenderOperation OpType OpType RenderOperation OpType 0T TRIANGLE STRIP DWORD rgba 0 virtual void Polygon Real Vertices Real Indices int NumIndices RenderOperation OpType Oprype RenderOperation sO0pTIype 0T TRIANGLE SIRIP DWORD gba 0 7 virtual void Line Vector3 Vertexl Vector3 Vertex2 ColourValue amp color virtual void PushMatrix void virtual vela FopMaEriz va virtual void SetViewport int x int y int h int w fendif GLOSSARY Flux Irradiance Lambertian Monte Carlo integration Participating media Projection map Radiance Recursive grid Russian roulette Solid angle Voxel Bidirectional Reflectance Distribution Function A function that defines the reflectance properties of an object It describes how light is scattered at the surfaces and determines the appearance of the object The radiometry term for power Incident flux per unit area Material that is perfectly diffuse Light is reflected equally in all directions In this context integration of indirect light by sampling a hemisphere above a point in the scene The hemisphere is sampled by shooting many rays in random directions and computing the radiance at the intersection points Media that scatters l ght as t passes through Examples are smoke fog and dust A spherical projection of the scene geometry as seen from a light source Used to opti
37. et to use y virtual void setlextureCoord5et int unit nt index 0 Sets a method for automatically calculating texture coordinates for a stage Should not be used by apps for use by me only param unit Texture unit as above Qparam m Calculation method to use virtual void setTextureCoordCalculation int unit TexCoordCalcMethod m 0 Sets the texture blend modes from a TextureLayer record Meant for use internally only apps should use the Material and TextureLayer classes param unit Texture unit as above param bm Details of the blending mode A virtual void setTextureBlendMode int unit const LayerBlendModeEx amp bm 0 Sets the texture filtering type for a texture unit virtual void setTextureLayerFiltering int unit const TextureFilterOptions texLayerFilterOps 0 Sets the maximal anisotropy for the specified texture Bate 7 virtual void setTextureLayerAnisotropy int unit int maxAnisotropy 0 Sets the maximal anisotropy virtual void setAnisotropy int maxAnisotropy 0 Sets the texture addressing mode for a texture unit virtual void setTextureAddressingMode int unit TextureAddressingMode tam 0 Sets the texture coordinate transformation matrix for a texture unit param unit Texture unit to affect param xform The 4x4 matrix my virtual void setTextureMatrix int unit const Matrix4 amp xform 0 Sets the global blending factors for
38. eve global 1llumination effects such as color bleeding and caustics The method was originally developed by Jensen JEN96 The method is based on the idea of emitting photons from the light sources and letting them bounce around in the scene until absorption This emission takes place before any actual rendering s done Photons hitting scene geometry are stored to be used later during rendering Many photons are needed to get good image quality typically 100 000 1 000 000 photons depending on the specific scene The collections of photons are called a photon map Normal ray tracing methods are combined with the photon map during rendering The density of photons in the neighborhood of a specific query point is used to get an irradiance estimate during rendering and this value is used as an approximation instead of performing a costly Monte Carlo integration Photon Mapping can be divided into three consecutive steps each of which is described in the subseguent subsections Photon Tracing Photon Map Sorting Rendering B Photon Tracing Each light source emits photons which are traced through the scene A photon hitting a surface can be reflected transmitted or absorbed Russian roulette is used to determine which of these three events should occur with probabilities based on the material properties A photon path is terminated when it is absorbed Photons hitting diffuse surfaces are stored for later use each photon emitted fro
39. fuse and specular reflections without the speed issues or noise issues that arise from radiosity and ray tracing Photon mapping uses techniques and ideas from both ray tracing and radiosity We can classify the major solutions into a table illustrating the capability of each method dealing with BRDF and its complexity BRDF and its complexity Radiosity Diffuse only Hemi cube Radiosity Progressive Radiosity Analyt cal form factor method Radiosity and Diffuse and specular planar surface Two pass method ray tracing only and s ngle pass U ee surface multi pass Ray tracing for Forward statistic ray tracing enables solving the caustic diffuse Diffuse and specular nonplanar Radiance method component surface deterministic forward ray various tracing technigues are Forward and backward combination Bi directional path tracing suggested Path mutation in ray tracing Metropolis light transfer method Bi directional Photon tracing Photon map method However these solutions have common interest in some points One major thing is important sampling To solve a problem using iteration or numerical integration the variables with large value should be considered first It is a kind of importance sampling The other thing is error level adjustment For the radiosity method it presented as hierarchical or meshing technigues In ray tracing it is represented as ray path level and ray sampling rates VI Project Phases The proj
40. his method allows each to implement their own correctly and pass back a generic matrix for storage in the engine us virtual void makeProjectionMatrix Real fovy Real aspect Real nearPlane Real farPlane Matrix4 amp dest 0 Sets how to rasterise triangles as points wireframe or solid polve virtual void setRasterisationMode SceneDetailLevel level 0 Turns stencil buffer checking on or off remarks Stencilling masking off areas of the rendering target based on the stencil buffer canbe turned on or off using this method By default stencilling is disabled y virtual void setStencilCheckEnabled bool enabled 0 Determines if this system supports hardware accelerated stencil buffer remarks Note that the lack of this function doesn t mean you can t do stencilling but the stencilling operations will be provided in software which will NOT be fast par Generally hardware stencils are only supported in 32 b1t colour modes because the stencil buffer shares the memory of the z buffer and in most cards the z buffer has to be the same depth as the colour buffer This means that in 32 DLE mode 24 bits of the z buffer are depth and 8 bits are stencil In 16 bit mode there is no room for a stencil although some cards support a 15 1 depth stencil option this isn t useful for very much so 8 bits of stencil are provided in software This can mean that if you use stencilling your applications may be
41. ich is pertormed 15 SOF REPLACE g virtual void setStencilBufferReferenceValue ulong refValue Sets the stencil buffer mask value Qremarks This is applied thus lt PRE gt Reference Value Mask CompareFunction Stencil Buffer Value amp Mask lt PRE gt m virtual void setStencilBufferMask ulong mask 0 Sets the action to perform if the stencil test fails virtual void setStencilBufferFailOperation StencilOperation op 0 Sets the action to perform if the stencil test passes but the depth buffer test fails virtual void setStencilBufferDepthFailOperation StencilOperation op 0 Sets the action to perform if both the stencil test and the depth buffer test passes virtual void setStencilBufferPassOperation StencilOperation op 0 Performs a software vertex blend on the passed in operation remarks This function is supplied to calculate a vertex blend when no hardware support is available or when the results are required by another software component The vertices contained in the passed in operation will be modified by the matrices supplied according to the blending weights also in the operation To avoid accidentally modifying core vertex data a temporary vertex buffer is used for the result which is then used in the RenderOperation instead of the original passed in vertex data n void softwareVertexBlend RenderOperation amp op Matrix4 pMatrices Indicates
42. ise null od virtual RenderWindow initialise bool autoCreateWindow Restart the renderer normally following a change in settings u virtual void reinitialise void 0 Shutdown the renderer and cleanup resources ui virtual void shutdown void Registers a FrameListener which will be called back every frame remarks A FrameListener is a class which implements methods which will be called during me s automatic rendering loop started with RenderSystem startRendering par See the FrameListener class for more details on the specifics It is imperitive that the instance passed to this method is not destroyed before iether the rendering loop ends or the class is removed from the listening list using removeFrameListener see FrameListener m E ii virtual void addFrameListener Framelistener newListener Removes a FrameListener from the list of listening classes E Fe virtual void removeFramelistener Framelistener oldListener Starts restarts the automatic rendering cycle remarks This method begins the automatic rendering of the scene This method will NOT RETURN until the rendering cycle is halted par During rendering any Framelistener classes registered using addFramelistener will be called back for each frame that is to be rendered These classes can tell GSM to halt the rendering if required which will cause this method to return par Note users of
43. ldren Note Equality corresponding to right child is signicant Assume points are sorted on both x and y in a composite array S S x corresponds to a list of points sorted by x The Algorithm of building the tree is as follows KDNode buildTree SortedArray S int cd if S empty return null else if S singleton return new KDNode S x 0 cd else m median S cd median cut t ing dimens ion left leftPoints S cd right S left t new KDNode m t left buildTree left cd 1 t right build Tree right cd 1 return t j j e T n kn 2T n 2 so the algorithm takes O n log n time III Soft Shadows Area light sources occupy a finite one or two dimensional area of space They can cast soft shadows because an object can partially block their light Point sources are either totally blocked or not blocked It is approximated as an array of point light sources spread out over the area occupied by the light The array effect applies to shadows only The object s llumination is still that of a point source The intensity of each individual point light in the array is dimmed so that the total amount of light emitted by the light is equal to the light color specified in the declaration The area light command defines the location the size and orientation of the area light as well as the number of lights in the light source array The location vector is the centre of a rectangle defined by the two vectors l
44. le texture stage Sets the details of a texture stage to be used for all primitives rendered afterwards User processes would not normally call this direct unless rendering primitives themselves the SubEntity class is designed to manage materials for objects Not that this method 18 called by setM terial param unit The index of the texture unit to modify Multitexturing hardware can support multiple units see getNumrlextureuUnits param enabled Boolean to turn the unit on off param texname The name of the texture to use this should have already been loaded with TextureManager load ay virtual void ssetlexture inL init bool enabled Caner CString amp texname 0 Returns the number of texture units the current output hardware supports For use in rendering this determines how many texture units the are available for multitexturing i e rendering multiple rexr res in a single pass Where a Material has multiple texture layers it will try to use multitexturing where available and where it is not available will perform multipass rendering to achieve the same effect id virtual int getNumTextureUnits void 0 Sets the texture coordinate set to use for a texture unit Meant for use internally not generally used directly by apps the Material and TextureLayer classes let you manage textures far more easily param unit Texture unit as above param index The index of the texture coordinate s
45. ling Unfortunately ray tracing could not handle diffuse reflections which 1s where much of real light comes from In 1984 the Radiosity algor thm was created by researchers at Japan s Fukuyama and Hiroshima Universities and the United States Cornell University This algorithm borrowed from the field of radiative heat transfer proposed to give everything ray tracing couldn t to the graphics field Mainly this meant that Radiosity could calculate diffuse reflection In 1986 Kaj ya introduced path tracing an extension to the ray tracing algorithm that allowed it to stochastically sample for diffuse reflections The algor thm worked well but noise in the image was a major problem Also in 1986 Immel Cohen and Greenberg developed a specular Radiosity program that could simulate specular reflections Unfortunately the excessive time it took to render even a small number of specular surfaces was discouraging In 1987 AT amp T introduced a MIMD parallel machine that could render simple scenes using ray tracing in real time Since 1988 there has been an explosion in the number of methods trying to improve either Radiosity or ray tracing including many attempts at combining the two Many attempts have been made at creating real time ray trac ng and radiosity that used parallel machines However n 1996 Henrik Wann Jensen published the first papers on photon mapping Photon mapping is a technique that allows the inclusion of both dif
46. m a light source can therefore be stored many times during its path through the scene hitting several diffuse surfaces The collection of stored photons is the global photon map An additional caustics photon map may also be created This photon map only stores photons hitting diffuse surfaces if they have been reflected or transmitted from a specular surface The following information is stored for each photon Photon position Photon flux ncident direction C Photon Map Sorting All photons created during photon tracing are in this step sorted to allow fast lookups during the rendering step Jensen JEN96 uses a balanced kd tree since it is a compact representation which allows a non uniform distribution of photons in the scene The global photons and the caustics photons are stored into separate photon maps D Rendering Four terms are evaluated and added together to get the color of each pixel in the image Direct light e Specular light Indirect light e Caustics Figure Al a illustrates how the direct light term 1s calculated The red arrow represents a primary ray sent from the camera The black arrows represent shadow rays sent from the intersection point towards all light sources Figure Al b illustrates how specular reflection and transmission are calculated The blue object 1s both diffuse and specular Reflected rays are sent to collect illumination n the specular direction Figure Al c illustrates how indirect
47. mask See RenderSystem ey void setStencilBufferFailOperation StencilOperation op See RenderSystem ay void setStencilBufferDepthFailOperation StencilOperation op See RenderSystem m void setStencilBufferPassOperation StencilOperation op See RenderSystem remarks This is overridden because GL likes to set stencil options together so we can provide a better custom implementation of this than using the superclass sy void setStencilBufferParams CompareFunction func CMPF ALWAYS PASS ulong refValue 0 ulong mask OxFFFFFFFF stent lOperati n sueneLlrallOp SOP KEEP Stenciloperation depthFailOp SOP KEEP stene1lOperaL on passop SOP KEEP See RenderSystem Tu void setTextureLayerFiltering int unit const TextureFilterOptions texLayerFilterOps See RenderSystem x void setAnisotropy int maxAnisotropy See RenderSystem void setTextureLayerAnisotropy int unit int maxAnisotropy virtual void SetCamera Camera cam _ End Overridden members _ virtual void DrawGrid void Texture CreateTexture voiu RenderTexture CreateRenderTexture CString Name uint Width ult Height TextureType TexIlIype TEX TYPE 2D bool SuppportMultiTex virtual RenderWindow createRenderWindow HWND ExternalWnd int colourDepth virtual void Polygon Vector3 Vertexl Vector3 Vertex2 Vector3 V
48. mize photon emission from the light source Flux per unit projected area and per solid angle What we use for the color of a pixel A spatial data structure used to speedup intersection testing The scene 1s divided into grid voxels were each voxel in turn can be further divided Making decisions based on a random variable The projection of an area onto a unit sphere Measured in steradians A sphere subtends 4zsteradians An element in a spatial data structure In this context one of the cells in a three dimensional grid REFERENCES LAMA87 Amanatides John and Andrew Woo A Fast Voxel Traversal Algorithm for Ray Tracing Proc Eurographics 87 The Netherlands pp 1 10 1987 ARY93a Arya Sunil and David M Mount Approximate nearest neighbor queries in fixed dimensions Proc 4th ACM SIAM Symp on Discrete Algorithms SODA pp 271 280 1993 ARY93b Arya Sunil and David M Mount Algorithms for fast vector quantization Proc IEEE Data Compression Conference DCC eds J A Storer and M Cohn IEEE Press pp 381 390 1993 BEN75 Bentley Jon L Multidimensional binary search trees used for assiciative searching Comm of the ACM vol 18 no 9 pp 509 517 ACM 1975 BON02 Bonnedal Rasmus and Pettersson Magnus SIMD Accelerated Ray tracing Master Thesis Chalmers University of Technology Goteborg 2002 CHR99 Christensen Per H Faster Photon Map Global Illumination
49. mputer from a description of a three dimensional world Our Objective is to combine both Hardware and software capabilities and get highest realism in the generated image using most powerful global illumination algorithm Photon Mapping Global illumination is based on light transport mechanism in real world The light transport mechanism can be expressed in terms of Bidirectional Reflectance Distribution Function BRDF of each element and the most common and practical way is dividing the BRDF into specular and diffuse component Mathematically Global illumination is a problem of solving numerical equations concerning with the convergence converging speed and ifit converges to right answer The initial value is the given light sources and their characteristics The energy of the light source is propagated into the geometrical space The Radiosity and Ray tracing methods are used to calculate the energy propagation in each iteration step The BRDF of geometrical element is important to the efficiency of each method Ifthe BRDFis ideal diffuse Radiosity method will converge and converge to right answer However Ray tracing algorithm works more efficiently in calculating specular reflection refraction and caustic surfaces Those Radiosity and Ray tracing algorithms can be measured in two aspects the accuracy and efficiency in BRDF simulation and the rendering speed The photon mapping is a new method is used extensively in global illumination
50. n map is organized in a kd tree to support efficient retrieval A photon hit is stored with the power of the photon on different wavelengths position and direction of arr val and with the surface normal The gathering phase is based on the following approximation of the transport operator LE Lin o a fes ost du Q dd uw TA ana Ole dt ww N cos 0 dw lira fr w T w cos dw Q A w I ANA fr w E w 1 Where A x is the power of a photon landing at the surface AA from direction The A and AA quantities are approximated from the photons in the neighborhood of X in the following way A sphere centered around X is extended until it contains l photons If at this point the radius of the sphere is 7 then the i 2 intersected surface area is AA Zr e Photon Shooting Stuck photon float x y Zz where this photon was stored char power char B its power and where it came from short cd the cutting dimensi n kd tree diffuse pointShoot n 0 p lightSource while not enough photons d randomDirection shoot photon in direction d to get pos n l Scale power by Hp store photon at pos with power and direction e Computing Reflected Radiance We want to the reflected radiance at x in the outgoing direction w e Inthe photon map we find a photon p close to x and we know it came from the direction and it has some differential flux W
51. ndled and processed by the engine classes like keyboard and mouse input The design is based on the idea of client server activity where some of the classes described above work as provider of the service and others work as Receiver of the service or event The figure shown is the hierarchy chart of base class and inheritance And here are some of the classes and its description Description IEventProvider Base interface for event providing Base interface for frame providing IMessageProvider Base interface for message passing IWindowMessageProvider Base interface for window message passing IGenericMessageProvider Base interface for generic message passing IMouseProvider Base interface for mouse events providing 3 Utilities beet Texture imaternion D3DSTextute STDImage GLT exture DEEP CDevicellode oceneaelector View ort Vector Cached atrix Vectors Camera Yectord Contieliption D3D8Devicelnfo DsDeDrrver DsDeDriverList Di Video ode Light Figure 2 8 Material Matrix These are some utility classes that have a great help in mathematical calculations and object texturing support view port camera The figure shown is the hierarchy chart of base class and inheritance And here are some of the classes and its description DirectX Specific Implementation for Texture object MTranslationTool Tool that can do interactive translation MRotationTool Tool that can do interactive rotation MScaleT
52. o get notifications between batches par There are individual state change methods for each of the parameters set using this method Note that the default values in this method represent the defaults at system star Up 735 param func The comparison function applied param refValue The reference value used in the comparison param mask The bitmask applied to both the stencil value and the reference value before comparison param stencilFailOp The action to perform when the stencil check fails param depthFailOp The action to perform when the stencil check passes but the depth buffer check still fails param passOp The action to take when both the stencil and depth check pass sy virtual void setStencilBufferParams CompareFunction func CMPF ALWAYS PASS ulong refValue 0 ulong mask OxFFFFFFFF Ssrene1lOperallon StenerlraLl Op SOP KEEP StencilOperation depthFailOp SOP KEEP StLencllOperation passop SOP KEEP Sets the stencil test function dremarks The stencil test is lt PRE gt Reference Value Mask CompareFunction Stencil Buffer Value Mask lt PRE gt ep virtual void setStencilBufferFunction CompareFunction func 0 Sets the stencil buffer reference value remarks This value is used in the stencil test lt PRE gt Reference Value amp Mask CompareFunction Stencil Buffer Value amp Mask lt PRE gt It can also be used as the destination value for the stencil buffer if the operation wh
53. od for details This method is used by setMaterial so does not need to be called direct if that method is being used param ambient The amount of ambient sourceless and directionless light an object reflects Affected by the colour amount of ambient light in the scene param diffuse The amount of light from directed sources that 18 reflected affected by colour amount of point directed and spot light sources param specular The amount of specular light reflected This 18 also affected by directed light sources but represents the colour at the highlights of the object param emissive The colour of light emitted from the object Note that this will make an object seem brighter and not dependent on lights 2n the scene but it will not act as a light so will not illuminate other objects Use a light attached to the same SceneNode as the object Tor this purpose param shininess A value which only has an effect on Specular highlights so Specular must be non black The higher this value the smaller and crisper the Specular highlights will be imitating a more highly polished surface This value is not constrained to 0 0 1 0 in fact it is likely to be more 10 0 gives a modest sheen to an object ai virtual void setSurfaceParams const ColourValue amp ambient const ColourValue amp diffuse const ColourValue amp specular const ColourValue amp emissive Real shininess 0 Sets the status of a sing
54. oid 1nitContigOprtrons volg void initInputDevices void void processInputDevices void void setGLLight int index Light 1t void makeGLMatrix GLfloat gl matrix 16 const Matrix4 amp m int rowByRow 0 groups hey GLint getBlendMode SceneBlendFactor Blendtype void setLights Store last depth write state bool mDepthWrite GLint convertCompareFunction CompareFunction func GLint convertStencilOp StencilOperation op Save stencil settings since GL insists on having them in Means we have to call functions more than once but what the GLint mStencilFunc mStencilRef GLuint mStencilMask GLint mStencilFail mStencilZFail mStencilPass internal method for anisotrophy validation GLiloat getCurrentAnlsotropy Q0 GL support class used for creating windows etc GLSupport mGLSupport Internal method to set pos direction of a light void setGLLightPositionDirection Light lt int lightindex p blic virtual void SetMaterial Material mat Default constructor destructor GLRenderSystem GLRenderSystem Overridden RenderSystem functions value 2242222222 See RenderSystem i const CString amp getName void const See RenderSystem P CMapStringToOb amp getConfigOptions void See RenderSystem d void setConfigOption const CString amp name const CString See RenderSystem sy CString valida
55. olys attached to another surface to represent details such as bulletholes etc par A way to combat this problem is to use a depth bias to adjust the depth buffer value used for the decal such that it is slightly higher than the true value ensuring that the decal appears on top param bias The bias value should be between 0 and 16 T virtual volg setDepthBrias ushorb bias 0 Sets the fogging mode for future geometry param mode Set up the mode of fog as described in the FogMode enum or set to FOG NONE to turn off param colour The colour of the fog Either set this to the same as your viewport background colour or to blend in with a skydome or skybox param expDensity The density of the fog in FOG EXP or FOG EXP mode as a value between 0 and l The sa is i Le completely opaque lower values can mean that fog never completely obscures the scene param linearStart Distance at which linear fog starts to encroach The distance must be passed as a parametric value between 0 and 1 with O0 being the near clipping plane and 1 being the far clipping plane Only applicable ii mode is FOG LINEAR param linearEnd Distance at which linear fog becomes completely opaque The distance must be passed as a parametric value between 0 and 1 with 0 being the near clipping plane and 1 being the far clipping plane Only applicable if mode is FOG LINEAR a virtual void setFog FogMode mode FOG NONE ColourValue colour ColourValue White
56. ool Tool that can do interactive scale e Screen Shots Figure 2 9 Screen Shots of the Application Photonix Untitled Sele File Edit View Help Create Rendering Tools evecte ur gun BREESE Ess Texture Editor Add Material CFinishDla 3 Finish Parameters Material G standard tex Ambient 01 PIGMENT Diffuse 0 ne solid color Brilliance 10 he finish Sky Sphere Phong 1 it Rainbow Phong Size 25 Specular 0 1 D Roughness Reflection ns od Stop Antaliasing Material Scene Options Crand Al a Material Box w Metallic Influence 0 3 Enviromental a mae as 11 lidescence Amount lo Persistence Options nnd Thickness 0 Scene Settings 1 le Add Transform KK Use Photon Mapping Photon Mapping options Use Spacing Count Spacing Count O C_ Use files to persist photons Figure 2 1 0 Sawebond Browse 2 11 Adaptive Depth Control Bailout Screen Shot of the Mas Trace Level application Jitter Use Media Photons Interaction Render Scene Display image while rendering Use Radiosity Mosaic Start Stop Antialiasimg Threshold Jitter Raps Output Settings Resolution M pels Rendering Rendering Progress Current Task Rendering line 267 of 460 Task Progress G RRR RRR RRR Elapsed Time 09 00 04 Remaining Time
57. pporting Most Realistic Images using Photon mapping Supporting bump Mapping Reflection Alpha Blending High Quality Object Models using Subdivision and Mathematical Representation Soft Shadow Objects Supporting Corect Light Model using Radiosity simulating Real life particles fog and providing correct Light transport through physical medias Focal blur by simulating the human eye Sky and Rainbow Simulation System Object Texturing and different Pattern filling wood bozo cracle 3D diie and Modeler Easy User interface like most famous CAD Application 3D Max MAYA Real time Preview Object Management Selection Manipulation and Deletion 3D File Import 3ds IFS Ramaining Time Rendering Support Project Development The project s released as open source development at http photonix sourceforge net Weekly Updated V Previous work Computer graphics has been an increasingly growing field of computer science In 1968 when much of computer graphics was simple raster calculations Arthur Apple thought of a new way to render objects His idea was to trace rays from the viewer s eye through an image plane and into a scene to discover where objects were located in a three dimensional world However it wasn t until Turner Whitted extended this idea into ray tracing in 1980 that the technique became noticed The inclusion of both specular reflection and transmission made the algorithm both versatile and visually appea
58. r changing the color and reflection changing the direction Finally from this second surface t may be reflected directly into the virtual camera where its color contributes to the final rendered image Ray tracing s popular ty stems from its realism over other rendering methods such as scanline algorithms effects such as reflections and shadows which are difficult to s mulate in other algorithms follow naturally from the ray trac ng algor thm The main drawback of ray tracing is that t can be an extremely slow process due mainly to the large numbers of light rays which need to be traced and the larger number of potentially complicated intersection calculations between light rays and geometry the result of which may lead to the creation of new rays Since very few of the potential rays of light emitted from light sources might end up reaching the camera a common optimization is to trace hypothetical rays of light in the opposite direction That is a ray of light is traced starting from the camera into the scene and back through interactions with geometry to see 1f 1t ends up back at a light source This is usually referred to as backwards ray tracing Nonetheless since its first use as a graphics technique by Turner Whitted n 1980 much research has been done on acceleration schemes for ray tracing many of these focus on speeding up the determination of whether a light ray has intersected an arbitrary piece of geometry in the
59. re the adaptive phase begins For example if you use adaptive 0 a minimum of 4 rays will be shot at the light If you use adaptive a minimum of 9 rays will be shot adaptive 2 gives 25 rays adaptive 3 gives 81 rays etc Obviously the more shadow rays you shoot the slower the rendering will be so you should use the lowest value that gives acceptable results The number of rays never exceeds the values you specify for rows and columns of points For example area light x y 4 4 specifies a 4 by 4 array of lights If you specify adapt ve 3 1t would mean that you should start with a 9 by 9 array In this case no adaptive sampling is done The 4 by 4 array is used The circular command has been added to area lights in order to better create circular soft shadows With ordinary area lights the pseudo lights are arranged in a rectangular grid and thus project partly rectangular shadows around all objects including circular objects By including the circular tag in an area light the light 1s stretched and squashed so that 1t looks like a circle this way circular or spherical light sources are better simulated A few things more e Circular area lights can be ellipses the AXIS 1 VECTOR and AXIS 2 VECTOR define the shape and orientation of the circle 1f the vectors are not equal the light source is elliptical in shape e Rectangular artifacts may still show up with very large area grids e The area of a circular light is roughly 78 5 per cent of
60. rendering which appeared for the first time in new millennium accurately in the year 2002 This new technique for rendering is called photon mapping which uses traditional ray tracing techniques and indirect light illumination technique as the same as it happen real life to render 3D objects In the following pages of documentation we introduce a summary of hard work in our graduation project The documentation is organized as fellow 1 Introductory material chapter 1 describes largely in quantities term the problem definition why this new technique photon mapping appears and the old techniques limitations then we describe our objective from the project and its features and outline the project phases 2 Project details in chapter 2 which include a description of the traditional ray tracing technique and then we describe the photon mapping technique in details and provide a pseudo code of algorithm of photon mapping and then we describe the raw basis of the project the 3D rendering engine we describe its features and implementation 3 Applications of the project the photon mapping reach a reality of images which will be useful in many applications outlined in the third chapter 4 Source code in chapter 4 we provide a source code of the project so that it may be useful for next years students who want to build their work based on our project Abstract Rendering is the process in which a two dimensional image is created by a co
61. scene often by storing the geometric database in a spatially organised data structure Ray tracing has also shown itself to be very versatile and in the last decade ray tracing has been extended to global 1llumination rendering methods such as photon mapping and Metropolis l ght transport Ray tracing in computer graphics derives its name and principles from a much older technique used for lens design since the 1900s Geometric ray tracing is used to describe the propagation of light rays through a lens system or optical instrument allowing the properties of the system to be modelled This is used to optimise the design of the instrument e g to minimise effects such as chromatic aberration before it is built The principles of ray trac ng for computer graphics and optical design are s milar but the technique in optical design usually uses much more rigorous and physically correct models of how light behaves In particular optical effects such as dispersion diffraction and the behaviour of optical coatings are important in lens design but are less so in computer graphics Before the advent of the computer ray tracing calculations were performed by hand but now they are common features of optical design software such as Zemax A simple version of ray tracing known as ray transfer matrix analysis is often used in the design of optical resonators used in lasers II Photon Mapping Algorithm A General Photon Mapping is a method to achi
62. sh but it is not advised unless you know what you are doing You may wish to use the CULL NONE option for mesh data that you cull yourself where the vertex winding is uncertain virtual void setCullingMode CullingMode mode 0 virtual CullingMode getCullingMode void Sets the mode of operation for depth buffer tests from this point onwards Sometimes you may wish to alter the behaviour of the depth buffer to achieve special effects Because it s unlikely that you ll set these options for an entire frame but rather use them to tweak settings between rendering objects this is an internal method indicated by the prefix which will be used by a SceneManager implementation rather than directly from the client application If this method is never called the settings are automatically the same as the default parameters param depthTest If true the depth buffer is tested for each pixel and the frame buffer is only updated if the depth function test succeeds If false no test is performed and pixels are always written param depthWrite If true the depth buffer is updated with the depth of the new pixel if the depth test succeeds If false the depth buffer is left unchanged even if a new pixel is written param depthFunction Sets the function required for the depth test ny virtual void setDepthBufferParans bool depthTest true bool depthWrite true CompareFunction depthFunction CMPF LESS EQUAL 0
63. t Axis_1 gt and Axis 2 These specify the lengths and directions of the edges of the light Figure 2 4 4d Area fight location and vectors Since the area lights are rectangular in shape these vectors should be perpendicular to each other The larger the size of the light the thicker the soft part of shadows will be The integers Size_1 and Size_2 specify the number of rows and columns of point sources of the The more lights you use the smoother your shadows will be but the longer they will take to render An interesting effect can be created using a linear light source Rather than having a rectangular shape a linear light stretches along a line sort of like a thin fluorescent tube To create a linear light just create an area light with one of the array dimensions set to 1 The jitter command is optional When used it causes the positions of the point lights in the array to be randomly jittered to eliminate any shadow banding that may occur The jittering is completely random from render to render and should not be used when generating animations The adaptive command is used to enable adaptive sampling of the light source By default the algorithm calculates the amount of light that reaches a surface from an area light by shooting a test ray at every point light within the array As you can imagine this is very slow Adaptive sampling on the other hand attempts to approximate the same calculation by using a minimum number of test rays
64. teConfigOptions void See RenderSystem ay RenderWindow initialise bool autoCreateWindow See RenderSystem di void reinitialise void Used if settings changed mid rendering See RenderSystem void shutdown void See RenderSystem void startRendering void See RenderSystem void setAmbientLight float r float g float b See RenderSystem EJ void setShadingType ShadeOptions so See RenderSystem SI void setTextureFiltering TextureFilterOptions fo See RenderSystem vy void setLightingEnabled bool enabled See RenderSystem af RenderWindow createRenderWindow const CString amp name int width int height int colourDepth bool fullScreen int left 0 int top 0 bool depthBuffer true HWND parentWindowHandle 0 RenderTexture createRenderTexture const CString amp name int width aint height See RenderSystem el ii void destroyRenderWindow RenderWindow pWin See RenderSystem y CString getErrorDescription long errorNumber See RenderSystem yr void convertColourValue const ColourValue amp colour unsigned long pDest _ Low level overridden members _ See RenderSystem SP void addLight Light LE See RenderSystem sf v ld removeLight Light 1t See RenderSystem y void modityLight Light LE Se
65. to render photorealistic pictures The photon mapping combines the advantages of both radiosity and ray tracing and better than them in terms ofthe accuracy and efficiency in BRDF simulation and the rendering speed Table of Contents List of Figures l Introduction i Problem Definition ii Existing Algorithms Limitations iii Objective iv Project Features v Previous work vi Project phases Ray tracing Object Models Photon mapping Radiosity Soft shadows Focal blur Participating Media and Particle systems 2 Project Details i Ray Tracing ii Photon Mapping Algorithm l General 2 Photon Tracing 3 Photon Map Sorting 4 Rendering 5 Mathematical Basis of Photons k d Tree iii Soft Shadows iv 3d Editor and Engine v Screen Shots 3 Applications 4 Tools 5 Source Code e Render Operation e Render System e OpenGL Render System JAM NA Glossary References User Manual 00 oo oo NANNAAN U Cn UV BR RR 02 F2 F0 RR 3 me 59 60 62 Number TOC Index l 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Figure 1 1 Figure 1 2 Figure 1 3 Figure 1 4 Figure 1 5 Figure 2 1 Figure 2 2 Figure 2 3 Figure 2 4 Figure 2 5 Figure 2 6 Figure 2 7 Figure 2 8 Figure 2 9 Figure 2 10 2 11 Figure 2 12 2 13 Figure 2 13 2 14 Figure 2 15 2 16 Figure 2 17 2 18 Figure 2 19 Figure 3 1 Figure 3 2 Figure 3 3 Figure 3 4 Figure 3 5 List of Figures Description Output of photon mapp ng
66. viewport dest for future rendering operations CViewPort mActiveViewport virtual void SetCamera Camera cam 0 RenderWindow mWindow CObArray mRenderIn virtual void DrawGrid void 0 virtual Texture CreateTexture void 0 virtual RenderTexture CreateRenderTexture CString Name uint Width uint Height TextureType TexType TEX TYPE 2D 0 virtual RenderWindow createRenderWindow HWND ExternalWnd int colourDepth return 0 Rendering loop control bool mStopRendering rendered with the default material virtual void Polygon Vector3 Vertexl Vector3 Vertex2 Vector3 Vertex3 0 virtual void Polygon Real Vertices int NumVertices RenderOperation OpType OpType RenderOperation OpType OT TRIANGLE STRIP DWORD rgba 0 0 virtual void Polygon Real Vertices Real Indices int NumIndices RenderOperation OpType OpType RenderOperation OpType OT TRIANGLE STRIP DWORD rgba 0 0 virtual void Line Vector3 Vertexl Vector3 Vertex2 ColourValue amp color ColourValue 0 0 0 0 intending to put funcs for strides F void Polygon Vector3 Vertex Vector2 TexCoordl Vector2 TexCoord2 Vector2 TexCoord2 7 void Polygon Real Vertices int NumVertices RenderOperation OpType OpType 4 void Polygon Real Vertices Real Indices RenderOperation OpType OpType int NumVertices int NumIndices virtual void PushMatrix void virtual void PopMatrix void virtual void SetViewport int x int y int h int w 0

Download Pdf Manuals

image

Related Search

Related Contents

  SPI-H6150-LLVA User`s Manual  Huawei 4TB 3.5" SATA  アイドルアジャストスクリュー 取扱説明書  Arnova 10 User Guide  LG MH7042X microwave  Apricorn Aegis Padlock Fortress 1TB  (LonTalk®通信) 製品仕様書(PDF/631KB)  用紙カセット(LPYC6) 取扱説明書    

Copyright © All rights reserved.
Failed to retrieve file