Sunday 1 April 2012

Collision Response

For a proper collision response, a normal to the surface is required.
But of course my geometry has none...

Easy fix, calculate the normals on the fly when they are needed!

How?

Sample the points surrounding the point on the surface.
This gives 9x9x9 points (if you include the point itself).
For each of these points, if it is filled, move the normal away from the sampled point.

Doing this I have managed to achieve a very nice collision response to any point on the surface.
(Its awesome =P)

Wednesday 28 March 2012

Point Collisions

I've finally moved away from working on the rendering side of things and have managed to implement a point collision detection system.

To do this I have a slightly decompressed version of the voxels in main memory (for use on the CPU not the GPU). I decided it was best to do the collision detection on the CPU since the GPU is already struggling with the insane number of triangles.
(Side Note: Have achieved slightly better performance by fixing a bug which caused half of the voxels to not be rendered...oops =P)

The CPU version of the data is stored as start and end indices of the voxel segments. Since these are in order I am able to binary search the data. Giving me O(Log2(N)) access to voxels.
This allows me to check whether a single point is filled or empty, therefore providing point collision detection.

I am trying to think of a way to check for intersections with shapes without checking per voxel but I'm not sure how this could work yet.

Tuesday 27 March 2012

And Now For Something Completely Different...

In an attempt to create a more interesting landscape, I had an idea.
Offset the time values of 3D Brownian Motion with the results of a 2D slice of complex fractal.
Shown here is the results of a Rigid Multi Fractal.




Stats:
512 x 512 x 512 = 134,217,728 Voxels
8.17MB = 8,573,371 Byte Filesize

A fair bit larger file than the previous landscape but it contains a lot more detail.

Procedural 3D Texturing

This mixes 3D Perlin Noise Turbulence with a 2D detail image to attempt to create an appearance of rocks covered in moss.

I've fixed my filtering issues =)
They were cause by the way I was storing the fragment positions. I resolved the issue by changing to recreating them from the depth buffer.
This combined with the previously mentioned dFdx/y functions creates perfect deferred texture filtering.

Also I've altered and simplified my compression it now uses fixed size run length codes (unsigned short (2 bytes)) which has reduced file sizes by a few megabytes.

This "landscape" consists of 512 * 512 * 300 = 78,643,200 voxels.
Its file is 1.56MB = 1,643,755 bytes.
Therefore, a 78 times reduction.

Monday 26 March 2012

3D Brownian Motion

Interestingly, 2D fractals such as Brownian Motion and Rigid Multi Fractals appear to have very little difference to each other in 3D...

Friday 23 March 2012

3D Noise and Texturing

I'm currently working on Landscape generation using 3D perlin noise. Unfortunately, there seems to be something wrong with my noise or the way I'm sampling it...
But its still pretty cool....

Also, pictured is deferred texturing and lighting, with point light at the camera's position.

Note to Erin: slightly improved texturing by using the glsl functions dFdx and dFdy with textureGrad.