Semi working
Signed-off-by: fly <merspieler@airmail.cc>
This commit is contained in:
parent
5fd1f4a267
commit
628f8215df
3 changed files with 66 additions and 10 deletions
|
@ -6,8 +6,8 @@
|
|||
<buffer>
|
||||
<name>color</name>
|
||||
<type>cubemap</type>
|
||||
<width>1024</width>
|
||||
<height>1024</height>
|
||||
<width>2048</width>
|
||||
<height>2048</height>
|
||||
<format>rgba8</format>
|
||||
</buffer>
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
|||
<attachment>
|
||||
<buffer>color</buffer>
|
||||
<component>color0</component>
|
||||
<face>2</face>
|
||||
<face>0</face>
|
||||
</attachment>
|
||||
</pass>
|
||||
<!--top-->
|
||||
|
@ -30,7 +30,7 @@
|
|||
<attachment>
|
||||
<buffer>color</buffer>
|
||||
<component>color0</component>
|
||||
<face>3</face>
|
||||
<face>1</face>
|
||||
</attachment>
|
||||
</pass>
|
||||
<!--right-->
|
||||
|
@ -41,7 +41,7 @@
|
|||
<attachment>
|
||||
<buffer>color</buffer>
|
||||
<component>color0</component>
|
||||
<face>4</face>
|
||||
<face>2</face>
|
||||
</attachment>
|
||||
</pass>
|
||||
<!--left-->
|
||||
|
@ -52,7 +52,7 @@
|
|||
<attachment>
|
||||
<buffer>color</buffer>
|
||||
<component>color0</component>
|
||||
<face>5</face>
|
||||
<face>3</face>
|
||||
</attachment>
|
||||
</pass>
|
||||
<!--front-->
|
||||
|
@ -63,7 +63,7 @@
|
|||
<attachment>
|
||||
<buffer>color</buffer>
|
||||
<component>color0</component>
|
||||
<face>0</face>
|
||||
<face>4</face>
|
||||
</attachment>
|
||||
</pass>
|
||||
<!--back-->
|
||||
|
@ -74,7 +74,7 @@
|
|||
<attachment>
|
||||
<buffer>color</buffer>
|
||||
<component>color0</component>
|
||||
<face>1</face>
|
||||
<face>5</face>
|
||||
</attachment>
|
||||
</pass>
|
||||
|
||||
|
|
|
@ -5,7 +5,11 @@
|
|||
<hfov><use>/sim/current-view/field-of-view</use></hfov>
|
||||
<vfov>180</vfov><!-- TODO add parameter -->
|
||||
<auto_vfov>1</auto_vfov><!-- TODO add parameter -->
|
||||
<enable_overlay>0</enable_overlay><!-- TODO add parameter -->
|
||||
<enable_overlay>1</enable_overlay>
|
||||
<!--enable_overlay><use>/surround/enable-overlay</use></enable_overlay-->
|
||||
<rot_x><use>/sim/current-view/raw-orientation[0]</use></rot_x>
|
||||
<rot_y><use>/sim/current-view/raw-orientation[1]</use></rot_y>
|
||||
<rot_z><use>/sim/current-view/raw-orientation[2]</use></rot_z>
|
||||
<display_xsize>
|
||||
<use>/sim/startup/xsize</use>
|
||||
</display_xsize>
|
||||
|
@ -61,6 +65,21 @@
|
|||
<type>sampler-cube</type>
|
||||
<value>2</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>i_rot_x</name>
|
||||
<type>float</type>
|
||||
<value><use>rot_x</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>i_rot_y</name>
|
||||
<type>float</type>
|
||||
<value><use>rot_y</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>i_rot_z</name>
|
||||
<type>float</type>
|
||||
<value><use>rot_z</use></value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
</PropertyList>
|
||||
|
|
|
@ -7,6 +7,33 @@ uniform vec2 fg_ViewportSize;
|
|||
uniform samplerCube iChannel0;
|
||||
uniform int display_x;
|
||||
uniform int display_y;
|
||||
uniform float i_rot_x;
|
||||
uniform float i_rot_y;
|
||||
uniform float i_rot_z;
|
||||
|
||||
vec3 rot3d( vec3 p, vec3 v, float a_rad )
|
||||
{
|
||||
float c = cos( a_rad );
|
||||
float s = sin( a_rad );
|
||||
float t = 1.0 - c;
|
||||
|
||||
vec3 r0, r1, r2;
|
||||
r0[0] = t*v[0]*v[0] + c;
|
||||
r0[1] = t*v[0]*v[1] - s*v[2];
|
||||
r0[2] = t*v[0]*v[2] + s*v[1];
|
||||
|
||||
r1[0] = t*v[0]*v[1] + s*v[2];
|
||||
r1[1] = t*v[1]*v[1] + c;
|
||||
r1[2] = t*v[1]*v[2] - s*v[0];
|
||||
|
||||
r2[0] = t*v[0]*v[2] - s*v[1];
|
||||
r2[1] = t*v[1]*v[2] + s*v[0];
|
||||
r2[2] = t*v[2]*v[2] + c;
|
||||
|
||||
return vec3( dot( r0, p),
|
||||
dot( r1, p),
|
||||
dot( r2, p) );
|
||||
}
|
||||
|
||||
|
||||
void main(void)
|
||||
|
@ -26,10 +53,15 @@ void main(void)
|
|||
// uv.x = gl_FragCoord.x / display_x;
|
||||
// uv.y = gl_FragCoord.y / display_y;
|
||||
vec3 ray = vec3(0.0, 0.0, 0.0);
|
||||
vec3 rayt = vec3(0.0, 0.0, 0.0);
|
||||
|
||||
|
||||
vec2 thetaphi = ((uv * 2.0) - vec2(1.0)) * vec2(3.1415926535897932384626433832795, 1.5707963267948966192313216916398) * (hfov / 360.0);
|
||||
ray = vec3(cos(thetaphi.y) * cos(thetaphi.x), sin(thetaphi.y), cos(thetaphi.y) * sin(thetaphi.x));
|
||||
rayt = rot3d(ray, vec3(1.0, 0.0, 0.0), i_rot_x);
|
||||
rayt = rot3d(rayt, vec3(0.0, 1.0, 0.0), i_rot_y);
|
||||
rayt = rot3d(rayt, vec3(0.0, 0.0, 1.0), i_rot_z);
|
||||
// ray = rot3d(ray, vec3(i_rot_x, i_rot_y, i_rot_z), 0.0);
|
||||
|
||||
vec4 ret = textureCube( iChannel0, ray );
|
||||
if (enable_overlay == 1)
|
||||
|
@ -68,11 +100,16 @@ void main(void)
|
|||
col = vec4(0.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
}
|
||||
col.r = rayt.x;
|
||||
col.g = rayt.y;
|
||||
col.z = rayt.z;
|
||||
ret.r = ret.r / 2.0 + col.r / 2.0;
|
||||
ret.g = ret.g / 2.0 + col.g / 2.0;
|
||||
ret.b = ret.b / 2.0 + col.b / 2.0;
|
||||
}
|
||||
// ret = col;
|
||||
ret.r = (i_rot_x + 1.0) * 0.5;
|
||||
ret.g = 0.0;
|
||||
ret.b = 0.0;
|
||||
ret.a = 1.0;
|
||||
gl_FragColor = ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue