Sign in to follow this  
gchewood

Lots of reflections- how?

Recommended Posts

gchewood    236
A rather vague question about reflections. I hope someone can enlighten me.

I've got no problems with simple mirrors and reflecting water etc but how do you go about creating an environment with lots of reflections (I'm working in XNA)?

I'm thinking of games like Mass Effect 2/3 where nearly every other surface reflects its environment. It seems clear that not ever reflection can be calculated each frame so I'm assuming some kind of pre-calculated approach like environment mapping with cubemaps. Hope someone can fill me in.

Thanks Edited by gchewood

Share this post


Link to post
Share on other sites
Quat    568
I would guess they place cube maps around the scene to do reflections. There is also a screen space reflection technique I heard crytek uses, but it is not very accurate and can get problems, so I don't like it too much.

Share this post


Link to post
Share on other sites
MJP    19754
Yeah the common approach is to place reflection probes in the scene, and then pre-render environment maps at the probe locations. When you do this you can also filter the mip levels such that they somewhat match the specular response for different roughness values (specular powers).

Share this post


Link to post
Share on other sites
InvalidPointer    1842
What MJP said. I can personally confirm ME2/3 both use regular boring cubemaps, but BioWare's art department did a pretty good job hiding this by way of careful region selection. I can't think of any glaring examples where the infinite projection was obvious.

If you want to slap them over things more aggressively, techniques like [url="http://seblagarde.wordpress.com/2012/08/11/siggraph-2012-talk/"]parallax-corrected cubemaps[/url] and other enhanced-projection approaches work really, really well for a large percentage of scenes. They typically aren't much more expensive than the traditional stuff but for mostly-planar surfaces you can get results approaching stencil-masked mirrors.

Share this post


Link to post
Share on other sites
gchewood    236
[quote name='TheChubu' timestamp='1350365229' post='4990630']
The even more common approach is not to do reflections at all [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]
[/quote]

Erm, yeah.....thanks. Very helpful.

[quote name='MJP' timestamp='1350323414' post='4990451']
Yeah the common approach is to place reflection probes in the scene, and then pre-render environment maps at the probe locations. When you do this you can also filter the mip levels such that they somewhat match the specular response for different roughness values (specular powers).
[/quote]

Well I'm glad I was on the right lines. Is it best to do this programmatically in the engine (and if so, does anyone have the algorithm?) or in something like 3ds max?

Share this post


Link to post
Share on other sites
jeffkingdev    787
[quote]
[quote name='MJP' timestamp='1350323414' post='4990451']
Yeah the common approach is to place reflection probes in the scene, and then pre-render environment maps at the probe locations. When you do this you can also filter the mip levels such that they somewhat match the specular response for different roughness values (specular powers).
[/quote]

Well I'm glad I was on the right lines. Is it best to do this programmatically in the engine (and if so, does anyone have the algorithm?) or in something like 3ds max?
[/quote]

MJP,

In addition to gchewood's question, I would like to add a question regarding the probe locations. Do you then just setup an orthographic view in all directions (ex. straight up, down, left, right, forward, back) to a single cubemap texture?

Thanks,
Jeff.

Share this post


Link to post
Share on other sites
InvalidPointer    1842
[quote name='gchewood' timestamp='1350379284' post='4990662']
[quote name='TheChubu' timestamp='1350365229' post='4990630']
The even more common approach is not to do reflections at all [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]
[/quote]

Erm, yeah.....thanks. Very helpful.

[quote name='MJP' timestamp='1350323414' post='4990451']
Yeah the common approach is to place reflection probes in the scene, and then pre-render environment maps at the probe locations. When you do this you can also filter the mip levels such that they somewhat match the specular response for different roughness values (specular powers).
[/quote]

Well I'm glad I was on the right lines. Is it best to do this programmatically in the engine (and if so, does anyone have the algorithm?) or in something like 3ds max?
[/quote]
The consistency is nice, but you'll likely need to add extra shaders, etc. for things to go smoothly. Rendering programs have the advantage of accuracy and sampling flexibility. If one is a win, go with it.

Re: implementation: Render six views along each of the six major axes with 90-degree horizontal and vertical FOV, save into the appropriate face of a cubemap, done. With MAX you can probably accomplish something similar using render-to-texture and MAXScript though it's not something I've ever attempted.

[quote name='jeffkingdev' timestamp='1350392495' post='4990703']
[quote]
[quote name='MJP' timestamp='1350323414' post='4990451']
Yeah the common approach is to place reflection probes in the scene, and then pre-render environment maps at the probe locations. When you do this you can also filter the mip levels such that they somewhat match the specular response for different roughness values (specular powers).
[/quote]

Well I'm glad I was on the right lines. Is it best to do this programmatically in the engine (and if so, does anyone have the algorithm?) or in something like 3ds max?
[/quote]

MJP,

In addition to gchewood's question, I would like to add a question regarding the probe locations. Do you then just setup an orthographic view in all directions (ex. straight up, down, left, right, forward, back) to a single cubemap texture?

Thanks,
Jeff.
[/quote]
You probably want to be using projection cameras, but I guess ortho could work too. Likely would look a bit weird, but maybe there's some 'artistic effect' floating around in there someplace :)

Share this post


Link to post
Share on other sites
MJP    19754
You'll probably want to capture your probes with the same renderer that you use at runtime. This ensure that you support all of the same shaders/materials/effects/etc. when capturing probes. We do render the probes inside of Maya, using a custom plugin that uses our engine to do the rendering.

To render to a cubemap you'll want use use 6 perspective projections. The easiest way to do it is to line up each cubemap face with a world-space axis, so that you can sample from the probe using a world-space reflection vector. For the projection you'll want to use a FOV of Pi / 2, and an aspect ratio of 1.0.

Share this post


Link to post
Share on other sites
gchewood    236
[quote name='MJP' timestamp='1350454299' post='4991023']
For the projection you'll want to use a FOV of Pi / 2, and an aspect ratio of 1.0.
[/quote]

[quote name='InvalidPointer' timestamp='1350396581' post='4990719']
: Render six views along each of the six major axes with 90-degree horizontal and vertical FOV
[/quote]

Cool, I didn't realise it was that simple. Sounds like the only difficulty lies in dividing up the scenes so the reflections fit nicely. Thanks a lot people, glad to this forum is so reliable.

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