X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=render.h;h=64556ffbcfac1390a7c4789976c524e990d2608a;hb=5fa590f62aa7e62a8b6b07e10556c2ecc54cdca6;hp=0abbdae0ce9f07a78b3b8c964fd38abf67117f53;hpb=1f1d636056450dcd23cce55c0795ec6276272531;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/render.h b/render.h index 0abbdae..64556ff 100644 --- a/render.h +++ b/render.h @@ -1,37 +1,129 @@ -#ifndef RENDER_H -#define RENDER_H -#define VG_3D -#include "vg/vg.h" +/* + * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved + */ +#pragma once +#include "common.h" +#include "model.h" +#include "camera.h" -static struct pipeline -{ - float fov; -} -gpipeline; +#include "shaders/blit.h" +#include "shaders/blitblur.h" +#include "shaders/blitcolour.h" +#include "shaders/blit_transition.h" -static void render_water_texture( m4x3f camera ); -static void render_water_surface( m4x4f pv ); -static void render_world( m4x4f pv ); +#define WORKSHOP_PREVIEW_WIDTH 504 +#define WORKSHOP_PREVIEW_HEIGHT 336 + +static f32 k_render_scale = 1.0f; +static i32 k_blur_effect = 1; +static f32 k_blur_strength = 0.3f; +static f32 k_fov = 0.86f; +static f32 k_cam_height = 0.8f; + +typedef struct framebuffer framebuffer; /* - * http://www.terathon.com/lengyel/Lengyel-Oblique.pdf + * All standard buffers used in rendering */ -static void plane_clip_projection( m4x4f mat, v4f plane ) -{ - v4f c = - { - (vg_signf(plane[0]) + mat[2][0]) / mat[0][0], - (vg_signf(plane[1]) + mat[2][1]) / mat[1][1], - -1.0f, - (1.0f + mat[2][2]) / mat[3][2] - }; - - v4_muls( plane, 2.0f / v4_dot(plane,c), c ); - - mat[0][2] = c[0]; - mat[1][2] = c[1]; - mat[2][2] = c[2] + 1.0f; - mat[3][2] = c[3]; +static struct pipeline{ + glmesh fsquad; + + framebuffer *fb_main, + *fb_water_reflection, + *fb_water_beneath, + *fb_workshop_preview, + *fb_network_status; + int ready; } +gpipeline; + +struct framebuffer{ + const char *display_name; + int resolution_div, /* definition */ + fixed_w, + fixed_h, + + render_w, /* runtime */ + render_h; + + struct framebuffer_attachment{ + const char *display_name; + + enum framebuffer_attachment_type{ + k_framebuffer_attachment_type_none, + k_framebuffer_attachment_type_texture, + k_framebuffer_attachment_type_renderbuffer, + k_framebuffer_attachment_type_texture_depth + } + purpose; + + enum framebuffer_quality_profile{ + k_framebuffer_quality_all, + k_framebuffer_quality_high_only + } + quality; + + GLenum internalformat, + format, + type, + attachment; + + GLuint id; + + /* Runtime */ + int debug_view; + } + attachments[5]; + GLuint fb; + framebuffer **link; +} +extern framebuffers[]; + + +struct shader_props_standard +{ + u32 tex_diffuse; +}; + +struct shader_props_terrain +{ + u32 tex_diffuse; + v2f blend_offset; + v4f sand_colour; +}; + +struct shader_props_vertex_blend +{ + u32 tex_diffuse; + v2f blend_offset; +}; + +struct shader_props_water +{ + v4f shore_colour; + v4f deep_colour; + f32 fog_scale; + f32 fresnel; + f32 water_sale; + v4f wave_speed; +}; + +struct shader_props_cubemapped +{ + u32 tex_diffuse; + u32 cubemap_entity; + v4f tint; +}; -#endif /* RENDER_H */ +void render_init(void); +void render_fsquad(void); +void render_fsquad1(void); +void render_fsquad2(void); +void render_view_framebuffer_ui(void); +void render_fb_bind_texture( framebuffer *fb, int attachment, int slot ); +void render_fb_inverse_ratio( framebuffer *fb, v2f inverse ); +void render_fb_get_current_res( struct framebuffer *fb, int *x, int *y ); +void render_fb_bind( framebuffer *fb, int use_scaling ); +void render_fb_bind_texture( framebuffer *fb, int attachment, int slot ); +void render_fb_allocate( struct framebuffer *fb ); +void render_fb_resize(void);