• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
spek

tex3D & raytracing performance

6 posts in this topic

Simple question... or at least... let's start simple: Is a tex3D read (much) more expensive than a tex2D read?

With attempt #3529 on G.I. I tried to store light data (as voxels) in 3D-textures and raycast through them in several ways. It "works", but in order to keep it realtime, I need to reduce the raycasting loops as little as possible. Less voxels, short-range rays, less rays... All in all, the quality suffers and its still pretty damn slow. To give an idea what's going on:
[code]
// for ~25.000 voxels (rendered as points into a 64x64x64 3D texture)
// the fragment shader sends out 9 rays in several directions, to see where they collide with
// the environment (stored as SH values into another 64x64x64 3D texture)
for (int i=0; i < RAYCOUNT; i++)
{
float3 direction = RAY_DIR[i];
float3 rayPos = startPos;

// Check where the ray hits a surface
while !occluded && steps++ < 25
{
rayPos += direction * stepsize;
float4 occl = tex3D( shTexOccl, rayPos );
// decode Spherical Harmonics, and check if we collided
...
}
// Get GI data from ray end position
...
}
[/code]
The raycasts are killing here. But at the same time, other effects that test rays over 2D textures don't seem to be very slow (RLR reflections for example can easily do hundreds of checks per pixel over a fullscreen image)...
- Is tex3D really that slow?
- Or is it just because the rays fly in all directions, making it very hard for the GPU to do things in parallel / texture caching?
- And/or is the loop coded in a dumb way?

Of course, there are multiple ways to store data. I could splat down everything into a 2D texture, or put it in a buffer for example. Not figured out how Crassin exactly stored his Voxel Octrees for techniques like "Voxel Cone Tracing", but it seems to be a mixture of 3D textures, data-buffers, and moreover, fast enough to achieve awesome things in realtime... Any hints on effective raytracing on a GPU?

Cheers,
Rick
1

Share this post


Link to post
Share on other sites
Just exchange the tex3d access with a tex 2d access. Does it performe better ?

In worst case you have 225 independent reads + some calculations, which isn't really fast, considering that the worst case scenario of a single pixel can kill the performance of a whole pixel block. 3d texture access has theoretically some more work when filtering, but this depends on hardware implementation.
0

Share this post


Link to post
Share on other sites
Hey!

You mean just change the tex3D call into tex2D? I can't try it right now, but wouldn't that case a lot of faults, and completely different behavior on the GPU, as the collision detection is wrong? The raycast(or "march") loop converts a world position into a volume texture space, then checks if that cell is blocking the ray or not. It could be done with a 2D texture too of course, but then I first would need to remap the coordinates. Which doesn't (easily) allow (tri)linear-interpolation btw.

But from what I understand a bit, a 3D texture read isn't necessarly a lot slower than a 2D read, asides from some a bit more complicated filtering?

Likely single pixels are indeed ruining the parallel multithreading party. I suppose the longest ray (= taken most steps) will dominate the performance of a black. And since the rays fly in all directions... Either way, does someone have experience with building fast raymarching in volume textures (or equivalents)?

Cheers
0

Share this post


Link to post
Share on other sites
Well I suppose the idea is that Crassin was using a voxel octree and not just a voxel volume, which is a completely different approach (instead of marching through the volume, you raytrace against bounding boxes that enclose voxels) and is much more efficient. Brute-force volume raycasting simply does not work well on GPU's, it's already a slow method and the incoherent rays just make it that much worse. You could probably squeeze a few more frames per second out of it but it's probably not going to be realtime with the same quality as voxel octrees :/

Put differently, the raycasting algorithm you are using is too naive and has O(n) performance anyway (because as the number of voxels in your volume increases, you will need to increase the number of ray steps, otherwise you won't be able to resolve the smaller voxels, so your raymarching cost is directly proportional to the number of voxels you have, even if it doesn't seem to be) whereas voxel octrees have O(log(n)) performance. Still largely asymptotic, and to be fair the reason it's even realtime at all is not so much the octree but more a significant number of clever implementation tricks and hacks to make it run just that little bit faster. Edited by Bacterius
1

Share this post


Link to post
Share on other sites
Didn't read the exact implementation of voxel trees, but if I understand it right, they aren't storing the octree into a texture, but a ....cbuffer or something? So the marching loop checks that data, then the octree leaf-nodes point to a certain space in a (3D) texture where actual data such as colors (for several directions) are stored.

If that's the case, I wonder why they store light/colors in a texture. Just to benefit from (tri)linear filtering?


Talking about Voxel Cone Tracing. I still wonder how they deal with walls in narrow environments. As the cone gets wider, it samples from larger
nodes, which contain the averages of its sub-cells. But what to do if those larger cells overlap multiple rooms/corridors with walls between them? I guess that's still an issue, but since Unreal4 is using VCT, they might have found a smart trick?

Cheers
0

Share this post


Link to post
Share on other sites
[quote name='spek' timestamp='1349541239' post='4987432']
If that's the case, I wonder why they store light/colors in a texture. Just to benefit from (tri)linear filtering?
[/quote]

That's the main reason. Storing in a 3D texture also means that the memory accesses for bilinear filtering will be at least somewhat coherent, since GPU's will store 3D textures in a tiled layout.

[quote name='spek' timestamp='1349541239' post='4987432']
Talking about Voxel Cone Tracing. I still wonder how they deal with walls in narrow environments. As the cone gets wider, it samples from larger
nodes, which contain the averages of its sub-cells. But what to do if those larger cells overlap multiple rooms/corridors with walls between them? I guess that's still an issue, but since Unreal4 is using VCT, they might have found a smart trick?
[/quote]

Thin geometry is always going to be a problem for techniques like this. The Unreal guys attempt to deal with it by storing lighting in an ambient cube basis (1 color for each of the 6 major axis directions). Using such a basis lets you prevent the contribution from the other side of thin geometry from "leaking" into your sample, and also lets you generate mips independently for each direction.
0

Share this post


Link to post
Share on other sites
All right. The ambient-cube makes sense, although it still doesn't prevent light leaking from walls/objects that have the same axis:
| || |
| || |
Let's say we have 2 parallel corridors, and the octree-cells are so big that they overlap both corridors after some distance. The most right wall will contribute GI to the most left wall as well. Maybe that scenario doesn't appear so often, although in my narrow indoor game I'm not so sure about it... But maybe Unreal4 just accepts and swallows this problem.

As for the octree traversing, I read somewhere they store it in "linear memory". Do they mean something like a Vertex Buffer or (OpenGL) "Unified Buffer Object" with that? So much terminology!
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0