# 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:** 15

<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:** [February 20, 2015, 3:55pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/284 "2015-02-20T15:55:53Z")

</div>

> [@TDoro;225766](#):
>
> is actually interesting, do you have more news to share?

hmm when I said “expect news more often” was talking about once a day or similar … not right now 😉

---

<div class="post-metadata">

**Author:** ![TAN](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TAN](https://forums.unrealengine.com/u/TAN)\
**Post date:** [February 20, 2015, 11:55pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/285 "2015-02-20T23:55:26Z")

</div>

Will be expecting . And thanks for your hard work a always.

---

<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:** [February 22, 2015, 3:38am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/286 "2015-02-22T03:38:51Z")

</div>

> [@TAN\_;226091](#):
>
> Will be expecting . And thanks for your hard work a always.

Thanks for the support, to you and to all the ones that are still waiting.  
I managed to get some free time, and worked on finishing the normal upsampling thing I showed earlier. No screens to show right now, sorry, but things are coming together. Performance is about 6 - 8 ms for the raytracing stage at 1080p right now! Getting solid 60 FPS at 1080p on the sponza scene, voxelizing everything every frame, but not on UE, in my test demo

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_52a14607](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_52a14607](https://forums.unrealengine.com/u/anonymous_user_52a14607)\
**Post date:** [February 22, 2015, 5:24am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/287 "2015-02-22T05:24:16Z")

</div>

Looking forward to it.

I figured out just yesterday (after messing around with my opengl vctgi engine) that to get unlimited bounces, the only thing you would need to do is to add a cone tracing pass which reads from your voxel texture within your voxelization shader, then add that indirect lighting to the direct lighting before it is voxelized. Its as simple as that - only a single voxelization pass is required so no need to duplicate any voxelization code.

---

<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:** [February 22, 2015, 12:34pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/288 "2015-02-22T12:34:40Z")

</div>

> [@;226723](#):
>
> Looking forward to it.
> 
> I figured out just yesterday (after messing around with my opengl vctgi engine) that to get unlimited bounces, the only thing you would need to do is to add a cone tracing pass which reads from your voxel texture within your voxelization shader, then add that indirect lighting to the direct lighting before it is voxelized. Its as simple as that - only a single voxelization pass is required so no need to duplicate any voxelization code.

I worked out something similar. The way my code work I can’t do exactly that, but have the idea on how to do something similar. Thanks for the idea!

---

<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:** [February 22, 2015, 9:15pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/289 "2015-02-22T21:15:19Z")

</div>

Well, solved a major bug that was breaking my build, so working now. I still need to do a few changes to the normal upsampling thing i talked before, make it look better and be a bit faster. Will try to have screens ASAP.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_52a14607](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_52a14607](https://forums.unrealengine.com/u/anonymous_user_52a14607)\
**Post date:** [February 22, 2015, 10:49pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/290 "2015-02-22T22:49:12Z")

</div>

> [@;226826](#):
>
> I worked out something similar. The way my code work I can’t do exactly that, but have the idea on how to do something similar. Thanks for the idea!

That’s , I can’t wait for it. You will be one-up against VXGI because they can only do one bounce.

---

<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:** [February 24, 2015, 1:16pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/291 "2015-02-24T13:16:28Z")

</div>

Well, quick update. Found out I have a problem with the way I generate the rays. While I need them to be distributed on an hemisphere oriented by the normal, the code I use to generate them has some directionality, it favors rays in a certain direction, so need to fix that. If someone has any idea, would be helpful. is the current code:

```auto

float3 dir = normal;

float3 step = dir;
		
step.x = rng.GetRandomFloat(0, 1)*2-1;
step.y = rng.GetRandomFloat(0, 1)*2-1;
step.z = rng.GetRandomFloat(0, 1);

float3 rt = 0;
float3 rbt = 0;

FindBestAxisVectors(dir,rt,rbt);

step = normalize(step.x * rbt + (step.y * rt + (step.z * dir)));

```

and

```auto

// From unreal engine 4, modified to compensate for axis change in UE4 (z up instead of y up)
/**
 * Find good arbitrary axis vectors to represent U and V axes of a plane,
 * given just the normal. Ported from UnMath.h
 */
void FindBestAxisVectors(float3 In, out float3 Axis1, out float3 Axis2 )
{
        In.xyz = In.xzy;
	const float3 N = abs(In);

	// Find best basis vectors.
	if( N.z > N.x && N.z > N.y )
	{
		Axis1 = float3(1, 0, 0);
	}
	else
	{
		Axis1 = float3(0, 0, 1);
	}

	Axis1 = normalize(Axis1 - In * (Axis1, In));
	Axis2 = cross(Axis1, In);

        Axis1.xyz = Axis1.xzy;
        Axis2.xyz = Axis2.xzy;
}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_52a14607](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_52a14607](https://forums.unrealengine.com/u/anonymous_user_52a14607)\
**Post date:** [February 24, 2015, 2:55pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/292 "2015-02-24T14:55:27Z")

</div>

> [@;228166](#):
>
> Well, quick update. Found out I have a problem with the way I generate the rays. While I need them to be distributed on an hemisphere oriented by the normal, the code I use to generate them has some directionality, it favors rays in a certain direction, so need to fix that. If someone has any idea, would be helpful. is the current code:
> 
> ```auto
> 
> float3 dir = normal;
> 
> float3 step = dir;
> 		
> step.x = rng.GetRandomFloat(0, 1)*2-1;
> step.y = rng.GetRandomFloat(0, 1)*2-1;
> step.z = rng.GetRandomFloat(0, 1);
> 
> float3 rt = 0;
> float3 rbt = 0;
> 
> FindBestAxisVectors(dir,rt,rbt);
> 
> step = normalize(step.x * rbt + (step.y * rt + (step.z * dir)));
> 
> ```
> 
> and
> 
> ```auto
> 
> // From unreal engine 4, modified to compensate for axis change in UE4 (z up instead of y up)
> /**
> * Find good arbitrary axis vectors to represent U and V axes of a plane,
> * given just the normal. Ported from UnMath.h
> */
> void FindBestAxisVectors(float3 In, out float3 Axis1, out float3 Axis2 )
> {
> In.xyz = In.xzy;
> const float3 N = abs(In);
> 
> // Find best basis vectors.
> if( N.z > N.x && N.z > N.y )
> {
> Axis1 = float3(1, 0, 0);
> }
> else
> {
> Axis1 = float3(0, 0, 1);
> }
> 
> Axis1 = normalize(Axis1 - In * (Axis1, In));
> Axis2 = cross(Axis1, In);
> 
> Axis1.xyz = Axis1.xzy;
> Axis2.xyz = Axis2.xzy;
> }
> 
> ```

Are you talking about the cones? because I manually specify which direction mine go - is with 5 cones for diffuse (which is sufficient for quality).

```auto

	iDiffuse += coneTrace(voxPos.xyz, bumpN, iConeRatio, iMaxDist);
	iDiffuse += 0.707*coneTrace(voxPos.xyz, tangent, iConeRatio, iMaxDist);
	iDiffuse += 0.707*coneTrace(voxPos.xyz, binorm, iConeRatio, iMaxDist);
	iDiffuse += 0.707*coneTrace(voxPos.xyz, ntangent, iConeRatio, iMaxDist);
	iDiffuse += 0.707*coneTrace(voxPos.xyz, nbinorm, iConeRatio, iMaxDist);

```

---

<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:** [February 24, 2015, 3:19pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/293 "2015-02-24T15:19:36Z")

</div>

> [@;228218](#):
>
> Are you talking about the cones? because I manually specify which direction mine go - is with 5 cones for diffuse (which is sufficient for quality).
> 
> ```auto
> 
> iDiffuse += coneTrace(voxPos.xyz, bumpN, iConeRatio, iMaxDist);
> iDiffuse += 0.707*coneTrace(voxPos.xyz, tangent, iConeRatio, iMaxDist);
> iDiffuse += 0.707*coneTrace(voxPos.xyz, binorm, iConeRatio, iMaxDist);
> iDiffuse += 0.707*coneTrace(voxPos.xyz, ntangent, iConeRatio, iMaxDist);
> iDiffuse += 0.707*coneTrace(voxPos.xyz, nbinorm, iConeRatio, iMaxDist);
> 
> ```

No, i’m talking about rays, need to generate random rays in the hemisphere aligned with the normal, to compute illumination for the pixel

---

<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:** [February 24, 2015, 10:48pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/294 "2015-02-24T22:48:37Z")

</div>

Well, that still needs to be fixed, but think I’m close. Now that Epic released 4.7, i’ll get into updating to 4.7, fixing the bugs that could/would appear, and then make the branch public, cause if I keep trying to polish it the “beta” would end up being the final release. If everything goes according to the plan, i’ll have the beta up weekend. Bare in mind that it will be a BETA, so there will be things to fix, no reflections and no multiple bounces. Just don’t want to make people wait more.

---

<div class="post-metadata">

**Author:** ![TAN](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TAN](https://forums.unrealengine.com/u/TAN)\
**Post date:** [February 26, 2015, 1:09am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/295 "2015-02-26T01:09:12Z")

</div>

Saluting the beta with gunshots ! 😃

 ![Amigo girls.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/7/2/722fab5607e6fd5dfe024f4e373d585b2ffc143e.jpeg)

I’Ll try the hell out of hell and will try to give back nice feedback. Hope to see that becoming a real game-changer soon.

---

<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:** [February 26, 2015, 1:13am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/296 "2015-02-26T01:13:21Z")

</div>

> [@TAN\_;229681](#):
>
> Saluting the beta with gunshots ! 😃
> 
> ![Amigo girls.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/7/2/722fab5607e6fd5dfe024f4e373d585b2ffc143e.jpeg)
> 
> I’Ll try the hell out of hell and will try to give back nice feedback. Hope to see that becoming a real game-changer soon.

Thanks man! weekend might have been too optimistic, but will be at most out next weekend.

---

<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:** [March 1, 2015, 10:02pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/297 "2015-03-01T22:02:12Z")

</div>

Well, sorry for the lack of updates, been working a project for a guy from the forums. Started the update to 4.7  
Was quite seamless, but they changed a bit the rendering code so need to make some modifications. Luckily nothing big. The project i mentioned is taking a good share of my time, and college starts over tomorrow, but I will still find some spare time and work on . Want to make it public ASAP

---

<div class="post-metadata">

**Author:** ![Keiyentai](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Keiyentai](https://forums.unrealengine.com/u/Keiyentai)\
**Post date:** [March 1, 2015, 10:56pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/298 "2015-03-01T22:56:32Z")

</div>

man can’t wait to see that updates with 4.7 and the progress. Also possible beta is sounding. I am liking the rendering in 4.7 seems they have tweaked it a lot and I am happy about that.

---

<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:** [March 1, 2015, 11:12pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/299 "2015-03-01T23:12:29Z")

</div>

> [@Keiyentai;232958](#):
>
> man can’t wait to see that updates with 4.7 and the progress. Also possible beta is sounding. I am liking the rendering in 4.7 seems they have tweaked it a lot and I am happy about that.

Possible not, I’m gonna do it! (Eventually… 😉 )

---

<div class="post-metadata">

**Author:** ![Keiyentai](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Keiyentai](https://forums.unrealengine.com/u/Keiyentai)\
**Post date:** [March 1, 2015, 11:17pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/300 "2015-03-01T23:17:58Z")

</div>

Hahah . Sorry I just noticed my sentence was a bit off. I am still waking up and have a zillion things going on in my mind right now lol. Don’t mind me! 😃

---

<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:** [March 1, 2015, 11:32pm UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/301 "2015-03-01T23:32:04Z")

</div>

> [@Keiyentai;232966](#):
>
> Hahah . Sorry I just noticed my sentence was a bit off. I am still waking up and have a zillion things going on in my mind right now lol. Don’t mind me! 😃

Haha no problem, know that feeling bro 😉

---

<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:** [March 5, 2015, 2:42am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/302 "2015-03-05T02:42:30Z")

</div>

Sorry for delaying . I’m really sorry, but the job I took has been longer that I expect. Trying to finish it asap though. After that, I should have the time to make all public. Once again, sorry for the delays

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_52a14607](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_52a14607](https://forums.unrealengine.com/u/anonymous_user_52a14607)\
**Post date:** [March 8, 2015, 3:08am UTC](https://forums.unrealengine.com/t/realtime-dynamic-gi-reflections-ao-emissive-ahr/11923/303 "2015-03-08T03:08:10Z")

</div>

Hey , any updates?

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

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