Page MenuHome

Cycles: Experiment with using Lambert cylindrical equal-area projection
AcceptedPublic

Authored by Sergey Sharybin (sergey) on Mar 23 2016, 11:01 PM.

Details

Summary

This commit implements new panorama and environment texture projection
which is called after a dude named Lambert:

https://en.wikipedia.org/wiki/Lambert_cylindrical_equal-area_projection

Advantage of this projection is that it doesn't waste sampling time next
to the poles (which is a huge issue for the equirectangular projection).

Disadvantage of this model is that there'll be some distortion on the
poles when mapping it back to the sphere.

This is partially worked around by using scaling magic so there'll be
a bit more samples added on the top/bottom of the image (which makes it
technically a Roosendaal-Sharybin mapping since that's what we've been
discussing in the studio).

Maybe we should be more aggressive here with clamping of the sine, but
let's start doing some real-world tests first.

Diff Detail

Repository
rB Blender
Branch
cycles_panorama_lambert

Event Timeline

Sergey Sharybin (sergey) retitled this revision from to Cycles: Experiment with using Lambert cylindrical equal-area projection.
Sergey Sharybin (sergey) updated this object.

For those who wants to play with clamping:

1diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h
2index a3a22fe..8c633a4 100644
3--- a/intern/cycles/kernel/kernel_projection.h
4+++ b/intern/cycles/kernel/kernel_projection.h
5@@ -86,8 +86,9 @@ ccl_device float3 equirectangular_to_direction(float u, float v)
6
7 /* Lambert coordinates <-> Cartesian direction */
8
9-#define LAMBERT_CLAMP (1.0f - 0.01f)
10-#define LAMBERT_SCALE (1.0990301169315693f)
11+#define LAMBERT_DELTA 0.05f
12+#define LAMBERT_CLAMP (1.0f - LAMBERT_DELTA)
13+#define LAMBERT_SCALE ((M_PI_2_F) / asinf(LAMBERT_CLAMP))
14
15 ccl_device_inline float lambert_asinf_clamped(float x)
16 {

Just modify LAMBERT_DELTA and all dependent values will be updated automatically.

And here's some comparison.

Equirectangular:

Lambert:

Is there any known way to consume these... ?

While this implementation seems good I am wondering if it might not be better to also create a real case where these maps are consumed.

Is there any known way to consume these... ?
While this implementation seems good I am wondering if it might not be better to also create a real case where these maps are consumed.

That's what I am wondering as well. I mean, even though it might be saving samples, you would be locked out from pretty much everything that uses equirectangular mapping - which is pretty much everyone, like for example Youtube.
On the other hand, might be cool to create a new standard. :)
Also, it should be pretty easy to convert that mapping back to standard equirectangular after rendering. (Though that is true for cubemaps as well)

Martijn Berger (juicyfruit) edited edge metadata.

Well the implementation is good.

This revision is now accepted and ready to land.Mar 24 2016, 10:33 AM

@Sebastian Koenig (sebastian_k), you can easily re-amp it back to equirectangular, that's not an issue. Issue is that we'll need to deal with the distortion somehow. Additionally, we can do trickery like rendering in Lambert (or some other non-linear projection) projection and then re-scale it back to equirectangular as a matter of render time saver.

Not saying it's something ultimate to do, but still interesting to investigate possibilities.

The practical application of this is also a bit unclear to me, if you want to render to another format to save render time then rendering to a cube map seems better to me, lower distortion and more standard. Sampling from cube maps is somewhat complicated though, requiring filtering across boundaries.

Sure cubemap has better samples distirbution in terms of pixels. But that would need to be implemented as somewhat core feature of Cycles (or at least Blender). Surely it's doable and perhaps we should test that.