summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-08-14 10:59:42 -0400
committerAndrew Opalach <andrew@akon.city> 2025-08-14 10:59:42 -0400
commitc48a6d1e806d7bd92cad81eaffe734f8bf9e40f5 (patch)
treed4cb5610f2f7fde2e2975679721aea7e17352ada /src/render
parent7e796649557bfeae6eccba751d4a1ffae75de45c (diff)
downloadcamu-c48a6d1e806d7bd92cad81eaffe734f8bf9e40f5.tar.gz
camu-c48a6d1e806d7bd92cad81eaffe734f8bf9e40f5.tar.bz2
camu-c48a6d1e806d7bd92cad81eaffe734f8bf9e40f5.zip
Support 360 degree videos, Improve VR keybinds
- Update liana API in cdio handler. - Fix some build configurations. Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/render')
-rw-r--r--src/render/queue_libplacebo.c6
-rw-r--r--src/render/renderer_libplacebo.c17
-rw-r--r--src/render/shaders/vr_video.h37
3 files changed, 33 insertions, 27 deletions
diff --git a/src/render/queue_libplacebo.c b/src/render/queue_libplacebo.c
index 01cd366..d1f7d88 100644
--- a/src/render/queue_libplacebo.c
+++ b/src/render/queue_libplacebo.c
@@ -256,10 +256,10 @@ static bool map_av_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *
#ifdef CAMU_HAVE_SUBTITLES
if (ok && lq->has_subtitles) {
- s64 now = av_rescale_q(frame->best_effort_timestamp, stream->time_base, (AVRational){ 1, 1000 });
+ s64 pts = av_rescale_q(frame->best_effort_timestamp, stream->time_base, (AVRational){ 1, 1000 });
nn_mutex_lock(&lq->subtitle_lock);
s32 change; // 1 = different position, 2 = different content.
- ASS_Image *ass_frame = ass_render_frame(lq->ass_renderer, lq->ass_track, now, &change);
+ ASS_Image *ass_frame = ass_render_frame(lq->ass_renderer, lq->ass_track, pts, &change);
if (ass_frame) {
struct camu_overlay_lp *overlay = NULL;
if (lq->overlays.count > 0) overlay = al_array_last(lq->overlays);
@@ -272,6 +272,8 @@ static bool map_av_frame(pl_gpu gpu, pl_tex *tex, const struct pl_source_frame *
out_frame->overlays = overlay->overlays;
out_frame->num_overlays = overlay->num;
((struct pl_source_frame *)src)->frame_data = overlay;
+ } else if (change > 0) {
+ log_error("Failed to parse or render subtitle.");
}
nn_mutex_unlock(&lq->subtitle_lock);
}
diff --git a/src/render/renderer_libplacebo.c b/src/render/renderer_libplacebo.c
index cdf09bf..562c486 100644
--- a/src/render/renderer_libplacebo.c
+++ b/src/render/renderer_libplacebo.c
@@ -107,6 +107,8 @@ static void ass_log_callback(s32 level, const char *fmt, va_list args, void *use
(void)userdata;
if (level <= 1) {
al_logv(AL_LOG_ERROR, "ass", fmt, args);
+ } else if (level <= 3) {
+ al_logv(AL_LOG_WARN, "ass", fmt, args);
} else {
#ifdef AL_DEBUG
al_logv(AL_LOG_DEBUG, "ass", fmt, args);
@@ -247,7 +249,7 @@ static bool renderer_lp_create_renderer(struct camu_renderer *renderer, u32 *wid
}
lr->swapchain = pl_opengl_create_swapchain(lr->gl, pl_opengl_swapchain_params(
- //.max_swapchain_depth = 2,
+ .max_swapchain_depth = 1,
.swap_buffers = gl_swap_buffers,
.priv = priv
));
@@ -391,11 +393,14 @@ static void renderer_lp_render(struct camu_renderer *renderer, struct camu_scree
f64 mouse_x, mouse_y;
bool vr_emulation = scr->vr_emulation && lr->vr_emulation_hook[0];
if (vr_emulation) {
- mouse_x = (scr->last_pointer_x - (scr->calibrate_x - (scr->width / 2.0))) / (f64)scr->width;
- mouse_y = (scr->last_pointer_y - (scr->calibrate_y - (scr->height / 2.0))) / (f64)scr->height;
- mouse_y = 1.0 - mouse_y;
- mouse_x = CLAMP(mouse_x, -0.5, 1.5);
- mouse_y = CLAMP(mouse_y, -0.5, 1.5);
+ mouse_x = (scr->last_pointer_x / scr->width) - (scr->vr_calibrate_x - 0.5);
+ mouse_y = (scr->last_pointer_y / scr->height) - (scr->vr_calibrate_y - 0.5);
+ if (scr->vr_emulation == CAMU_VR_360) {
+ mouse_x = CLAMP(mouse_x * 2.0, -1.0, 3.0);
+ } else {
+ mouse_x = CLAMP(mouse_x, -0.5, 1.5);
+ }
+ mouse_y = CLAMP(1.0 - mouse_y, -0.5, 1.5);
lr->params.hooks = lr->vr_emulation_hook;
lr->params.num_hooks = 1;
lr->params.hooks[0]->parameters[0].data->f = (f32)mouse_x;
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";