diff options
Diffstat (limited to 'src/render/shaders')
| -rw-r--r-- | src/render/shaders/vr_video.h | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/render/shaders/vr_video.h b/src/render/shaders/vr_video.h index fc2d192..73869eb 100644 --- a/src/render/shaders/vr_video.h +++ b/src/render/shaders/vr_video.h @@ -5,12 +5,11 @@ // YAW: [any float] polar angle, one full revolution is 2*M_PI // PITCH: [any float] vertical tilt, positive is up // ROLL: [any float] view rotation, positive is clockwise -//" const float yaw = M_PI*(-1.0+(mouse_x*2.0));\n" // 360 static const char vr_video_shader[] = \ "//!PARAM mouse_x\n" "//!TYPE float\n" -"//!MINIMUM -0.5\n" -"//!MAXIMUM 1.5\n" +"//!MINIMUM -1.0\n" +"//!MAXIMUM 3.0\n" "0.0\n" "//!PARAM mouse_y\n" "//!TYPE float\n" @@ -27,20 +26,20 @@ static const char vr_video_shader[] = \ "//!DESC un360\n" "const float M_PI = 3.141592653589793;\n" "vec4 hook() {\n" -" float yaw = M_PI*mouse_x;\n" -" float pitch = M_PI*(-0.5+mouse_y);\n" -" float roll = M_PI*0.0;\n" -" float t = tan(fov/2);\n" -" float c = cos(pitch);\n" -" float s = sin(pitch);\n" -" float r = target_size.y/target_size.x;\n" -" float sR = sin(roll);\n" -" float cR = cos(roll);\n" -" mat3 m = mat3(2*t*cR, 2*sR*t*r, -t*(cR+sR*r), -2*sR*t*c, 2*cR*t*c*r, t*c*(sR-cR*r)-s, -2*sR*t*s, 2*cR*t*s*r, t*s*(sR-cR*r)+c);\n" -" vec3 p = vec3(HOOKED_pos, 1.0) * m;\n" -" float theta = atan(p.x, p.z) + yaw;\n" -" float phi = atan(p.y, length(p.xz)) + M_PI/2;\n" -" float x = fract(theta / (2*M_PI));\n" -" float y = phi / M_PI;\n" -" return HOOKED_tex(vec2(x, y));\n" +" float yaw = M_PI*mouse_x;\n" +" float pitch = M_PI*(-0.5+mouse_y);\n" +" float roll = M_PI*0.0;\n" +" float t = tan(fov/2);\n" +" float c = cos(pitch);\n" +" float s = sin(pitch);\n" +" float r = target_size.y/target_size.x;\n" +" float sR = sin(roll);\n" +" float cR = cos(roll);\n" +" mat3 m = mat3(2*t*cR, 2*sR*t*r, -t*(cR+sR*r), -2*sR*t*c, 2*cR*t*c*r, t*c*(sR-cR*r)-s, -2*sR*t*s, 2*cR*t*s*r, t*s*(sR-cR*r)+c);\n" +" vec3 p = vec3(HOOKED_pos, 1.0) * m;\n" +" float theta = atan(p.x, p.z) + yaw;\n" +" float phi = atan(p.y, length(p.xz)) + M_PI/2;\n" +" float x = fract(theta / (2*M_PI));\n" +" float y = phi / M_PI;\n" +" return HOOKED_tex(vec2(x, y));\n" "}\n"; |