Voxel Cone Tracing Experiment - Progress

Started by
27 comments, last by gboxentertainment 10 years, 10 months ago

Here's transparency:

[attachment=13828:giboxtransparency0.jpg][attachment=13829:giboxtransparency1.jpg]

Not sure entirely how correct this is - the backface seems to be on top in the depth order. I've tried placing the code:


	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);

both before and after enabling depth test, but doesn't make any difference. You will notice when I go to the back of the glass Buddha that only his back shows, whereas when I am in front of him, both his back and front faces are shown. There is no backface culling that I am aware of.

Other things I have to add is refractions and and caustics.

Advertisement

Cone-traced refraction without transparency (Translucency):

[attachment=13830:giboxrefraction.jpg]

So it seems that I've got three choices:

  1. Render using alpha blended transparency which cannot provide refractions (but still looks cool).
  2. Cone trace refraction by copying the specular cone trace and replacing the reflection vector with a refraction vector - very slow (13fps with the Buddha) and still very blurry even with a 0.01 cone ratio. At some view directions, the object does not look translucent at all.
  3. Render refraction using cube maps - may provide most accurate image but I'd imagine this would also be quite slow. I might give this a go though.

[attachment=13831:giboxrefraction1.jpg]

The sphere is a lot faster, as expected [27 fps]

I still would like to get clearer refractions.

Here's a translucent cube:

[attachment=13832:giboxrefraction2.jpg]

One thing that is missing from cone-traced refraction is the back faces are not captured - not sure if there is a possible way to do this or to fake it.

I'm going to go ahead and say "Accurate refraction, who cares?" Don't particularly see the appeal of it, not at the performance hit being talked about, not above just a screenspace refraction anyhow.

It's nice in hypothesis, and then if you actually look at the results, it's not really that spectacular unless you are looking at some extremely specific object designed to show it off.

A thing that might be worth exploring more is voxel anti aliasing. If your mesh partially covers a voxel space, might it be better to have that voxel "partially" filled? Assuming you can get it working I wonder what the cone traced shadows would look like. At best it might also help with emissive stuff "popping" into a neighboring voxel, and it's associated light popping as well. You could get as many emissive objects as you'd want in a scene, unlimited shadows casting lights definitely sounds like a worthy goal, even if the shadowing is going to be a bit, blocky or something.

Great work so far smile.png

Really I've just been trying to get as accurate refractions as I can get for the sake of seeing if I can. But you are correct, I think I will just push this one aside - being a natural engineer, I tend to become obsessed with the little details sometimes too much - although that's what got me into graphics programming in the first place.

More importantly though, I do need to work out a way of either getting more accurate cone-traced soft shadows, or somehow masking the very voxelized core of the shadow that is closest to the occluder. I think the latter will be more achievable:

My idea is to render a shadow map and this would be blended in with the cone traced soft shadow. What I would start off doing is to fade out the shadow map at a certain distance away from each occluder. I remember being able to do this with Unreal Engine 3 shadows, however I never understood the technical specifics of it. I'd like to know if anyone knows of a way of doing this?

[attachment=13839:givox7.jpg]

Another thing I have to resolve is - if you look at the translucent cube, you will notice its shadow is incorrect. This is related to the issue in the following image, where the reflection of the red box only shows the top and side voxels as opaque and anything in shadow is transparent:

[attachment=13840:gibox0-1.jpg]

Technically, the base mip should be completely opaque with an alpha value of 1 - even when I try forcing the base mip alpha values to 1 the problem still persists.

A thing that might be worth exploring more is voxel anti aliasing. If your mesh partially covers a voxel space, might it be better to have that voxel "partially" filled?

So currently, my voxels are just blended together and when I sample for the cone trace, I take a voxel offset for six directions:

[attachment=13841:givox8.jpg]

which pretty much achieves what you are saying - unless you are referring to something else? Anyhow, I have heard an octree structure might be able to provide more accurate voxel antialiasing - which is something I will implement later down the track.

Here's some more cone-traced transparency tests, where I've made everything semi-transparent:

[attachment=13899:giboxtransparency2.jpg][attachment=13900:giboxtransparency3.jpg][attachment=13901:giboxtransparency4.jpg]

Just for a test, when I make everything else completely opaque - this is what I see when I look through a transparent sphere:

[attachment=13903:giboxtransparency5.jpg]

Just like the specular issue, everything else becomes transparent (especially notice the red wall), when it should not.

I know that it is to do with the way values are accumulated from the cone trace after the samples are filtered.

Filtering is required for smooth speculars and smooth refraction, however, because every object is only surface voxelized, the opaque surface voxels are filtered together with the transparent empty voxels inside each mesh. When the cone traces through an object, it does not saturate immediate after hitting the object due to the semi-opacity and thus continues on, adding values from behind the object - which leads to the transparent results.

I guess the best way to resolve this is to use solid voxelization; however, I'm pretty sure that Crassin uses surface voxelization according to his OpenGL Insights chapter, and in one of his videos he shows a very defined specular image with the moving hand, and there are no opacity issues.

I'm not sure whether this is because I am not filtering correctly because I am not using 3x3x3 bricks. The issue is still present when I use 512x512x512 voxel resolution for this small scene.

I might as well show off the effects that my current engine can achieve, before I proceed to improving it by implementing solid voxelization and octrees:

[attachment=13926:giboxbumps0.jpg][attachment=13927:gibox6.jpg]

[attachment=13928:gibox7.jpg][attachment=13929:gibox8.jpg]

[attachment=13930:giboxemissive10.jpg][attachment=13931:gibox-cyber.jpg]

I'm trying to put together a video soon as well.

Stress test:

100 spheres ~24fps

[attachment=14000:gibox-stress0.jpg][attachment=14001:gibox-stress1.jpg]

1000 spheres ~12fps

[attachment=14002:gibox-stress2.jpg]

Looks really good! Video footage is a must to get a better idea of how it is in action/motion :D

How much time have you spent optimizing i.e. is there room for improvement or have you exhausted everything?

Looks really good! Video footage is a must to get a better idea of how it is in action/motion
How much time have you spent optimizing i.e. is there room for improvement or have you exhausted everything?

Actually I have not optimized very much at all. No octrees...yet. The scene is entirely within one 64x64x64 3D texture. Entire scene is revoxelized per frame.

I never even purposely implemented any other screen-space techniques - apart from the cone tracing itself, which is naturally a screen-space algorithm.

The only other optimization that I had done was substituting a low-poly version of the Stanford Buddha model for the voxelization pass.

I am in the process of creating a tech demo video that shows off each effect. Recently Ive been side tracked by a sudden obsession with trying to implement tessellation. I'd also would like to fix the shadow issue - which I believe that switching to solid voxelization will resolve the problem...hopefully. But I guess I'll end up finishing the video before that.

I have finally put up a video:

This topic is closed to new replies.

Advertisement