• 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
pachesantiago

Approximate Hybrid Raytracing - Work in Progress

19 posts in this topic

Awesome,

 

Can you say which data structure you used to accelerate the intersection test? I'm struggling  to implement my k-d tree efficient enough to use it dynamically.

2

Share this post


Link to post
Share on other sites

Awesome,

 

Can you say which data structure you used to accelerate the intersection test? I'm struggling  to implement my k-d tree efficient enough to use it dynamically.

I'm sorry, but I don't want to get into implementation details (ph34r.png ) until I know if I'm accepted / rejected to present at SIGGRAPH.

I can say that I don't use acceleration structures per se , it's more like a brute force raytracer. Next month I should know the verdict, and I'll get into details then.
Hope you understand.

0

Share this post


Link to post
Share on other sites

Unfortunately, from my perspective, the only really interesting part of a demo like this is how it's done. Specifically: what makes your approach superior to the innumerable other demos that purport to accomplish the exact same thing :-)

It's also really hard to discuss a graphics demo without knowing the techniques behind it; I can't tell if your grossly over-saturated diffuse interreflection is an artifact of rendering method or just the result of using too much specular gloss on the floors, for instance.

Having worked in realtime GI back in the days before it was actually hardware-practical, I appreciate the work that goes into a project like this, and I'm certainly not trying to denigrate your efforts. In fact it's probably my background in RTGI that makes me overly critical. What I'd personally rather see (besides the stock castle/banner scene) is stuff like material demos where you illustrate how your technique handles various surface types, especially in combination.

One of my favorite test scenes is Cornell Box variants for exactly that reason. It's a standard scene (even though the castle scene is pretty close to de-facto GI demo standard these days) and for someone with a trained eye it makes it immediately effortless to recognize the strengths and tradeoffs of a given rendering method.

I totally understand your point, I know it's hard to talk about something not knowing how it works.
Also, I'm all in for constructive criticism.

Now to the scene related things:
You said you'll like to see different materials, I think I can put together a scene with a bunch of spheres with different reflection amount, gi amount, etc in the next couple hours. Is that what you had in mind?
Regarding the reflections, is mostly the fact I had quite a problem combining the GI , Reflections and Direct Illumination buffers, and making it look good, but is more of an "artistical" problem of sorts wink.png

0

Share this post


Link to post
Share on other sites
Something like that sounds cool, yeah - ideally something that showcases the strengths of your approach as much as you can manage, even if you don't get into any detail on how you pulled it off just yet.

I figured the reflection problem was likely an aesthetic tradeoff. It can be very hard to get multiple layers of GI to play nicely together depending on how you do your rendering, and definitely making them all look good when combined is a real trick.
0

Share this post


Link to post
Share on other sites

Something like that sounds cool, yeah - ideally something that showcases the strengths of your approach as much as you can manage, even if you don't get into any detail on how you pulled it off just yet.

I figured the reflection problem was likely an aesthetic tradeoff. It can be very hard to get multiple layers of GI to play nicely together depending on how you do your rendering, and definitely making them all look good when combined is a real trick.

Great then! I should have that scene ready in a couple hours

0

Share this post


Link to post
Share on other sites

Well, I ran into some unexpected problems, so it took more than I though.
Here are some screens of a dirty simple Cornell Box:

 

I disabled reflections, as I had some problems getting them to look good on that scene. Just GI for now.
The blur needs a lot of work too, but I believe the idea is there.
As you can see by the FPS, my poor GTX 750 Ti is trying it's best, but is not enough.
the 75 W TDP and mainly the 128 bits bus really hurts performance, as this is a bandwidth-bound algorithm. I ran it a couple times on a 7870, and it runs at twice or more framerate ( 256 bit bus ). 

It depends a lot on the scene and the settings, but I cant get 30 FPS with the 750 Ti at the Sponza scene( wich is actually faster, as a lot of rays collide really close to the start position)

EDIT: Does anyone knows how can I put an images album? Or at least the images one by one, nothing seems to work. For now, here goes the link
https://imgur.com/a/T0SJP

Edited by pachesantiago
0

Share this post


Link to post
Share on other sites

Well, I had been working on improving the scene representation, and I managed to increase performance by about 20% - 25% with just a 3 % increase in memory usage and a small increase in the GBuffer stage, but I believe I could tune it up to 30% - 35%. Also now reflections take into account the sky, and I added specular lighting to the GI calculation. 

 

I'm having a problem though, and I wanted to ask you guys. I can't get the blur to work correctly. I'm implementing a Gaussian blur, separated on two passes, with the weights calculated on the fly, as I like to be able to tune the number of samples of the filter. Also, the Gaussian weight is multiplied by 1 / (epsilon + abs(z - depth[sample])) to take into account depth discontinuities. It works, but instead of producing a nice smooth blur, it creates a black cross in the middle. Below is a screen. Rays where reduced to 1 per pixel and strength upped to better display the problem. The blur is using 8 samples and a sigma of 4.3.

 

ywTzM6l.png

 

And here is the code for the horizontal pass. The vertical one is exactly the same, changing float2(1, 0) for float2(0, 1). I read two images, do the horizontal blur to two temp images, do the vertical blur sampling the temp images, and output to the original images.
Texture2D<float> tCoarseDepth : register(t0);
Texture2D<float4> tCoarseNormal : register(t1);
Texture2D<float4> tGI : register(t2);
Texture2D<float4> tRFL : register(t3);

RWTexture2D<float4> output : register(u0);
RWTexture2D<float4> outputRFL : register(u1);

static const float samples = 8;
static const float g_epsilon = 0.0001f;
static const float sigma = 4.3f * 4.3f;

[numthreads(256, 1, 1)]
void BlurH( uint3 DTid : SV_DispatchThreadID )
{
	float z = tCoarseDepth[DTid.xy];

	float4 gi = tGI[DTid.xy];
	float4 rfl = tRFL[DTid.xy];
	float acc = 1;

	float2 spos = float2(1, 0);
	for (float i = 1; i <= samples; i++)
	{
		// Sample right
		//		Calculate weights
		float zWeightR = 1.0f / (g_epsilon + abs(z - tCoarseDepth[DTid.xy + spos*i]));
		float WeightR = zWeightR * GaussianWeight(i, sigma);
		
		//		Sample 
		gi += tGI[DTid.xy + spos*i]* WeightR;
		rfl += tRFL[DTid.xy + spos*i] * WeightR;
		acc += WeightR;
		
		// Sample left
		//		Calculate weights
		float zWeightL = 1.0f / (g_epsilon + abs(z - tCoarseDepth[DTid.xy - spos*i]));
		float WeightL = zWeightL * GaussianWeight(i, sigma);

		//		Sample 
		gi += tGI[DTid.xy - spos*i] * WeightL;
		rfl += tRFL[DTid.xy - spos*i] * WeightL;
		acc += WeightL;
	}
	
	output[DTid.xy] = gi / acc;
	outputRFL[DTid.xy] = rfl / acc;
}

If someone can shed some light, I would be grateful.

There's other thing I want / need to add to my blur shader, and that is to take into account the distance of the pixel, so everything gets the same amount of blur. Right now, things that are too far get too much blur, and things that are to close don't get enough.
I need suggestion on how to do that, I suppose someone here has done it before.

Well, that's it for now, I'll try to keep this thread with some more regular updates, maybe a screen every two or three days.

EDIT: Here's the code for the GaussianWeight function
 

float GaussianWeight(float x,float sigmaSquared)
{
        float alpha = 1.0f / sqrt(2.0f * 3.1416f * sigmaSquared);
	float beta = (x*x) / (2*sigmaSquared);

	return alpha*exp(-beta);
}
Edited by pachesantiago
0

Share this post


Link to post
Share on other sites

Anyone have anything to say about the blur problem? I'm still fighting with that.

I'm also having another problem, and I posted on Stack Overflow about it : http://stackoverflow.com/questions/23189808/interlocked-average-cas-not-working-on-hlsl

I'm trying to remove the flickering of the light by storing it using atomic ops, but I can't get it to work correctly. Here's the code I'm using:

[allow_uav_condition] while (true)
{
    // Get old value
    uint old = irradianceVolume[vpos];

    // Average
    float3 avg = saturate((UnpackR5G5B5A1(old) + irradiance) * 0.5f);
    uint final = PackR5G5B5A1(float4(avg, 1));

    // Try to store
    uint ret = -1;
    InterlockedCompareExchange(irradianceVolume[vpos], old, final, ret);

    if (ret == old)
        break;
}

If anyone can say anything, I would really appreciate it.

0

Share this post


Link to post
Share on other sites

[numthreads(256, 1, 1)]
void BlurH( uint3 DTid : SV_DispatchThreadID )
{
	float z = tCoarseDepth[DTid.xy];

	float4 gi = tGI[DTid.xy];
	float4 rfl = tRFL[DTid.xy];
	float acc = 1;

	float2 spos = float2(1, 0);
	for (float i = 1; i <= samples; i++)
	{
		// Sample right
		//		Calculate weights
		float zWeightR = 1.0f / (g_epsilon + abs(z - tCoarseDepth[DTid.xy + spos*i]));
		float WeightR = zWeightR * GaussianWeight(i, sigma);
		
		//		Sample 
		gi += tGI[DTid.xy + spos*i]* WeightR;
		rfl += tRFL[DTid.xy + spos*i] * WeightR;
		acc += WeightR;
		
		// Sample left
		//		Calculate weights
		float zWeightL = 1.0f / (g_epsilon + abs(z - tCoarseDepth[DTid.xy - spos*i]));
		float WeightL = zWeightL * GaussianWeight(i, sigma);

		//		Sample 
		gi += tGI[DTid.xy - spos*i] * WeightL;
		rfl += tRFL[DTid.xy - spos*i] * WeightL;
		acc += WeightL;
	}
	
	output[DTid.xy] = gi / acc;
	outputRFL[DTid.xy] = rfl / acc;
}
float GaussianWeight(float x,float sigmaSquared)
{
        float alpha = 1.0f / sqrt(2.0f * 3.1416f * sigmaSquared);
	float beta = (x*x) / (2*sigmaSquared);

	return alpha*exp(-beta);
}

This is a pretty classic brain fart. You're passing integer sample points [1..samples] to the gaussian function, but the domain of the gaussian is [-inf, +inf]. You should be passing GaussianWeight(i - centre, sigma_sq), where centre is the middle sample. Here centre = (samples+1) / 2 = 4.5. People conventionally use an odd number of samples to get an integer centre. You've also labelled your sigma squared constant as sigma, that was a little confusing.

There's other thing I want / need to add to my blur shader, and that is to take into account the distance of the pixel, so everything gets the same amount of blur. Right now, things that are too far get too much blur, and things that are to close don't get enough.
I need suggestion on how to do that, I suppose someone here has done it before.

This may not work well with a separable blur like this one, it would create anisotropic blur as different size kernels mix together on the second pass.
0

Share this post


Link to post
Share on other sites


This is a pretty classic brain fart. You're passing integer sample points [1..samples] to the gaussian function, but the domain of the gaussian is [-inf, +inf]. You should be passing GaussianWeight(i - centre, sigma_sq), where centre is the middle sample. Here centre = (samples+1) / 2 = 4.5. People conventionally use an odd number of samples to get an integer centre. You've also labelled your sigma squared constant as sigma, that was a little confusing.

Thanks! Tried that, and it works better now. Still, I have some things to fix.
Anyone knows something about the atomic average problem I mentioned earlier? Still struggling with that.

0

Share this post


Link to post
Share on other sites

Just a quick post. I played a bit with raytraced shadows, using AHR. Here are some (preliminary) results:
6SxS9PJ.png

0

Share this post


Link to post
Share on other sites
Today I found out I was rejected to present my technique at SIGGRAPH, so I'm now open to talk about the technique, but I don't know how to continue from here. Should I do a tutorial, some kind of article, a downloadable demo? Maybe try to integrate it with some enigne, like Unity or UDK? Should I make a new post here on GameDev? What are other places where I can make this idea public?
If anyone can provide some suggestions, I would be really glad, as I said, I don't know where to move with this from now on. I'll continue improving it though.
0

Share this post


Link to post
Share on other sites

How big of a presentation are you wanting to make? A journal series is best if you want to talk about processes you went though during development; an article is best if you just want to talk about the technique itself; and if you want to discuss it, this thread should be perfect :-)

0

Share this post


Link to post
Share on other sites

How big of a presentation are you wanting to make? A journal series is best if you want to talk about processes you went though during development; an article is best if you just want to talk about the technique itself; and if you want to discuss it, this thread should be perfect :-)

Ok so I think that for now, I'll keep with this thread, and discuss about it. Ask away!
When I have it more polished, maybe I'll make an article.
Also I plan to try to enter next year GDC. Can't hurt trying, plus according to the SIGGRAPH reviewers, I was really close to make it.
AHR needs, as they pointed out, more polish and also compare it to other techniques.

0

Share this post


Link to post
Share on other sites

Looks pretty good. I'd love to know more about your technique. What's hybrid about it? And what's approximate about it? Have you given an explanation (even in broad terms) anywhere about your process?

0

Share this post


Link to post
Share on other sites

Could you share more details?

A playable demo maybe?

 

Looks really promising.

 

Are you taking in account the G-buffer to compute GI? or just world space data?

What about spreading the work across frames? Or even guess wich areas needs to be updated (based on lighting changes, moving objects, etc) at runtime.

 

Could be really useful for architectural visualization.

 

Keep up the good work!

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