Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/index.php:3) in /var/www/html/wp-includes/feed-rss2.php on line 8
PaulRidgway.co.uk http://www.paulridgway.co.uk Wed, 07 Nov 2012 08:25:56 +0000 en-US hourly 1 https://wordpress.org/?v=4.7.2 Real-time Environment Mapping in OpenGL http://www.paulridgway.co.uk/2011/08/09/real-time-environment-mapping-in-opengl/ http://www.paulridgway.co.uk/2011/08/09/real-time-environment-mapping-in-opengl/#respond Tue, 09 Aug 2011 16:43:27 +0000 http://www.paulridgway.co.uk/?p=190 Environment Mapping, also known as Reflection Mapping is an efficient technique for simulating realistic reflections. In many cases a precomputed texture is rendered on the object which represents the environment surrounding scene.

The following image is an example from Wikipedia:

20110808-101037.jpg

And the next is an environment mapped teapot it a room which “matches” the reflection texture:

20110808-101620.jpg

While the classic static environment mapping looks awesome in a scene, perhaps with a rotating object as the reflective target, it is sightly lacking in challenge as with OpenGL it can be done rather easily. A common example will include a skybox and an object with the reflection cube-mapped onto the focal object.

For my prototype I wanted to create a reflective cube that in real-time could demonstrate environmental reflection. With such a system it would be fairly trivial to use the dynamically generated texture to make many simple objects appear reflective using cube mapping.

For those who just want to see the video, it is embedded below:


For others who want details, read on…

The small cubes and the ‘room’ surrounding the cube rotate at different speeds and distances to demonstrate the reflection. The yellow sphere represents the light source which is applied using a basic per-pixel fragment Shader. From some angles the reflection clearly shows the lighting application and the reflected faces of the orbiting cubes move from shadow to light.

The texture for each face of the cube is generated and applied independently. For each frame all movement calculations are carried out once, then the scene is rendered to a Frame Buffer Object (FBO) 6 times, once for each face of the cube. It is then rendered once more from the point of view of the observer, this time to the screen. The camera is positioned at the centre of the cube looking though a specific face and the scene is rendered. The camera uses a 90 degree field of view to capture the image the cube face should reflect whereas the camera used to observe the scene has a 45 degree field of view.

Currently for each frame the textures for all 6 sides are generated and rendered at quite a high resolution. If performance became an issue then only the sides visible to the camera could be considered and a lower resolution texture could be generated.

I also made a variation where the Shader mixes the result of the lighting calculations on the main cube with the texture to give the appearance of a slightly matted reflection.

]]>
http://www.paulridgway.co.uk/2011/08/09/real-time-environment-mapping-in-opengl/feed/ 0
Network Based Scene in OpenGL http://www.paulridgway.co.uk/2011/08/07/network-based-scene-in-opengl/ http://www.paulridgway.co.uk/2011/08/07/network-based-scene-in-opengl/#respond Sun, 07 Aug 2011 08:25:00 +0000 http://www.paulridgway.co.uk/2011/08/07/network-based-scene-in-opengl/

This scene is rendered identically on two computers with a TCP server sharing the scene data. A cube created on any client is shared with all other clients.

More details coming soon…

]]>
http://www.paulridgway.co.uk/2011/08/07/network-based-scene-in-opengl/feed/ 0
Rescue from ‘execution expired’ in Ruby http://www.paulridgway.co.uk/2011/08/04/rescue-from-execution-expired-in-ruby/ http://www.paulridgway.co.uk/2011/08/04/rescue-from-execution-expired-in-ruby/#respond Thu, 04 Aug 2011 21:55:26 +0000 http://www.paulridgway.co.uk/?p=177 e # This will NOT catch 'execution expired' !! puts "Rescue : #{e}" rescue Timeout::Error => te # […]]]> Today I was trying to rescue from an ‘execution expired’ error when using another colleagues gem (which interfaces with an XML RPC API).

Thankfully I found this snippet at http://geoff.evason.name/2011/01/16/rescue-from-execution-expired-in-ruby/.

      begin
        # do something involving Net:HTTP
      rescue => e
        # This will NOT catch 'execution expired' !!
        puts "Rescue : #{e}"
      rescue Timeout::Error => te
        # This explicit rescue will work
        puts "Rescued from timeout : #{te}"
      end

Hopefully this will save someone a bit of time :).

]]>
http://www.paulridgway.co.uk/2011/08/04/rescue-from-execution-expired-in-ruby/feed/ 0
Continuous Terrain Generation http://www.paulridgway.co.uk/2011/08/03/continuous-terrain-generation/ http://www.paulridgway.co.uk/2011/08/03/continuous-terrain-generation/#respond Wed, 03 Aug 2011 08:07:29 +0000 http://www.paulridgway.co.uk/2011/08/11/continuous-terrain-generation/

I saw this done for a dissertation and decided to try it for myself. The height map is generated on the fly based on the last data known to create a smooth variation.

More details coming soon…

]]>
http://www.paulridgway.co.uk/2011/08/03/continuous-terrain-generation/feed/ 0
Hierarchical Quadratic Mesh http://www.paulridgway.co.uk/2011/08/01/hierarchical-quadratic-mesh/ http://www.paulridgway.co.uk/2011/08/01/hierarchical-quadratic-mesh/#respond Mon, 01 Aug 2011 08:03:55 +0000 http://www.paulridgway.co.uk/2011/08/11/hierarchical-quadratic-mesh/

Taking the Hierarchical Triangular Mesh prototype further, with a quadratic version texturing is easier using a skybox-like texture.

More details coming soon…

]]>
http://www.paulridgway.co.uk/2011/08/01/hierarchical-quadratic-mesh/feed/ 0
Hierarchical Triangular Mesh http://www.paulridgway.co.uk/2011/07/28/hierarchical-triangular-mesh/ http://www.paulridgway.co.uk/2011/07/28/hierarchical-triangular-mesh/#respond Thu, 28 Jul 2011 08:00:00 +0000 http://www.paulridgway.co.uk/2011/07/28/hierarchical-triangular-mesh/  

 

A HTM based sphere generation prototype, each primitive is approximately the same size and therefore it does not suffer from any singularities.

http://research.microsoft.com/apps/pubs/default.aspx?id=64531

http://researchweb.iiit.ac.in/~shiben/docs/HexGeomClip_Shiben-PJN.pdf

More details coming soon…

]]>
http://www.paulridgway.co.uk/2011/07/28/hierarchical-triangular-mesh/feed/ 0
OpenGL World Generation http://www.paulridgway.co.uk/2011/07/25/opengl-world-generation/ http://www.paulridgway.co.uk/2011/07/25/opengl-world-generation/#respond Mon, 25 Jul 2011 07:56:00 +0000 http://www.paulridgway.co.uk/?p=408

This prototype procedurally generates and textures a sphere to that it looks like the earth. Unfortunately it suffers from polar singularities, where the vertices for all the longitudinal slices meet and cause a dithering artefact on the screen.

More details coming soon…

]]>
http://www.paulridgway.co.uk/2011/07/25/opengl-world-generation/feed/ 0