hakanai / EACSkyboxShader

Panoramic skybox shader for Unity, suitable for playing YouTube videos which are laid out as equi-angular cubemap.
Do What The F*ck You Want To Public License
27 stars 3 forks source link

Support 2D EAC #1

Open eemasal opened 6 years ago

eemasal commented 6 years ago

How can we modify it to support 2D EAC projection??

hakanai commented 6 years ago

Good question. You'd have to look at how it's packed, and maybe either scale by 2 or rotate the whole thing, depending on the layout.

adrianoperez commented 6 years ago

Hi, very good work. I have a question, I can not see it in stereoscopic in virtual reality, the shader does not have 3D LAYOUT options. Any ideas to incorporate it? Best

hakanai commented 6 years ago

Sounds like two different question, but:

  1. I have only ever tested it in stereoscopic VR because VRChat was my sole use case for getting it to work.

  2. It currently only supports side by side layout because that’s the only layout I have seen YouTube use so far and I don’t have samples of any over-under videos yet.

The odds are that if YouTube started using more layouts, the sensible move would be to start using the mesh metadata embedded in the video. In VRChat this would be difficult, but in a straight Unity application it would probably be fairly straightforward so that’s the route I would go.

To do the mesh route in VRChat would require converting the mesh to a texture somehow, I think? Otherwise I can’t think of another way to look it up.

On Wed, 12 Sep 2018 at 18:33, adrianoperez notifications@github.com wrote:

Hi, very good work. I have a question, I can not see it in stereoscopic in virtual reality, the shader does not have 3D LAYOUT options. Any ideas to incorporate it? Best

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/trejkaz/EACSkyboxShader/issues/1#issuecomment-420560922, or mute the thread https://github.com/notifications/unsubscribe-auth/AACo5DheXhjbj-kw0BNniXTxTjKoGRzNks5uaMbtgaJpZM4VspKr .

adrianoperez commented 6 years ago

Hi, I have tried it in virtual reality, and although the video is stereoscopic, in virtual reality it is shown as monoscopic, that is, the same panorama in each eye, it is as if one of the eyes was lost. You can do the test, you can check that it really looks monoscopic. That's why I was asking you about layout 3d. Best

hakanai commented 6 years ago

I'm not sure what the difference between our setups is, but in mine, it's definitely 3D. I originally tested it with a screen with red and blue squares to make absolutely sure.

The line which does it: https://github.com/trejkaz/EACSkyboxShader/blob/master/Assets/EACSkyboxShader/EACPanorama.cginc#L102

adrianoperez commented 6 years ago

Thank you very much for the test, I will do the same as you, a cube of different colors in each eye, I am testing it with samsung gear vr, as soon as I have done the test I tell you. Exactly that line of code makes reference to stereoscopy, it should work for me.

onkelandy commented 4 years ago

Hi! Thanks for the cool work - it works perfectly for 3D content.. but as mentioned it doesn't work with 2D over-under like this one: https://www.youtube.com/watch?v=9KfT6nE19I0

Could you give us a hint what to change exactly? I guess it's all about the Orient and Offset lines but have some problems to figure out how exactly.

Thanks alot!

hakanai commented 4 years ago

If it's over-under I'm just guessing but you might have to do something where you manipulate st.y at the end of the EquiAngularCubemap function to account for which eye the video is for, perhaps using unity_StereoEyeIndex.

yibinfan commented 4 years ago

Hi, Thanks for your work! I am also trying to modify this work to support 2D EAC. Could you please tell me what is the "matrics for orient a [0..+1] square for each side" in lines 21~27 (EACPanorama.cginc) means? I think they define the orientation of each square(side) but didn't figure out what exactly are the elements in the matrics? Thank you!

hakanai commented 4 years ago

Those are rotation matrices to orient the square correctly for each face.

yibinfan commented 4 years ago

Hi, Thanks for trejkaz's prompt response. I have successfully made it support 2D EAC. I paste the diff between the original EACPanorama.cginc and the modified one below as the reference for the people that also want the 2D support. The basic idea is to reposition and reorientate the 6 faces and scale the faces region by two (0.25->0.5).

 $ diff EACPanorama.org EACPanorama.cginc 
22,27c22,27
< static const float3x3 ORIENT_POS_X = float3x3( 0, -1, 1, -1,  0, 1, 0, 0, 1);
< static const float3x3 ORIENT_NEG_X = float3x3(-1,  0, 1,  0, -1, 1, 0, 0, 1);
< static const float3x3 ORIENT_POS_Y = float3x3( 0,  1, 0,  1,  0, 0, 0, 0, 1);
< static const float3x3 ORIENT_NEG_Y = float3x3( 0, -1, 1,  1,  0, 0, 0, 0, 1);
< static const float3x3 ORIENT_POS_Z = float3x3( 0,  1, 0, -1,  0, 1, 0, 0, 1);
< static const float3x3 ORIENT_NEG_Z = float3x3( 0, -1, 1, -1,  0, 1, 0, 0, 1);
---
> static const float3x3 ORIENT_POS_X = float3x3( 0, 1, 0, 1,  0, 0, 0, 0, 1);
> static const float3x3 ORIENT_NEG_X = float3x3(-1, 0, 1, 0, -1, 1, 0, 0, 1);
> static const float3x3 ORIENT_POS_Y = float3x3(-1, 0, 1, 0,  1, 0, 0, 0, 1);
> static const float3x3 ORIENT_NEG_Y = float3x3(-1, 0, 1, 0, -1, 1, 0, 0, 1);
> static const float3x3 ORIENT_POS_Z = float3x3(-1, 0, 1, 0, -1, 1, 0, 0, 1);
> static const float3x3 ORIENT_NEG_Z = float3x3(-1, 0, 1, 0,  1, 0, 0, 0, 1);
30,35c30,35
< static const float2 OFFSET_POS_X = float2(0.0,  0.33333333);
< static const float2 OFFSET_NEG_X = float2(0.25, 0.33333333);
< static const float2 OFFSET_POS_Y = float2(0.25, 0.66666666);
< static const float2 OFFSET_NEG_Y = float2(0.25, 0.0       );
< static const float2 OFFSET_POS_Z = float2(0.0,  0.0       );
< static const float2 OFFSET_NEG_Z = float2(0.0,  0.66666666);
---
> static const float2 OFFSET_POS_X = float2(0.33333333,  0.0);
> static const float2 OFFSET_NEG_X = float2(0.33333333,  0.5);
> static const float2 OFFSET_POS_Y = float2(0.66666666,  0.0);
> static const float2 OFFSET_NEG_Y = float2(0.0,         0.0);
> static const float2 OFFSET_POS_Z = float2(0.66666666,  0.5);
> static const float2 OFFSET_NEG_Z = float2(0.0,         0.5);
87c87
<     tc = mul(float2x2(0.25, 0, 0, 0.33333333), tc);
---
>   tc = mul(float2x2(0.33333333, 0, 0, 0.5), tc);
93c93
<     tc = clamp(tc, edgeSize, float2(0.25, 0.33333333) - edgeSize);
---
>   tc = clamp(tc, edgeSize, float2(0.33333333, 0.5) - edgeSize);
102c102
< #if UNITY_SINGLE_PASS_STEREO
---
> //#if UNITY_SINGLE_PASS_STEREO
104,105c104,105
<     tc.x += 0.5 * unity_StereoEyeIndex;
< #endif
---
> //    tc.x += 0.5 * unity_StereoEyeIndex;
> //#endif

However, I haven't solved the minor alignment issue mentioned in the README yet...

hakanai commented 4 years ago

The alignment issue I even get on the official player so I'm convinced that the video has the issue.

That said, the absolute correct way to render these is completely different to what we're doing here. They store mesh data into the video metadata now.