diff options
| author | 2026-04-13 17:01:47 -0400 | |
|---|---|---|
| committer | 2026-04-13 17:01:47 -0400 | |
| commit | 77b54c35bf9587450cd636e0d7df37e190e28bfb (patch) | |
| tree | a290efdd8b09066847199f3f52a32be70d24ef51 /src/render/shaders | |
| parent | 20617b9c80cf8d8051ecdb53a2c22f68c012f21b (diff) | |
| download | camu-77b54c35bf9587450cd636e0d7df37e190e28bfb.tar.gz camu-77b54c35bf9587450cd636e0d7df37e190e28bfb.tar.bz2 camu-77b54c35bf9587450cd636e0d7df37e190e28bfb.zip | |
Smaller stuff that went uncommitted
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/render/shaders')
| -rw-r--r-- | src/render/shaders/vr_video.h | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/src/render/shaders/vr_video.h b/src/render/shaders/vr_video.h index 73869eb..c892601 100644 --- a/src/render/shaders/vr_video.h +++ b/src/render/shaders/vr_video.h @@ -5,7 +5,7 @@ // 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 -static const char vr_video_shader[] = \ +static char vr_video_shader[] = \ "//!PARAM mouse_x\n" "//!TYPE float\n" "//!MINIMUM -1.0\n" @@ -18,28 +18,33 @@ static const char vr_video_shader[] = \ "0.5\n" "//!PARAM fov\n" "//!TYPE float\n" -"//!MINIMUM 0\n" +"//!MINIMUM 0.0\n" "//!MAXIMUM 3.141592653589793\n" "1.5707963267948966\n" +"//!PARAM mode\n" +"//!TYPE float\n" +"//!MINIMUM 0.0\n" +"//!MAXIMUM 2.0\n" +"1.0\n" // 0.0 = Left eye, 1.0 = Right eye, 2.0 = 360 degrees. "//!HOOK MAINPRESUB\n" "//!BIND HOOKED\n" "//!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" -"}\n"; +"const float M_PI = 3.141592653589793;" +"vec4 hook() {" +" float yaw = M_PI*mouse_x;" +" float pitch = M_PI*(-0.5+mouse_y);" +" float roll = M_PI*0.0;" +" float t = tan(fov/2.0);" +" float c = cos(pitch);" +" float s = sin(pitch);" +" float r = target_size.y/target_size.x;" +" float sR = sin(roll);" +" float cR = cos(roll);" +" mat3 m = mat3(2.0*t*cR, 2.0*sR*t*r, -t*(cR+sR*r), -2.0*sR*t*c, 2.0*cR*t*c*r, t*c*(sR-cR*r)-s, -2.0*sR*t*s, 2.0*cR*t*s*r, t*s*(sR-cR*r)+c);" +" vec3 p = vec3(HOOKED_pos, 1.0)*m;" +" float theta = atan(p.x, p.z)+yaw;" +" float phi = atan(p.y, length(p.xz))+M_PI/2.0;" +" float x = fract(theta/(2.0*M_PI));" +" float y = phi/M_PI;" // Range: [M_PI, 2.0*M_PI] = Right eye 180 degrees. float(max(theta, mode-1.0) > 0.0) = Always true except mode = 0.0 and theta < 0.0. +" return HOOKED_tex(vec2(x, y))*clamp(abs((1.0-mode)-(step(M_PI, theta)-step(2.0*M_PI, theta)))*float(max(theta, mode-1.0)>=0.0), 0.0, 1.0);" +"}"; |