Voxel Cone Traced Soft Shadows
Asked Answered
C

2

14

I have recently implemented soft shadows using voxel cone tracing in OpenGL 4.3 by tracing a cone in the direction of the light and accumulating opacity values. enter image description here

The key thing that I am trying to resolve or hide is the very voxelized shadowing effect as the occluded surface gets closer to the occluder, as well as hide the clear spots in the shadow due to surface voxelization. I am using low resolution voxels 64x64x64; however, even if I use higher resolution voxels, some of the low-res voxels at a higher mip-map level are still captured in the trace.

So here's what my first idea is: I want to be able to keep the softest parts of the shadow that is furthest away and replace the parts of the shadow that is closer to the occluder with a shadow map. The shadow map will fade as it is further away from each occluder and I will somehow blend it into with the cone traced shadows.

enter image description here

Can anyone think of a way to fade a shadow away based on distance from each object for a shadow-map and then have it blend smoothly into the cone-traced shadow?

Another idea I have would be to somehow ray-trace shadows onto surfaces that are closer to an occluder, but this would probably be too expensive.

Alternatively, I would welcome any other ideas to help improve my soft shadow algorithm.

I've also put up a video to show it in motion:

https://www.youtube.com/watch?v=SUiUlRojBpM

Still haven't found a way to resolve the shadowing issue.

Cns answered 16/2, 2013 at 10:21 Comment(7)
+1 – finally again a question, that's not on a newbie level and makes tickle my brain :) Let me see what I can think of…Carolann
In the cone tracing algorithm, do you use the alpha value of the voxel to indicate whether the voxel is occupied or not? If so, the default mipmapping algorithm in opengl may not give you correct results. Also are you using a sparse voxel octree representation?Bailey
For the indirect diffuse and specular, I sample the 3D texture by offsetting in all 6 directions by 1 voxel - for every mip level. I guess this gives me 2x2x2 "bricks", if I have understood the theory correctly. I trace the cone until the opacity value becomes 1 and it reaches my defined maximum distance. I have noticed that the default mipmapping is not very smooth, so I guess my results should improve if I used 3x3x3 bricks - at a bit more cost of performance? I'm not using an octree structure, but this is on the list of things to implement.Cns
Any question with Stanford models in it is a good question.Renfro
I don't know how you apply your shadows, but let's assume you have a shader and you do a shadow map look up. If the object is then occluded, we could simply get the distance from the point on the surface to the light, and fade based on some arbitrary parameter. It would be a disrepancy between the shadow map and your soft shadow in the "blending" zone though. I don't know if you'd consider this too costly, but it would not require ray tracing, furthermore it would only happen in the shadowed zone.Renfro
With the hard shadows I'm using a shadow map - with this, the shadow map is the image that the light sees and this is projected onto all object surfaces that the object occludes - so distance values are not part of the equation. I'm wondering if there is a way I can fade the top of what the light sees - but it has to be done per object.Cns
I think it may be possible to compare the world position of the object with world position on a light map and use its size/2 to determine the top surface of the object. I know that the unreal engine 3 has an efficient way to fade shadows out, I'm not sure how they do it though.Cns
D
2

I'm guessing the "clear spot" artifacts are occurring due to large voxel sizes only being partially filled with geometry: "accumulating opacity values.". How many samples are you taking when converting from rasterized pixels to voxels? If the sample volume/voxel volume is small then there could be issues with correctly rendering transparency - there will be noise indicated by lighter areas.

Also, are your voxels' transparency direction dependent? Based on the author's original paper. Directional dependence is important to ensure semi-opaque voxels are rendered correctly.

A quick picture to explain

"for a shadow-map and then have it blend smoothly into the cone-traced shadow?"

This seems like you are kind of shooting yourself in the foot. You get an even larger performance hit and get the disadvantages of both shadow mapping and voxel cone tracing. Voxel cone tracing is expensive but can give nice soft shadows and do global illumination. Shadow mapping is better at doing hard shadows and is faster for smaller scenes, but as you add more geometry you end up redrawing the same stuff multiple times, at least once for each light.

Great work btw. I came across your problem while doing preliminary research for my own DirectX implementation of voxel cone tracing.

[Edit]

I realized that I made a typo in the picture. The picture on the right should be 4/64, rather than 4/16. I forgot about the Z dimension.

Distinct answered 24/3, 2013 at 20:53 Comment(1)
Glad to see other ppl also working on this technique. I am not using directionally dependent transparency. I had originally planned to replace my surface voxelization with solid voxelization which should get rid of the holes as well as eliminating "hollow" specular reflections (i.e. my specular reflections are transparent due to semi-transparent blending of voxels). My fear of using directionally dependent voxels is that it would cost significantly more than using solid voxelization.Cns
D
0

Well, in this case you can do it by adding more lights. You can add more lights closer to the original one and then compose the shadow of a light with the shadows of a bunch of closer lights. That is the 'area light' effect.

Determinable answered 2/3, 2013 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.