# Realtime Dynamic GI + Reflections + AO + Emissive - AHR

**URL:** <https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923>\
**Category:** Game Development\
**Tags:** unreal-engine\
**Created:** [September 24, 2014, 1:58am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923 "2014-09-24T01:58:17Z")\
**Posts on this page:** 20\
**Page:** 34

<div class="post-metadata">

**Author:** ![RyanTorant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanTorant](https://forums.unrealengine.com/u/RyanTorant)\
**Post date:** [June 24, 2015, 12:27am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/672 "2015-06-24T00:27:02Z")

</div>

> [@diegor;316765](#):
>
> Thanks, now i know wat prt really is, thankfully i havent talked about that yet in other forums, so now there is more research for me, alsot i think that i have heard of similar tecnique in one of the many square enix papers about path tracing using rasterization.  
> Lets hope that in the end using that ‘’ interpolation’’ is a viable option for other things such as direct lightning.
> 
> EDIT:I had an idea that is probably going to work , but could slow down the rendering instead of improving it , maybe the ‘’ interpolation’’ can be emulated by apliying an inverted fresnel for each ligh (or lights that come from the same direction if its posible ) using the light vector as the camera vector input and the low resolution direct shading of each light as their respective power inputs , but just taking into acount the normal map and not the object normal
> 
> all can be done using Fresnel Vector Ops for prototyping and if really turns out to be worth the effort im going to TRY to implement it direcly as a shader to speed things up (im am by no means a seasoned gneral programer , and i know far less about programing in HLSL), but because is not a general discusion forum i am going to start my own thread when i have actually done it.)

Hmm, that sounds interesting, will give it some thought

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_ec6c193e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_ec6c193e](https://forums.unrealengine.com/u/anonymous_user_ec6c193e)\
**Post date:** [June 24, 2015, 1:06am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/673 "2015-06-24T01:06:17Z")

</div>

> [@;317466](#):
>
> I really don’t see why it should be so much faster. Sure, you take less samples, but the access pattern is awful for GPUs. Take for example what I talked earlier, when I tested trilinear interpolation. Doing “naive” raymarching, even while doing more samples, ended up equal or faster than the more complex version with a buffered binary grid.  
> While it looks good on paper, doing a sparse trace is not that good on reality. For example, consider when you hit a lower res cascade, but the ray doesn’t really hit the higher res voxels inside. You’ll have to keep a stack to go up when you don’t have a hit. It is more complex.  
> As usual, only way to know for sure is to implement it and see, and luckily epic is already working on DFGI. Also, distance field have some limitations on the geometry and use quite a good deal of memory, so it’s nice to have different techniques for different projects.

You have a good point. I always assumed the reason that sparse voxel octrees gave bad performance was because the data structure itself is so non-contiguous, not because of the octree traversal algorithm itself. Like you said, the only to know for sure is to implement it and see. But I can say for sure that using distance fields will not have the same problem as it avoids the octree traversal altogether.

Another way to accelerate the raymarching would be to use a cascaded voxel representation and read from lower-resolution cascades as the rays get further apart, like I mentioned above (obviously, it would be for diffuse and blurry specular only). That way you could increase the ray step size as the rays get further away, but you avoid the octree traversal altogether. I’m quite certain that would give a speedup. If you aren’t sold, though, then I’d be willing take a crack at it, after you implement cascades. It should just be a matter of changing the shader code, which I’m quite good at (messing with the internals of UE4, not so much ;)).

---

<div class="post-metadata">

**Author:** ![RyanTorant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanTorant](https://forums.unrealengine.com/u/RyanTorant)\
**Post date:** [June 24, 2015, 1:31am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/674 "2015-06-24T01:31:44Z")

</div>

> [@krstefan42;317481](#):
>
> You have a good point. I always assumed the reason that sparse voxel octrees gave bad performance was because the data structure itself is so non-contiguous, not because of the octree traversal algorithm itself. Like you said, the only to know for sure is to implement it and see. But I can say for sure that using distance fields will not have the same problem as it avoids the octree traversal altogether.
> 
> Another way to accelerate the raymarching would be to use a cascaded voxel representation and read from lower-resolution cascades as the rays get further apart, like I mentioned above (obviously, it would be for diffuse and blurry specular only). That way you could increase the ray step size as the rays get further away, but you avoid the octree traversal altogether. I’m quite certain that would give a speedup. If you aren’t sold, though, then I’d be willing take a crack at it, after you implement cascades. It should just be a matter of changing the shader code, which I’m quite good at (messing with the internals of UE4, not so much ;)).

Voxel cascades will have the stack problem though. Oh, wait, unless you mean using a lower res as you get away from the starting point. I’m in the middle of a change on the way I store the voxels, will use 3d textures, and that will surely make it easier to implement cascades. Will keep you updated. I do do trace against a packed binary voxels grid, so I need to sample less, but that have some implementation issues. Now ill move that binary grid to a r8\_uint 3d Tex where I pack 8 voxels, so that it’s effectively at half res for the trace, but full res when sampling.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_ec6c193e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_ec6c193e](https://forums.unrealengine.com/u/anonymous_user_ec6c193e)\
**Post date:** [June 24, 2015, 2:56am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/675 "2015-06-24T02:56:38Z")

</div>

> [@;317498](#):
>
> Voxel cascades will have the stack problem though. Oh, wait, unless you mean using a lower res as you get away from the starting point.

Yep, that’s exactly what I mean.

The obvious approach would be to choose the LOD where the texel size most closely matches the current “cone size” (if we pretend for a second that the rays are closely packed cones). But that wouldn’t work well, because features will need to be thickened in the coarser LOD’s (otherwise thin walls will disappear), and therefore small gaps like windows would close up. could be solved by subtracting a constant from the LOD level and clamping to 0. way the “closing up” would still happen, but it would only happen at distances far enough away from the starting point that it won’t matter

---

<div class="post-metadata">

**Author:** ![diegor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@diegor](https://forums.unrealengine.com/u/diegor)\
**Post date:** [June 24, 2015, 3:32am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/676 "2015-06-24T03:32:52Z")

</div>

another trick to avoid tracing over large distances is recycling nearby raytraces that go in a similar diection as the current one an storing them in a buffer , so each voxel or pixel needs a dedicated trace of a very short distance a la tomorrow children , but i think you have already implemented it and because of that you think that using distance fields is not worth being implemented?

---

<div class="post-metadata">

**Author:** ![RyanTorant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanTorant](https://forums.unrealengine.com/u/RyanTorant)\
**Post date:** [June 24, 2015, 11:54am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/677 "2015-06-24T11:54:27Z")

</div>

> [@krstefan42;317521](#):
>
> Yep, that’s exactly what I mean.
> 
> The obvious approach would be to choose the LOD where the texel size most closely matches the current “cone size” (if we pretend for a second that the rays are closely packed cones). But that wouldn’t work well, because features will need to be thickened in the coarser LOD’s (otherwise thin walls will disappear), and therefore small gaps like windows would close up. could be solved by subtracting a constant from the LOD level and clamping to 0. way the “closing up” would still happen, but it would only happen at distances far enough away from the starting point that it won’t matter

Sounds like a plan! Will tell you when I’ve finished converting to 3d textures and we can try that.

> [@diegor;317531](#):
>
> another trick to avoid tracing over large distances is recycling nearby raytraces that go in a similar diection as the current one an storing them in a buffer , so each voxel or pixel needs a dedicated trace of a very short distance a la tomorrow children , but i think you have already implemented it and because of that you think that using distance fields is not worth being implemented?

Recycling prev rays for pixels that hadn’t moved a lot is something i am going to do, been thinking on that for a while.  
About distance fields, epic is already doing a lot of job on that area, so think is better to leave them work with DFGI and similar, like I said before, distance field have their own plus and cons, so it’s cool to have different options to choose.

---

<div class="post-metadata">

**Author:** ![diegor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@diegor](https://forums.unrealengine.com/u/diegor)\
**Post date:** [June 24, 2015, 2:55pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/678 "2015-06-24T14:55:46Z")

</div>

I think that you are confusing resusing traces from previous frame with what i mean

---

<div class="post-metadata">

**Author:** ![RyanTorant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanTorant](https://forums.unrealengine.com/u/RyanTorant)\
**Post date:** [June 24, 2015, 3:16pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/679 "2015-06-24T15:16:39Z")

</div>

> [@diegor;317816](#):
>
> I think that you are confusing resusing traces from previous frame with what i mean

Guess i am :S what did you mean then?

---

<div class="post-metadata">

**Author:** ![diegor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@diegor](https://forums.unrealengine.com/u/diegor)\
**Post date:** [June 25, 2015, 12:04am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/680 "2015-06-25T00:04:30Z")

</div>

I am sorry for not being able to answer earlier , didnt have my computer avaible.

what im talking about is on page 96.

[http://fumufumu.q-games.com/archives/TheTechnologyOfTomorrowsChildrenFinal.pdf](http://fumufumu.q-games.com/archives/TheTechnologyOfTomorrowsChildrenFinal.pdf)

---

<div class="post-metadata">

**Author:** ![RyanTorant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanTorant](https://forums.unrealengine.com/u/RyanTorant)\
**Post date:** [June 25, 2015, 12:50am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/681 "2015-06-25T00:50:11Z")

</div>

> [@diegor;318232](#):
>
> I am sorry for not being able to answer earlier , didnt have my computer avaible.
> 
> what im talking about is on page 96.
> 
> [http://fumufumu.q-games.com/archives/TheTechnologyOfTomorrowsChildrenFinal.pdf](http://fumufumu.q-games.com/archives/TheTechnologyOfTomorrowsChildrenFinal.pdf)

Oh I see. Hmm, maybe, not really sure how to add it to raymarching though, seems like a good fit for conetracing, but strange for rays. Will give it some thought.  
I do need to finish the changes I’m currently doing and evaluate performance to get some up to date numbers, see how fast AHR really is (on million of rays/second)

EDIT: Maybe a buffer on shared memory? Not completely sure, you need to be really careful with stuff, as you might spend a lot of time on a that on paper it reduces the access count, but on the end it’s slower cause the access pattern is worse, or warp divergence, or occupation, or just you realize what you wrote is the same that the cache does. Been there, GPUs can be \*\*\*\*\*\*\* D:  
Will give it some more thought anyway.

---

<div class="post-metadata">

**Author:** ![diegor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@diegor](https://forums.unrealengine.com/u/diegor)\
**Post date:** [June 25, 2015, 1:04am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/682 "2015-06-25T01:04:49Z")

</div>

actually when i first read that part i thought that it was talking about tracing the far part first over number of voxels then trace a “far” for those voxels too ,all the way to your desired ray lenght , instead tc just traces the “far” once per cascade

---

<div class="post-metadata">

**Author:** ![RyanTorant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanTorant](https://forums.unrealengine.com/u/RyanTorant)\
**Post date:** [June 27, 2015, 7:01pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/683 "2015-06-27T19:01:33Z")

</div>

Sorry I’ve been slow with the updates, but have some really interesting stuff on the pipeline. Toying with an idea to spread the tracing over say, 4 frames, so that you get a x4 speedup (as it’s like you are rendering at 1/4 res instead of 1/2 res). You have to take into account how much it has moved, and it has some subelties, but from what little I’ve tested it seems to still look good (a big thanks here to the normal interpolation trick) and run much smoother.  
Will have some more updates later. Also, want to finish the conversion to 3D textures, and test what you guys said a few post back, about using a few lower res mips for the samples that are far away.  
Hope to have some more free time. University is a bi\*\*h right ? D:

---

<div class="post-metadata">

**Author:** ![Denny](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Denny](https://forums.unrealengine.com/u/Denny)\
**Post date:** [June 28, 2015, 10:19am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/684 "2015-06-28T10:19:45Z")

</div>

So _kinda_ like interlacing for old CRT screens but for dynamic GI? Sacrifice a bit of quality for a huge speedup. Why not. 🙂

---

<div class="post-metadata">

**Author:** ![RyanTorant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanTorant](https://forums.unrealengine.com/u/RyanTorant)\
**Post date:** [June 28, 2015, 12:07pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/685 "2015-06-28T12:07:20Z")

</div>

> [@Denny;320297](#):
>
> So _kinda_ like interlacing for old CRT screens but for dynamic GI? Sacrifice a bit of quality for a huge speedup. Why not. 🙂

Yeah! Something like that. On the worst case, when the image moves a lot, it’ll be like rendering at 1/4 res but a) you are moving fast, so you don’t see much detail, and b) the normal interpolation trick fills in the gaps nicely.

---

<div class="post-metadata">

**Author:** ![Denny](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Denny](https://forums.unrealengine.com/u/Denny)\
**Post date:** [June 28, 2015, 5:02pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/686 "2015-06-28T17:02:44Z")

</div>

I bet is one of those scenarios where people will only be able to notice the difference in either a screenshot or if they are told to look for the errors. You know, like [video / study](https://www.youtube.com/watch?v=vJG698U2Mvo). Ah the limits of the human mind, easily open to be tampered with. 😉

---

<div class="post-metadata">

**Author:** ![RyanTorant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanTorant](https://forums.unrealengine.com/u/RyanTorant)\
**Post date:** [July 3, 2015, 2:04am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/687 "2015-07-03T02:04:41Z")

</div>

Still alive here ;D  
2 exams down, 3 more to go. Will have more news after the 10th

---

<div class="post-metadata">

**Author:** ![\_cDub](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@\_cDub](https://forums.unrealengine.com/u/_cDub)\
**Post date:** [July 3, 2015, 5:00am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/688 "2015-07-03T05:00:56Z")

</div>

I see a lot here about GI, but what exactly is it doing for reflctions and emissive materials?

---

<div class="post-metadata">

**Author:** ![cadviz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@cadviz](https://forums.unrealengine.com/u/cadviz)\
**Post date:** [July 3, 2015, 7:05am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/689 "2015-07-03T07:05:11Z")

</div>

Hi everybody;  
The \*\*AHR \*\*had been released on the 14 of April 2015… Today is 03 of July 2015…  
For about 75 days… all What I saw was discussion without implementing accept 2 OR 3 tries (if I’m not mistaken)…  
Seems to me most of us has no time and are busy with examinations…!!  
Best wishes for all…🆒

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_fd738307](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_fd738307](https://forums.unrealengine.com/u/anonymous_user_fd738307)\
**Post date:** [July 3, 2015, 9:00am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/690 "2015-07-03T09:00:51Z")

</div>

> [@cadviz;323639](#):
>
> Hi everybody;  
> The \*\*AHR \*\*had been released on the 14 of April 2015… Today is 03 of July 2015…  
> For about 75 days… all What I saw was discussion without implementing accept 2 OR 3 tries (if I’m not mistaken)…  
> Seems to me most of us has no time and are busy with examinations…!!  
> Best wishes for all…🆒

@Cadviz, please explain yourself using clearer language, I can’t tell if you’re discontent with the situation or you’re just stating facts.

In any case, being an open source project, everyone who is able to complain could also be able to modify the source to fit his needs… Or at least use that time to start learning c++.  
is doing work for free so I don’t think anyone has any room to complain, so let’s keep the discussion on the positive side, shall we?  
Just my 2c.

---

<div class="post-metadata">

**Author:** ![RyanTorant](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanTorant](https://forums.unrealengine.com/u/RyanTorant)\
**Post date:** [July 3, 2015, 12:12pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/691 "2015-07-03T12:12:32Z")

</div>

> [@\_cDub;323600](#):
>
> I see a lot here about GI, but what exactly is it doing for reflctions and emissive materials?

Emissive objects illuminate the scene, just like a light(but don’t cast GI for now), and for reflections it allows you to have dynamic reflections for on screen and off screen objects (but just the ones that either emit light, or are hit by direct light

[Previous page](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923.md?page=33)

[Next page](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923.md?page=35)
