Sign in to follow this  
WhateverMan

Planar reflections on non planar surfaces... help

Recommended Posts

WhateverMan    151

Well I ran into a simple problem, where I'm rendering planar reflections and I need to find a value that probably requires trigonometry.
Why did I not take the trigonometry classes when I was at school...

So my question is how to I calculate the rendering cameras height offset, If I know the cameras angle of rotation and the radius of its orbital movements?

This formula seems to give quite promissing results, angle * sin(radius) but still quite not the same thing, theres some minimal height movement that messes up the visuals pretty baddly if the cameras angle of raotation gets to high.

 

I suspect it'sa simple formula of trigonometry

Any ideas?

 

Oh and this is a planar reflection for non planar surfaces, banked roads for example. It works ok if the camera rotation angle is 0. But as soon as the cameras rotation angle get changed, the camera gets an offset.

 

 

Heres a screen of how the reflections currently work:

[attachment=25438:planar realtime.JPG]

The theory behind this is quite simple. There is a realtime cubemap rendering camera under the scene camera, so it renders the mirrored reflections.

 

Share this post


Link to post
Share on other sites
clb    2147

I am reading two problems here, which to me sounds completely different. The first one is the problem of computing reflections when the surface that produces the reflections is not in a plane, and the second one you mention is that the reflections go wrong if the camera view rotation angle is not zero.

 

The first problem is a hard problem that cannot be solved just by plugging in a trigonometric formula in some appropriate place. This is because if the surface that produces the reflections is not planar but has varying normals in different directions in space, then these normals can scatter the reflected rays in arbitrary directions without much coherency. The only correct way to model that would be to do full raytracing, which is not very feasible on GPUs in the general context.

 

If the surface that does cause the reflections is "mostly planar", it can be successfully approximated by treating it as if it was just a plane, in which case the problem is solvable by rendering the geometry twice, and applying a reflection matrix to generate the reflection. Googling for "reflection matrix" will find results for this. Computing reflections via the reflection matrix equation is able to handle arbitrary camera orientations/rotation angles correctly.

 

When the surface is not very planar, a popular way is to do "screen space reflections" to approximate the reflection. See e.g. https://docs.unrealengine.com/latest/INT/Engine/Rendering/PostProcessEffects/ScreenSpaceReflection/index.html and http://www.gamasutra.com/blogs/BartlomiejWronski/20140129/209609/The_future_of_screenspace_reflections.php for descriptions. I'd probably do this approach if I had to pick one.

 

Other reflection methods involve precomputing cube maps for points in space, or impostors. E.g. https://www.cs.purdue.edu/cgvlab/papers/popescu/popescuGemEG06.pdf , however those can be quite expensive to compute.

Share this post


Link to post
Share on other sites
WhateverMan    151

Thanks for the reply!

As for the method I use, I'm actually rendering a cubemap not a single mirror camera. The cubemap is rendered at the oposite direction of the camera making non planar reflections possible, but they can still only be aplied to planar surface, because the cubemap requires the transforms pivot center. there also is one bug with the reflection normals, but with a material that has roughness it's barely noticable. The only problem I encounter currently is that when the cameras tranform position is changed by position and rotation, the render gets distorted, so I just need to figure out the math to translate the variables correctly.

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