render texture testing
This commit is contained in:
parent
5fb52441d4
commit
7227c8f3d1
@ -25,7 +25,7 @@ struct cs_input {
|
|||||||
* Lighting
|
* Lighting
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
#define SAMPLES 64
|
#define SAMPLES 16
|
||||||
#define MARCHES 16
|
#define MARCHES 16
|
||||||
#define AMBIENT float3(0, 0, 0)
|
#define AMBIENT float3(0, 0, 0)
|
||||||
|
|
||||||
@ -100,11 +100,12 @@ SH_ENTRY(ROOTSIG) void cs(struct cs_input input)
|
|||||||
color *= albedo_tex[id];
|
color *= albedo_tex[id];
|
||||||
|
|
||||||
/* Apply lighting */
|
/* Apply lighting */
|
||||||
color.rgb *= get_light_at_pos(id);
|
// color.rgb *= get_light_at_pos(id);
|
||||||
|
|
||||||
/* Apply temporal accumulation */
|
/* Apply temporal accumulation */
|
||||||
float hysterisis = 0;
|
float hysterisis = 0;
|
||||||
// hysterisis = 0.2;
|
// hysterisis = 0.2;
|
||||||
|
// hysterisis = 0.5;
|
||||||
// hysterisis = 0.9;
|
// hysterisis = 0.9;
|
||||||
color.rgb = lerp(color.rgb, read_tex[id].rgb, hysterisis);
|
color.rgb = lerp(color.rgb, read_tex[id].rgb, hysterisis);
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#define IMAGE_PIXELS_PER_UNIT 128.0
|
#define IMAGE_PIXELS_PER_UNIT 128.0
|
||||||
|
|
||||||
|
#define RENDER_MARGIN (1000)
|
||||||
|
|
||||||
/* How many ticks back in time should the user thread blend between?
|
/* How many ticks back in time should the user thread blend between?
|
||||||
* <Delay> = <USER_INTERP_RATIO> * <Tick interval>
|
* <Delay> = <USER_INTERP_RATIO> * <Tick interval>
|
||||||
* E.g: At 1.5, the user thread will render 75ms back in time if the sim runs at 50tps
|
* E.g: At 1.5, the user thread will render 75ms back in time if the sim runs at 50tps
|
||||||
|
|||||||
1
src/gp.h
1
src/gp.h
@ -107,6 +107,7 @@ struct gp_render_params {
|
|||||||
struct v2i32 ui_size;
|
struct v2i32 ui_size;
|
||||||
struct v2i32 render_size;
|
struct v2i32 render_size;
|
||||||
struct xform world_to_render_xf;
|
struct xform world_to_render_xf;
|
||||||
|
struct xform render_to_ui_xf;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct gp_render_sig *gp_render_sig_alloc(void);
|
struct gp_render_sig *gp_render_sig_alloc(void);
|
||||||
|
|||||||
@ -2954,6 +2954,7 @@ struct gp_resource *gp_run_render(struct gp_render_sig *render_sig, struct gp_re
|
|||||||
struct v2i32 ui_size = V2I32(max_i32(params.ui_size.x, 1), max_i32(params.ui_size.y, 1));
|
struct v2i32 ui_size = V2I32(max_i32(params.ui_size.x, 1), max_i32(params.ui_size.y, 1));
|
||||||
struct v2i32 render_size = V2I32(max_i32(params.render_size.x, 1), max_i32(params.render_size.y, 1));
|
struct v2i32 render_size = V2I32(max_i32(params.render_size.x, 1), max_i32(params.render_size.y, 1));
|
||||||
struct xform world_to_render_xf = params.world_to_render_xf;
|
struct xform world_to_render_xf = params.world_to_render_xf;
|
||||||
|
struct xform render_to_ui_xf = params.render_to_ui_xf;
|
||||||
|
|
||||||
struct rect ui_viewport = RECT_FROM_V2(V2(0, 0), V2(ui_size.x, ui_size.y));
|
struct rect ui_viewport = RECT_FROM_V2(V2(0, 0), V2(ui_size.x, ui_size.y));
|
||||||
struct rect render_viewport = RECT_FROM_V2(V2(0, 0), V2(render_size.x, render_size.y));
|
struct rect render_viewport = RECT_FROM_V2(V2(0, 0), V2(render_size.x, render_size.y));
|
||||||
@ -2997,7 +2998,22 @@ struct gp_resource *gp_run_render(struct gp_render_sig *render_sig, struct gp_re
|
|||||||
__profn("Run render");
|
__profn("Run render");
|
||||||
__profnc_dx12(cl->cq->prof, cl->cl, "Run render", RGB32_F(0.5, 0.2, 0.2));
|
__profnc_dx12(cl->cq->prof, cl->cl, "Run render", RGB32_F(0.5, 0.2, 0.2));
|
||||||
struct mat4x4 world_to_render_vp_matrix = calculate_vp(world_to_render_xf, render_viewport.width, render_viewport.height);
|
struct mat4x4 world_to_render_vp_matrix = calculate_vp(world_to_render_xf, render_viewport.width, render_viewport.height);
|
||||||
|
|
||||||
|
struct mat4x4 blit_vp_matrix = ZI;
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
struct xform xf = render_to_ui_xf;
|
||||||
|
//xf = xform_scaled(xf, V2(ui_size.x, ui_size.y));
|
||||||
|
xf = xform_scaled(xf, V2(render_size.x, render_size.y));
|
||||||
|
xf = xform_translated(xf, V2(0.5, 0.5));
|
||||||
|
|
||||||
|
|
||||||
|
blit_vp_matrix = calculate_vp(xf, ui_viewport.width, ui_viewport.height);
|
||||||
|
#else
|
||||||
struct mat4x4 blit_vp_matrix = calculate_vp(XFORM_TRS(.t = v2_mul(V2(ui_size.x, ui_size.y), 0.5), .s = V2(ui_size.x, ui_size.y)), ui_viewport.width, ui_viewport.height);
|
struct mat4x4 blit_vp_matrix = calculate_vp(XFORM_TRS(.t = v2_mul(V2(ui_size.x, ui_size.y), 0.5), .s = V2(ui_size.x, ui_size.y)), ui_viewport.width, ui_viewport.height);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
struct mat4x4 ui_vp_matrix = calculate_vp(XFORM_IDENT, ui_viewport.width, ui_viewport.height);
|
struct mat4x4 ui_vp_matrix = calculate_vp(XFORM_IDENT, ui_viewport.width, ui_viewport.height);
|
||||||
|
|
||||||
/* Upload dummmy vert & index buffer */
|
/* Upload dummmy vert & index buffer */
|
||||||
|
|||||||
243
src/user.c
243
src/user.c
@ -128,16 +128,18 @@ GLOBAL struct {
|
|||||||
struct v2 screen_size;
|
struct v2 screen_size;
|
||||||
struct v2 screen_cursor;
|
struct v2 screen_cursor;
|
||||||
|
|
||||||
struct xform world_to_ui_xf;
|
struct xform ui_to_screen_xf;
|
||||||
struct xform world_to_render_xf;
|
|
||||||
|
|
||||||
struct v2 ui_screen_offset;
|
|
||||||
struct v2 ui_size;
|
struct v2 ui_size;
|
||||||
struct v2 ui_cursor;
|
struct v2 ui_cursor;
|
||||||
|
|
||||||
|
struct xform render_to_ui_xf;
|
||||||
struct v2 render_size;
|
struct v2 render_size;
|
||||||
|
struct v2 render_vis_size;
|
||||||
|
|
||||||
|
struct xform world_to_render_xf;
|
||||||
|
struct xform world_to_ui_xf;
|
||||||
struct v2 world_cursor;
|
struct v2 world_cursor;
|
||||||
|
|
||||||
struct v2 focus_send;
|
struct v2 focus_send;
|
||||||
} G = ZI, DEBUG_ALIAS(G, G_user);
|
} G = ZI, DEBUG_ALIAS(G, G_user);
|
||||||
|
|
||||||
@ -880,22 +882,12 @@ INTERNAL void user_update(struct sys_window *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Update ui from camera
|
* Update ui to screen xform from screen size
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
/* Calculate ui dimensions */
|
|
||||||
DEBUGBREAKABLE;
|
|
||||||
/* FIXME:
|
|
||||||
* At 180p & 360p, objects increment in uniform but grid does not.
|
|
||||||
* At 270p, grid increments in uniform but objects do not */
|
|
||||||
|
|
||||||
//G.render_size = V2(320, 180);
|
|
||||||
//G.render_size = V2(480, 270);
|
|
||||||
G.render_size = V2(640, 360);
|
|
||||||
//G.render_size = V2(2560, 1440);
|
|
||||||
if (G.debug_camera) {
|
if (G.debug_camera) {
|
||||||
G.ui_size = G.screen_size;
|
G.ui_size = G.screen_size;
|
||||||
G.ui_screen_offset = V2(0, 0);
|
G.ui_to_screen_xf = XFORM_IDENT;
|
||||||
} else {
|
} else {
|
||||||
/* Determine ui size by camera & window dimensions */
|
/* Determine ui size by camera & window dimensions */
|
||||||
f32 aspect_ratio = (f32)(DEFAULT_CAMERA_WIDTH / DEFAULT_CAMERA_HEIGHT);
|
f32 aspect_ratio = (f32)(DEFAULT_CAMERA_WIDTH / DEFAULT_CAMERA_HEIGHT);
|
||||||
@ -916,17 +908,109 @@ INTERNAL void user_update(struct sys_window *window)
|
|||||||
G.ui_size = V2(width, height);
|
G.ui_size = V2(width, height);
|
||||||
|
|
||||||
/* Center ui in window */
|
/* Center ui in window */
|
||||||
f32 x = 0;
|
f32 x = math_round(G.screen_size.x / 2 - width / 2);
|
||||||
f32 y = 0;
|
f32 y = math_round(G.screen_size.y / 2 - height / 2);
|
||||||
x = math_round(G.screen_size.x / 2 - width / 2);
|
G.ui_to_screen_xf = XFORM_TRS(.t = V2(x, y));
|
||||||
y = math_round(G.screen_size.y / 2 - height / 2);
|
|
||||||
G.ui_screen_offset = V2(x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
G.ui_cursor = v2_sub(G.screen_cursor, G.ui_screen_offset);
|
G.ui_cursor = xform_mul_v2(xform_invert(G.ui_to_screen_xf), G.screen_cursor);
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Update view from camera
|
* Update render to ui xform
|
||||||
|
* ========================== */
|
||||||
|
|
||||||
|
//DEBUGBREAKABLE;
|
||||||
|
/* FIXME:
|
||||||
|
* At 180p & 360p, objects increment in uniform but grid does not.
|
||||||
|
* At 270p, grid increments in uniform but objects do not */
|
||||||
|
|
||||||
|
//G.render_vis_size = V2(20, 20);
|
||||||
|
//G.render_vis_size = V2(320, 180);
|
||||||
|
//G.render_vis_size = V2(480, 270);
|
||||||
|
G.render_vis_size = V2(640, 360);
|
||||||
|
|
||||||
|
G.render_size = G.render_vis_size;
|
||||||
|
G.render_size.x += RENDER_MARGIN;
|
||||||
|
G.render_size.y += RENDER_MARGIN;
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
struct v2 scale = v2_div_v2(G.ui_size, G.render_vis_size);
|
||||||
|
scale.x = max_f32(scale.x, scale.y);
|
||||||
|
scale.y = scale.x;
|
||||||
|
struct xform xf = XFORM_IDENT;
|
||||||
|
xf = xform_scaled(xf, scale);
|
||||||
|
xf = xform_translated(xf, v2_mul(V2(RENDER_MARGIN, RENDER_MARGIN), -0.5));
|
||||||
|
G.render_to_ui_xf = xf;
|
||||||
|
}
|
||||||
|
#elif 0
|
||||||
|
{
|
||||||
|
struct v2 pos = v2_mul(G.ui_size, 0.5);
|
||||||
|
pos = v2_sub(pos, v2_mul(G.render_size, 0.5));
|
||||||
|
G.render_to_ui_xf = XFORM_TRS(.t = pos);
|
||||||
|
}
|
||||||
|
#elif 0
|
||||||
|
{
|
||||||
|
struct v2 scale = v2_div_v2(G.render_size, G.render_vis_size);
|
||||||
|
scale.x = min_f32(scale.x, scale.y);
|
||||||
|
scale.y = scale.x;
|
||||||
|
|
||||||
|
struct xform xf = XFORM_IDENT;
|
||||||
|
//xf = xform_translated(xf, v2_mul(V2(RENDER_MARGIN, RENDER_MARGIN), -0.5));
|
||||||
|
xf = xform_scaled(xf, scale);
|
||||||
|
G.render_to_ui_xf = xf;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
struct v2 margin = V2(RENDER_MARGIN, RENDER_MARGIN);
|
||||||
|
(UNUSED)margin;
|
||||||
|
|
||||||
|
struct v2 scale = v2_div_v2(G.render_size, G.render_vis_size);
|
||||||
|
scale.x = max_f32(scale.x, scale.y);
|
||||||
|
scale.y = scale.x;
|
||||||
|
(UNUSED)scale;
|
||||||
|
|
||||||
|
struct xform xf = XFORM_IDENT;
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
xf = xform_translated(xf, v2_mul(v2_sub(G.ui_size, G.render_size), 0.5));
|
||||||
|
xf = xform_scaled(xf, scale);
|
||||||
|
#else
|
||||||
|
struct v2 ui_center = v2_mul(G.ui_size, 0.5);
|
||||||
|
struct v2 render_center = v2_mul(G.render_size, 0.5);
|
||||||
|
|
||||||
|
xf = xform_translated(xf, ui_center);
|
||||||
|
xf = xform_scaled(xf, scale);
|
||||||
|
xf = xform_translated(xf, v2_neg(render_center));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//xf = xform_translated(xf, v2_mul(V2(RENDER_MARGIN, RENDER_MARGIN), -0.5));
|
||||||
|
|
||||||
|
|
||||||
|
//xf = xform_translated(xf, v2_mul(v2_sub(G.ui_size, G.render_size), -0.5));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//xf = xform_translated(xf, margin);
|
||||||
|
|
||||||
|
//xf = xform_translated(xf, V2(100, 100));
|
||||||
|
|
||||||
|
//xf.og = v2_sub(G.ui_size, G.render_size);
|
||||||
|
|
||||||
|
//xf = xform_translated(xf, v2_div_v2(v2_mul(v2_sub(G.ui_size, G.render_size), 0.5), scale));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
G.render_to_ui_xf = xf;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* ========================== *
|
||||||
|
* Update world to ui xform from camera
|
||||||
* ========================== */
|
* ========================== */
|
||||||
|
|
||||||
if (G.debug_camera) {
|
if (G.debug_camera) {
|
||||||
@ -961,23 +1045,24 @@ INTERNAL void user_update(struct sys_window *window)
|
|||||||
} else {
|
} else {
|
||||||
struct xform xf = sim_ent_get_xform(local_camera);
|
struct xform xf = sim_ent_get_xform(local_camera);
|
||||||
|
|
||||||
struct v2 center = xf.og;
|
struct v2 world_center = xf.og;
|
||||||
f32 rot = xform_get_rotation(xf);
|
f32 rot = xform_get_rotation(xf);
|
||||||
|
|
||||||
/* Scale view into viewport based on camera size */
|
/* Scale view into viewport based on camera size */
|
||||||
struct v2 size = G.ui_size;
|
struct v2 scale = G.ui_size;
|
||||||
{
|
{
|
||||||
struct xform quad_xf = xform_mul(xf, local_camera->camera_quad_xform);
|
struct xform quad_xf = xform_mul(xf, local_camera->camera_quad_xform);
|
||||||
struct v2 camera_size = xform_get_scale(quad_xf);
|
struct v2 camera_size = xform_get_scale(quad_xf);
|
||||||
if (!v2_is_zero(camera_size)) {
|
if (!v2_is_zero(camera_size)) {
|
||||||
size = v2_div_v2(size, camera_size);
|
scale = v2_div_v2(G.ui_size, camera_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f32 scale_ui = min_f32(size.x, size.y);
|
scale.x = min_f32(scale.x, scale.y);
|
||||||
|
scale.y = scale.x;
|
||||||
|
|
||||||
struct v2 ui_center = v2_mul(G.ui_size, 0.5);
|
struct v2 ui_center = v2_mul(G.ui_size, 0.5);
|
||||||
struct trs trs = TRS(.t = v2_sub(ui_center, center), .r = rot, .s = V2(scale_ui, scale_ui));
|
struct trs trs = TRS(.t = v2_sub(ui_center, world_center), .r = rot, .s = scale);
|
||||||
struct v2 pivot = center;
|
struct v2 pivot = world_center;
|
||||||
G.world_to_ui_xf = XFORM_IDENT;
|
G.world_to_ui_xf = XFORM_IDENT;
|
||||||
G.world_to_ui_xf = xform_translated(G.world_to_ui_xf, pivot);
|
G.world_to_ui_xf = xform_translated(G.world_to_ui_xf, pivot);
|
||||||
G.world_to_ui_xf = xform_translated(G.world_to_ui_xf, trs.t);
|
G.world_to_ui_xf = xform_translated(G.world_to_ui_xf, trs.t);
|
||||||
@ -986,6 +1071,47 @@ INTERNAL void user_update(struct sys_window *window)
|
|||||||
G.world_to_ui_xf = xform_translated(G.world_to_ui_xf, v2_neg(pivot));
|
G.world_to_ui_xf = xform_translated(G.world_to_ui_xf, v2_neg(pivot));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
G.world_cursor = xform_invert_mul_v2(G.world_to_ui_xf, G.ui_cursor);
|
||||||
|
|
||||||
|
/* ========================== *
|
||||||
|
* Update world to render xform from camera
|
||||||
|
* ========================== */
|
||||||
|
|
||||||
|
{
|
||||||
|
struct xform ui_to_world_xf = xform_invert(G.world_to_ui_xf);
|
||||||
|
struct v2 world_center = xform_mul_v2(ui_to_world_xf, v2_mul(G.ui_size, 0.5));
|
||||||
|
|
||||||
|
//world_center = v2_sub(world_center, V2(1, 1));
|
||||||
|
|
||||||
|
/* Scale view into viewport based on camera size */
|
||||||
|
//struct v2 scale = v2_div_v2(G.render_size, G.ui_size);
|
||||||
|
struct v2 scale = ZI;
|
||||||
|
//scale = v2_mul(G.render_size, IMAGE_PIXELS_PER_UNIT);
|
||||||
|
//scale = V2(IMAGE_PIXELS_PER_UNIT, IMAGE_PIXELS_PER_UNIT);
|
||||||
|
//scale = v2_div_v2(V2(1, 1), scale);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
scale = xform_get_scale(G.world_to_ui_xf);
|
||||||
|
#elif 1
|
||||||
|
struct v2 vis_scale = v2_div_v2(G.render_vis_size, G.render_size);
|
||||||
|
vis_scale.x = min_f32(vis_scale.x, vis_scale.y);
|
||||||
|
vis_scale.y = vis_scale.x;
|
||||||
|
|
||||||
|
scale = xform_get_scale(G.world_to_ui_xf);
|
||||||
|
scale = v2_mul_v2(scale, vis_scale);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct xform xf = XFORM_IDENT;
|
||||||
|
|
||||||
|
/*xf = xform_translated(xf, v2_mul(world_center, -1));*/
|
||||||
|
xf = xform_translated(xf, v2_mul(G.render_size, 0.5));
|
||||||
|
|
||||||
|
xf = xform_scaled(xf, scale);
|
||||||
|
xf = xform_translated(xf, v2_mul(world_center, -1));
|
||||||
|
|
||||||
|
|
||||||
|
G.world_to_render_xf = xf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -993,11 +1119,13 @@ INTERNAL void user_update(struct sys_window *window)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
DEBUGBREAKABLE;
|
|
||||||
|
#if 0
|
||||||
if (G.debug_camera) {
|
if (G.debug_camera) {
|
||||||
|
#if 0
|
||||||
G.world_to_render_xf = xform_basis_with_rotation_world(G.world_to_render_xf, 0);
|
G.world_to_render_xf = xform_basis_with_rotation_world(G.world_to_render_xf, 0);
|
||||||
|
|
||||||
struct v2 world_cursor = xform_invert_mul_v2(G.world_to_render_xf, G.ui_cursor);
|
struct v2 world_cursor = G.world_cursor;
|
||||||
|
|
||||||
/* Pan view */
|
/* Pan view */
|
||||||
if (G.bind_states[USER_BIND_KIND_PAN].is_held) {
|
if (G.bind_states[USER_BIND_KIND_PAN].is_held) {
|
||||||
@ -1023,27 +1151,28 @@ INTERNAL void user_update(struct sys_window *window)
|
|||||||
G.world_to_render_xf = xform_scaled(G.world_to_render_xf, V2(zoom, zoom));
|
G.world_to_render_xf = xform_scaled(G.world_to_render_xf, V2(zoom, zoom));
|
||||||
G.world_to_render_xf = xform_translated(G.world_to_render_xf, v2_neg(world_cursor));
|
G.world_to_render_xf = xform_translated(G.world_to_render_xf, v2_neg(world_cursor));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
struct xform xf = sim_ent_get_xform(local_camera);
|
struct xform xf = sim_ent_get_xform(local_camera);
|
||||||
|
|
||||||
struct v2 center = xf.og;
|
struct v2 world_center = xf.og;
|
||||||
f32 rot = xform_get_rotation(xf);
|
f32 rot = xform_get_rotation(xf);
|
||||||
|
|
||||||
/* Scale view into viewport based on camera size */
|
/* Scale view into viewport based on camera size */
|
||||||
struct v2 size = G.render_size;
|
struct v2 scale = G.render_vis_size;
|
||||||
{
|
{
|
||||||
struct xform quad_xf = xform_mul(xf, local_camera->camera_quad_xform);
|
struct xform quad_xf = xform_mul(xf, local_camera->camera_quad_xform);
|
||||||
struct v2 camera_size = xform_get_scale(quad_xf);
|
struct v2 camera_size = xform_get_scale(quad_xf);
|
||||||
if (!v2_is_zero(camera_size)) {
|
if (!v2_is_zero(camera_size)) {
|
||||||
size = v2_div_v2(size, camera_size);
|
scale = v2_div_v2(G.render_vis_size, camera_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f32 scale_render = min_f32(size.x, size.y);
|
scale.x = min_f32(scale.x, scale.y);
|
||||||
|
scale.y = scale.x;
|
||||||
|
|
||||||
struct v2 render_center = v2_mul(G.render_size, 0.5);
|
struct v2 render_center = v2_mul(G.render_size, 0.5);
|
||||||
|
struct trs trs = TRS(.t = v2_sub(render_center, world_center), .r = rot, .s = scale);
|
||||||
struct trs trs = TRS(.t = v2_sub(render_center, center), .r = rot, .s = V2(scale_render, scale_render));
|
struct v2 pivot = world_center;
|
||||||
struct v2 pivot = center;
|
|
||||||
G.world_to_render_xf = XFORM_IDENT;
|
G.world_to_render_xf = XFORM_IDENT;
|
||||||
G.world_to_render_xf = xform_translated(G.world_to_render_xf, pivot);
|
G.world_to_render_xf = xform_translated(G.world_to_render_xf, pivot);
|
||||||
G.world_to_render_xf = xform_translated(G.world_to_render_xf, trs.t);
|
G.world_to_render_xf = xform_translated(G.world_to_render_xf, trs.t);
|
||||||
@ -1051,6 +1180,7 @@ INTERNAL void user_update(struct sys_window *window)
|
|||||||
G.world_to_render_xf = xform_scaled(G.world_to_render_xf, trs.s);
|
G.world_to_render_xf = xform_scaled(G.world_to_render_xf, trs.s);
|
||||||
G.world_to_render_xf = xform_translated(G.world_to_render_xf, v2_neg(pivot));
|
G.world_to_render_xf = xform_translated(G.world_to_render_xf, v2_neg(pivot));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1063,16 +1193,42 @@ INTERNAL void user_update(struct sys_window *window)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
struct quad world_camera_quad = ZI;
|
||||||
|
world_camera_quad.p0 = V2(0, 0);
|
||||||
|
world_camera_quad.p1 = V2(0, G.ui_size.x);
|
||||||
|
world_camera_quad.p2 = V2(G.ui_size.x, G.ui_size.y);
|
||||||
|
world_camera_quad.p3 = V2(0, G.ui_size.y);
|
||||||
|
|
||||||
|
struct xform ui_to_world_xf = xform_invert(G.world_to_ui_xf);
|
||||||
|
world_camera_quad = xform_mul_quad(ui_to_world_xf, world_camera_quad);
|
||||||
|
|
||||||
|
struct v2 world_center = xform_mul_v2(ui_to_world_xf, v2_mul(G.ui_size, 0.5));
|
||||||
|
#else
|
||||||
|
//struct xform xf = sim_ent_get_xform(local_camera);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//struct v2 world_center = xf.og;
|
||||||
|
f32 rot = xform_get_rotation(G.world_to_ui_xf);
|
||||||
|
|
||||||
|
/* Scale view into viewport based on camera size */
|
||||||
|
//struct v2 scale = v2_div_v2(G.render_size, G.ui_size);
|
||||||
|
struct v2 scale = v2_sub(world_camera_quad.p2, world_camera_quad.p0);
|
||||||
|
scale = v2_div_v2(G.render_size, scale);
|
||||||
|
|
||||||
/* ========================== *
|
struct v2 render_center = v2_mul(G.render_size, 0.5);
|
||||||
* Update cursor
|
struct trs trs = TRS(.t = v2_sub(render_center, world_center), .r = rot, .s = scale);
|
||||||
* ========================== */
|
struct v2 pivot = world_center;
|
||||||
|
G.world_to_render_xf = XFORM_IDENT;
|
||||||
G.world_cursor = xform_invert_mul_v2(G.world_to_ui_xf, G.ui_cursor);
|
G.world_to_render_xf = xform_translated(G.world_to_render_xf, pivot);
|
||||||
|
G.world_to_render_xf = xform_translated(G.world_to_render_xf, trs.t);
|
||||||
|
G.world_to_render_xf = xform_rotated(G.world_to_render_xf, trs.r);
|
||||||
|
G.world_to_render_xf = xform_scaled(G.world_to_render_xf, trs.s);
|
||||||
|
G.world_to_render_xf = xform_translated(G.world_to_render_xf, v2_neg(pivot));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ========================== *
|
/* ========================== *
|
||||||
* Update listener from view
|
* Update listener from view
|
||||||
@ -2129,6 +2285,7 @@ INTERNAL void user_update(struct sys_window *window)
|
|||||||
params.ui_size = user_resolution;
|
params.ui_size = user_resolution;
|
||||||
params.render_size = world_resolution;
|
params.render_size = world_resolution;
|
||||||
params.world_to_render_xf = G.world_to_render_xf;
|
params.world_to_render_xf = G.world_to_render_xf;
|
||||||
|
params.render_to_ui_xf = G.render_to_ui_xf;
|
||||||
render_texture = gp_run_render(G.render_sig, params);
|
render_texture = gp_run_render(G.render_sig, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user