Tuesday, 11 May 2010

May update!

How fast time has passed! I've been very busy the last month or so finalising and debugging the program itself. I've also working on my dissertation at the very moment.

Happy to report that I have a program to show! After a lot of trying I've decided to ditch the idea of using shaders completely. I've tried using GLSL (which was very tricky for my intended purpose) and even Cg when GLSL didn't work. After asking around in the forums I've found out that the shader programs have limited ability to process data and texture calls.

The problems were solved when I switched to using CPU only. I've re-structured the whole framework and it is now very simple to read and also make changes. This does come with the price of sacrificing performance as the code could be further optimised for that.

Anyway, I've settled on a novel Spherical harmonic lighting and ray casting hybrid solution. I've managed to implement dynamic lighting, soft shadowing and inter-reflected on textured surfaces using this method. I admit that this solution is not (yet) 100% real time and some values are precalculated before runtime but I think that at an honours project level, this is a very good achievement and experience gained.

Here are some screenshots of the program in action :

SH lighting with shadows :



SH lighting with shadows and inter reflections:


The works! Sh lighting, soft shadows, inter reflections and fully textured with simple animated water:




I've also output some basic debugging informations such as ray samples and loading times through the console window:





It's normally around 17 seconds on my computer but I have a lot of background applications open so I guess that slowed it down a little. Considering the code could be further optimised and also the number of samples this is considered good results.

Right, now back to the dissertation!

Monday, 22 March 2010

Progress update - 22nd March 2010

It's been a long while since my last update but progress is good so far. Due to time and resource contraints, I've decided to omit several features from the application and decide to focus my research on the GI aspect.

What I have done:

  • Framework  - Basically have the "finished" framework. Just some testing on the shaders
  • Thesis writing - Have started planning on what to write and am beginning the first chapter - Introduction
What I am still doing:
  • GI techniques research - basically this will be an ongoing effort throughout the project
  • Writing the shader - This is fairly complicated and takes some time to get it right.
  • Testing  - Just to see there's no bugs
What I haven't done:
  • Water effects and vegetation - not very sure at the moment if I can manage to implement GI on them as it will take some extra work. Concentrating on finishing the shader first before attempting this. I could have some simple water effects and maybe vegetation that is not lit by GI but again will look into this after completing my shader.
Problems faced and anticipated:
  • Procedural shaders - one of the hardest aspect in this research. A lot of reading to do and testing. Derek's method uses the DirectX HLSL which have built-in multipass and custom render target feature while I have to deal with OGLSLs Frame Buffer objects and maybe 3D textures to get things working.
  • Cutting out of features - my initial scope for the research seems to be a little bit demanding and due to the time plus resource contraint I might have to cut back a little. I am not sure if I have enough time to fully implement GI for the water and vegetation at this point.
Conclusion so far:

Global Illumination seems to be a fairly involving topic. From my progress so far I can see now that my initial ideas would require a lot more time. However, I have done substantial research and are now trying my best to get the shader coding done. If no major problems crops up (fingers crossed!) I should have a working demo to show some basic GI effects on terrain in OpenGL. So hopefully I can have some nice pictures up on the blog.

However I feel that the most important bit will be the dissertation where I would have to document what I've read, what I've tried, what worked and what didn't and lastly why. Time organisation is critical here as writing the dissertation would also take up a big chunk of time. I would have to get all the resources properly organised and catalogued on top of producing a good write up detailing the whole research.






Tuesday, 9 February 2010

Progress update 9th February 2010

Here is a summary of my progress thus far:

What I have done:
  • Initial Research - Covering GI techniques
  • Basic Framework study - Finalising the shaders etc, building a "vanilla" structure
  • Resource gathering for report
What I am still doing:
  • GI techniques research - basically this will be an ongoing effort throughout the project
  • More work on framework - Terrain generation and testing
  • More testing  - Theories and implementation of them in framework, tweaking
What I haven't done:
  • Start on thesis
  • Have a solid framework
Problems faced and anticipated:
  • Buggy framework - shaders
  • Proper structure/format of thesis
  • Resources required to write dissertation 

Thursday, 21 January 2010

Progress update January 2010

Not much has been done so far as I am pretty swamped with courseworks. However, more progress shall be made after the submission of the final coursework which is due soon.

A little update of what has gone on so far in regards to the Honours Project:

  • Got a basic framework up and running. Just trying to tidy up the code a bit so I can "plug-in" the GI algorithms in the future.
  • Have decided on a more focussed approach to project implementation. I am now reading up John Snyder and Derek Nowrouzezahrai's work on Fast Global Illumination on Dynamic Height Fields and also Fast Soft Self-Shadowing on Dynamic Height Fields. Very interesting read and very good candidate for implementation. Main aim is to get his technique working in my demo framework at the moment.
  • Thinking of some extras such as simple vegatation and water caustics for the demo. I am not sure at this stage if it will be procedural vegetation. Both of them will have GI implemented. I am looking into several methods but at the moment focussing on Instant radiosity
  • I plan to also implement a real time directional light source (sun light) which the user can manipulate. 

The topic I have chosen seems to be very involved and requires a lot of techical reading. Next plan is to draft a Gantt chart so I can stick to a more focussed schedule. I will consult my Technical supervisor soon and will update the post as needed.

Here's a glimpse of Derek and John's work : cool video

Sunday, 10 January 2010

Honours Project Proposal

w fast time has passed it seems... Been very busy with two other courseworks so hardly have time to update blog as frequent as I would have liked it. Anyway, here is my Honours Proposal submission :

This is a copy of the Gantt Chart (click to enlarge) :


 
and the PDF file can be found here

(The Word document format for the proposal can be found here)



Introduction

Global illumination (GI) refers to algorithms used to enhance realism using lighting for a 3D scene. This group of algorithms differ to the common techniques used to light a scene because they not only take into account the light emitted from a light source but also the light reflected by objects from this light source. These are called direct and indirect illumination respectively. Common examples of algorithms used in GI are ray tracing, radiosity, ambient occlusion, photon mapping and image based lighting. Sometimes hybrids of these examples are also used to produce a more realistic yet efficient result. [Wikipedia] Generally though, ray tracing is an offline or a non-real-time method that is computationally extremely expensive. On the contrary rest of the methods mentioned above are very efficient and can be cleverly implemented in real-time.

Scenes rendered using Global Illumination algorithms are more photorealistic. Lighting is a very important factor in photorealistic rendering. The physical processes that form the basis of photorealistic rendering are light-material interaction, light transport and also the psychophysical aspects of the human visual system. [Dutré, et al., 2006]

However, GI could be very computationally expensive to implement, especially in real time and dynamic applications. In the past, high quality realistic scene could only be rendered offline and that also takes a considerable amount of time to achieve. Another alternative is to produce highly inaccurate and low quality results. [Stokes, et al., 2004]

Recently, computer generated 3D terrain is becoming more popular in various applications. Games ranging from first person shooter to strategy implements some form of terrain generation. Realistic computer generated terrain is also used in advanced mapping software and also in simulators used to train pilots and military personnel. A very good example is a 3D geospecific terrain created to train soldier fighting in Afghanistan. Created using proprietary software called the "Virtual Reality Scene Generator" developed by MetaVR, it could generate over 9,600 square kilometres of geospecific landscape with 500 accurately modelled buildings. According to MetaVR's developers, "Unlike the simplified, flattened terrain used to simulate urban environments in most image generators and video games, MetaVR’s Afghan village is set within mountains, complex terrain of varying elevation, and cave complexes enabling realistic training scenarios for operations in mountainous villages." [metavr, 2009]

To achieve a level of realism required for some applications of which include terrain generation, GI techniques could be considered. For real time terrain generation, the visual complexity is due to its lighting and not just the geometry. Lighting calculation when the whole generated terrain is static is relatively easy since most of the lighting calculations could be done before rendering. However, when considering a more dynamic environment, or even real time applications, applying GI techniques could also be challenging. [Mitchell, et al., 2002]

Motivation

It will be interesting to research into methods to push the boundary on how realistic a terrain can be rendered in real time. I am also personally very interested in graphics programming especially when it involves games. I hope to find a cheap and effective method of greatly improving the visual realism in games to add even more immersion.

With the advancement of GPU technology, the door opens to a multitude of new possibilities in graphics rendering. Traditionally, generated terrains were limited to heights fields that are generated by CPU and then rendered by the GPU. [Geiss, 2007] It is now possible use the raw processing power of the GPU to render a much more complex and realistic procedural terrain. Realistic lighting is also one of the biggest issues in real-time terrain generation. A lot of games that features outdoor scenes such as MMOs will benefit from this research.

This honours project fully meets the course requirements as it requires both technical writing skills and also programming skills. Most of this project requires in-depth technical and background reading. Proper project management and planning skills are also required to ensure that the project will have some accomplishments. Furthermore, research into graphics programming is very relevant to the course as it is a vital part of the computer gaming industry. Appropriate research and testing will also be carried out and an analysis would be done to cover any problems faced during the course of the project.

Research Topic

The GI techniques will be applied to a framework demo which is a scene of a 3D world consisting of a procedurally generated terrain coded using the C++ language and the OpenGL API. There would also be implementation of vegetation, simple water effects and a dynamic directional light representing the sun in the demo. Fractal methods such as midpoint displacement and fault line algorithm will be used to generate terrain's height field.

The demo would most probably feature procedurally generated height field geometry with a few non-height field elements such as vegetation and some bodies of water. A simple directional lighting representing the sun with some low-frequency environmental lighting will also be added.

Rendering water is relatively easy but simulating it requires advanced mathematics and physics. Interactive fluid dynamics rendering and real-time particle based fluid simulation using Lagrangian and Hamiltonian systems are a good source for interactive fluid dynamics rendering and real-time particle based fluid simulation.

However, again due to time constraints, considerations will also be made to generated simple water with primitive animation and reflections as discussed in Polacks's book, Focus on 3D Terrain Programming [Polack, et al., 2003]. These types of simple methods are mostly used in real-time games and applications due to their high visual quality and extremely fast rendering speed. To further enhance realism, real-time caustics can be implemented.

The advantage of real-time procedural terrain generation is that there is no requirement of pre-modelled 3D mesh or a 2D height map. Procedurally generated terrains also have an outstanding visual quality and are extremely fast, hence perfectly suited for real-time applications. Soft shadows will be implemented in the terrain. Soft shadows differ from the more common hard shadows because their penumbras lighten gradually as the shadow caster recedes from the receiver. [Fast Soft Self-Shadowing on Dynamic Height Fields, 2008] This will result in a greatly improved shadowing effect.

To handle the GI on the terrain, the aim is to try to implement work done by Derek Nowrouzezahrai and John Snyder to the demo. Their work covers a real-time method for rendering GI effects that can be applied to a large area with environmental lights. Their method involves handling indirect lighting and non-diffuse surfaces. [Fast Global Illumination on Dynamic Height Fields, 2009] From reading the paper it seems that their technique is effective and will be realistic to be implemented for the project.

Another method that will be looked into is “Lightcuts”. [Lightcuts: A Scalable Approach to Illumination, 2005] Simply speaking, it is a framework that approximates global illumination and several of its subset techniques. It can be applied to a dynamic range of situations and the output quality is very good in the open environments when simulating daylight.

Research Question

"What are the techniques involved in real time lighting effects for procedurally generated terrain?"


Methodology

Comprehensive literature review into GI techniques would be researched to further understand about GI in real time applications such as terrain generation. A good understanding of the topic at hand is very important to ensure that the project can be carried out smoothly. I will also draft out milestones to monitor project progress and make any necessary adjustments to ensure that the main objectives of the project could be completed on time. I will try to create a Gantt chart to help me keep track of the project.

The methods proposed by Derek Nowrouzezahrai will be focussed on and implemented in the framework demo because there is a lower chance of failure as Derek has already tested it on an open terrain.

As there's always chances of failure in the proposed method, I have decided to also look into the "Lightcut" method mentioned as a backup plan. This is to ensure that I will have some submissible work at the end of the project implementation period.

The real time water simulation and animation will have a lower priority and the simplest method of implementation will always be chosen. However I believe with simple reflections/refractions and animation, it will be adequate to look realistic. As for the vegetation, I will randomly place billboard trees and grass on suitable and realistic position on the terrain. For simplicity the vegetation will be non-animated.

The main resource requirement for this project is a lot of relevant literature. A C++ debugger and compiler such as Microsoft's Visual Studio 2005 and the OpenGL API is also a basic required for the software side while the hardware requirement would be a decent computer able to handle running the demo. At the moment, the computers available in the university's laboratory should be adequate.


Project Evaluation

As the main bulk of the project will be on research, a good way of evaluating the outcome is through the produced dissertation. The results of the literature review and comparison of possible GI implementations and in-depth analysis of the research question will be included along with the dissertation.

The demo would also aid the evaluation process as it will show the ideas behind the project visually. At the moment it is planned to include a simple Frames per Second (FPS) and Polygons per Second (PPS) counter in the demo to try to show the efficiency of the technique employed.

Possible Issues

GI is a very wide and complicated topic and implementing GI on procedurally generated terrain is also a very challenging task. Thus there could be some issues faced along the way. Below is the list of issues that could probably be encountered during the course of the project:

1) Time constraint is the most probable issue as well so a very rigid schedule has to be drafted and followed. I will plan regular meetings with my technical supervisor to ensure that my work is feasible to be carried on.

2) Longer than planned timeframe required to implement GI on extra features such as vegetation and water bodies. Using static vegetation could minimise problems faced.

3) Performance penalty that could occur as terrain generation with GI implementation uses a lot of resources from the CPU for crunching algorithms and also requires a decent GPU to handle rendering. Proper testing will have to be done to avoid any bottlenecks and "mini" optimisations carried out at every stage to ensure that the final demo will still run decently. If there are too much problems faced and not enough time to properly rectify it, the features would be left out accordingly.

4) The computers in the university laboratory might not be able to run the demo. Constant testing in the universities laboratories will be carried out and if the final demo can't run on the university's computer I will try to request a machine that is capable to or try to bring my own computer.



References

1. Dutré, Philip, Bala, Kavita and Bekaert, Philippe. 2006. Advanced Global Illumination : Second Edition. Massachusetts : A K Peters, Ltd., 2006. ISBN.
2. Fast Global Illumination on Dynamic Height Fields. Nowrouzezahrai, Derek and Snyder, John. 2009. 4, s.l. : Eurographics Symposium on Rendering, 2009, Vol. 28.
3. Fast Soft Self-Shadowing on Dynamic Height Fields. Snyder, John and Nowrouzezahrai, Derek. 2008. s.l. : Eurographics Symposium on Rendering, 2008.
4. Geiss, Ryan. 2007. Generating Complex Procedural Terrains Using the GPU. [book auth.] Hubert Nguyen. GPU Gems 3. Massachusetts : Pearson Education, Inc., 2007.
5. Lightcuts: A Scalable Approach to Illumination. Walter, Bruce, et al. 2005. s.l. : ACM SIGGRAPH 2005 conference proceedings, 2005.
6. metavr. 2009. MetaVR announces new Afghanistan 3D Terrain and the Release of Virtual Reality Scene Generator Version 5.5. Virtual Reality Resources. [Online] 2009. http://vresources.org/node/2009.
7. Mitchell, Kenny and Hoffman, Naty. 2002. Methods for Dynamic, Photorealistic Terrain Lighting. [book auth.] Dante Treglia. Game Programming Gems 3. Massachusetts : Charles River Media, INC., 2002.
8. Polack, Trent and LaMothe, André. 2003. Focus on 3D Terrain Programming. Ohio : Premier Press, 2003. ISBN.
9. Stokes, William A, et al. 2004. Perceptual Illumination Components: A New Approach to Efficient, High Quality Global Illumination Rendering. s.l. : ACM Transactions on Graphics (Proc. of SIGGRAPH) 23, 3,742–749, 2004.
10. Wikipedia. Global Illumination. Wikipedia. [Online] http://en.wikipedia.org/wiki/Global_illumination.



Bibliography

11. Dickheiser, Michael. 2006. Game Programming Gems 6. s.l. : Charles River Media Price, 2006.
12. Nguyen, Hubert. 2007. GPU Gems 2. Massachusetts : Pearson Education, Inc., 2007.
13. Real-Time Caustics. Wand, M. and Straßer, W. 2003. 3, s.l. : EUROGRAPHICS, 2003, Vol. 22.
14. Shah, Musawir A. and Pattanaik, Sumanta. 2005. Real-time Caustics Rendering. [Online] 2005. http://graphics.cs.ucf.edu/caustics/.
15. Shastry, Anirudh.S. 2005. Soft edged shadows. Gamedev.net. [Online] 18 January 2005. http://www.gamedev.net/reference/articles/article2193.asp.
16. Slater, Mel, Steed, Anthony and Chrysanthou, Yiorgos. 2002. Computer graphics and virtual environments : From Realism to Real-time. Essex : Pearson Education Limited, 2002.
17. The Terrain Rendering Pipeline. Roettger, Stefan and Frick, Ingo. 2002. s.l. : In Proc. of East-West Vision, 2002.

Wednesday, 18 November 2009

RQ Workshop

Below are the answers provided to the RQ Workshop worksheet (Worksheet 4)

1) What is the name of this module, how many credits?
CS1004 – Honours Project Planning & Reporting

2) Your technical supervisor, how many times have you met?
Only met him once but the first meeting was very production, it gave me a lot of new ideas for the research question.

3) How frequently do you update your blog?
Once a day, sometimes one every 2-3 days depending on how much progress I made. I would update my Project Diary more often than the blog as it’s informal and I could jot down rough ideas.

4) Have you included both you worksheets in your blog?
Yes, I have.

5) Have you made sure readers can leave comments and you can annotate the blog entry based on these feedbacks?
Yes, I have.

6) Have you subscribed to any game related forum and posted your RQ research ideas and got feedback?
I have posted on the GameDev forums asking for people’s comments but so far it doesn’t have any replies yet.

7) Have you looked for additional feedback other than the ones I’ve prescribed?
Not at the moment.

8) What backup procedure have you implemented?
I have used a program called Blogger Backup Utility to backup the blog in XML format so I can restore it if the blog is accidently delete. I have also saved the whole page as html so that I will still have the pictures on the blog.

9) How long do you spend for your Honours project activities?
To be honest I haven’t been really spending enough time during the first few weeks of the project. I have now scheduled my activities better so I am spending an average of 2 hours a day (excluding weekends) on the project.

10) What is your RQ?
What are the techniques involved in real time lighting effects for procedurally generated terrain? However the research question might be slightly tweaked later on for the final proposal submission.

11) Why is it important?
It will help me understand more about lighting in graphics programming.

12) How will you answer it?
First step is a lot of reading. I must source all the related books and papers to understand more and finally focus on the final method of approach.

13) So what will be your measure of success?
I will be happy if I can implement a demo that shows a photorealistic rendition of a procedurally generated terrain.

14) What will be the significance of what you have done?
I hope that this will give me an opportunity to enrich my CV and to help me seek employment that hopefully will specialize in the field of graphics programming.

Tuesday, 27 October 2009

New Inspiration

First meeting with technical supervisor, Matthew Bett taken place today. The meeting was very productive and the outcome was excellent as the discussions fuelled ideas and probably a new direction for the project.

Previously, simpler lighting techniques were considered such as height based lighting, slope lighting and lightmapping algorithms. Currently, the consideration of rendering a High Definition Range Imaging (HDRI or just HDR for short) terrain/scene contained within a skybox is considered. Basically HDR renders a scene using  lighting calculation using a larger dynamic range as compared to traditional methods. This will greatly enhance the realism on the scene.

The challenge now is to consider how to handle materials in the scene which consists of mainly the terrain mesh. The terrain would also be largely static so that could be a challenge to bring out the HDR qualities. The idea of using a HDR Environment map as the light source and reflection map is being investigated at the moment as it is not sure how well it could be implemented in the application.

Below is an example of how HDR can greatly boost the realism of a computer generated scene :



 

Example from the popular PC game Crysis

Complex 3D models won't be featured (or will only be featured minimally) in the demo so most of the HDR lighting will be done on the terrain itself. At this stage it is not yet certain of the real time performance and also the chance of procedurally generating such a scene.

Soft Shadows - This is also considered to be implemented in the scene

Changing of primary light source position/direction and also consideration of auxillary light sources
This is yet another problem that has to be researched into.

There's seems to be abundant techniques out there for photorealistic computer graphics rendering. The next aim is to pick out suitable ones for the research.