|
Untitled
|
The main render pass, data GPU uploads, and SSBO management. More...
Go to the source code of this file.
Functions | |
| void | bind_baking_ssbos () |
| Binds SSBOs required for baking. | |
| void | unbind_baking_ssbos () |
| Unbinds SSBOs required for baking. | |
| void | bind_render_ssbos () |
| Binds SSBOs required for rendering. | |
| void | aabb_to_vertices (DebugVertex *out, AABB *aabb, vec3 offset) |
| Transfers an AABB to DebufVertex for a wireframe (GL_LINES). | |
| void | render_mesh_aabbs_from_root (MeshNode *mn) |
| Adds Mesh AABBs for each MeshNode child recursively to DEBUG_LINES. | |
| void | upload_material_data () |
| Uploads Material data to the GPU as MaterialGPU. | |
| void | copy_light_to_gpu_light (LightGPU *lgpu, Light *l) |
| Transfers a Light to a LightGPU. | |
| void | upload_lights () |
| Uploads all current Lights inside of Globals.lights to the GPU in a triple buffered LIGHT_SSBO. | |
| void | add_mesh_to_buffer (Mesh *m, VertexLayout *layout) |
| Adds a single Mesh to the MAIN_VBO. | |
| void | add_all_meshes_to_buffer (VertexLayout *layout) |
| Adds all Meshes that have valid MeshNodes. | |
| void | add_text_box (Vector *tvs, Vector *tis, TextBox *tb, int current_box) |
| Adds a TextBox to a vertex and index buffer, to be uploaded to TEXT_VBO and TEXT_EBO. | |
| void | add_all_text_boxes_to_draw_buffer () |
| Adds all TextBoxes to TEXT_VBO and iterates through each character to push indices to TEXT_EBO. | |
| void | create_and_sort_draw_commands (int *dc_cnt, DrawCommand *dcs) |
| Creates all DrawCommands based on unique SubMeshes and sorts them via DrawCommand.sort_key. | |
| void | render_to_cubemap_face (Camera *rprobe_cam, GLuint render_fbo, int render_width, int render_height, bool probe_bake) |
| Uploads per-frame data to GPU and renders main render pass to a target FBO (omits Text, UI, and postprocessing that occurs after). | |
| void | render () |
| The main render pass. | |
The main render pass, data GPU uploads, and SSBO management.
Definition in file render.h.
| void bind_baking_ssbos | ( | ) |
Binds SSBOs required for baking.
Definition at line 31 of file render.c.
References bind_baking_ssbos(), MESH_BVH_SSBO, MESH_SSBO, PROBE_SSBO, RPROBE_SSBO, SCENE_BVH_SSBO, TRI_SSBO, and VERTEX_SSBO.
Referenced by bake_audio_probe_volume(), bake_lighting_probe_volume(), bake_lightmap(), and bind_baking_ssbos().
| void unbind_baking_ssbos | ( | ) |
Unbinds SSBOs required for baking.
Definition at line 42 of file render.c.
References GLOBAL_INSTANCE_SSBO, INDIRECT_ARRAYS_COMMAND_BUFFER, INDIRECT_ELEMENTS_COMMAND_BUFFER, INSTANCE_SSBO, JOINT_SSBO, RPROBE_SSBO, TEXT_BOX_SSBO, and unbind_baking_ssbos().
Referenced by bake_audio_probe_volume(), bake_lighting_probe_volume(), bake_lightmap(), and unbind_baking_ssbos().
| void bind_render_ssbos | ( | ) |
Binds SSBOs required for rendering.
Definition at line 56 of file render.c.
References bind_render_ssbos(), CLUSTER_AABB_SSBO, CLUSTER_SSBO, GLOBAL_INSTANCE_SSBO, GLOBAL_LIGHT_INDICES_SSBO, INDIRECT_ARRAYS_COMMAND_BUFFER, INDIRECT_ELEMENTS_COMMAND_BUFFER, INSTANCE_SSBO, JOINT_SSBO, LIGHTMAP_SSBO, MATERIAL_SSBO, MESH_LIGHT_SSBO, MESH_NODE_SSBO, RPROBE_SSBO, TEXT_BOX_SSBO, and UI_SSBO.
Referenced by bind_render_ssbos(), and init().
| void aabb_to_vertices | ( | DebugVertex * | out, |
| AABB * | aabb, | ||
| vec3 | offset ) |
Transfers an AABB to DebufVertex for a wireframe (GL_LINES).
| out | The outgoing vertices. |
| aabb | The input AABB. |
| offset | The offset in world space. |
Definition at line 475 of file render.c.
References aabb_to_vertices(), AABB::center, DebugVertex::pos, and vec3_add().
Referenced by aabb_to_vertices(), ray_traverse_scene_bvh(), render(), render_mesh_aabbs_from_root(), render_probe_volume(), render_tree(), and update_physics_components().
| void render_mesh_aabbs_from_root | ( | MeshNode * | mn | ) |
Adds Mesh AABBs for each MeshNode child recursively to DEBUG_LINES.
| mn | The MeshNode root. |
Definition at line 517 of file render.c.
References Mesh::aabb, aabb_to_vertices(), CAST_VEC, MeshNode::child_count, MeshNode::children, DebugVertex::color, DEBUG_LINE_COUNT, DEBUG_LINES, MeshNode::global_matrix, GLOBALS, MeshNode::mesh, Globals::mesh_nodes, Globals::meshes, render_mesh_aabbs_from_root(), and transform_aabb_by_model_matrix().
Referenced by render_mesh_aabbs_from_root(), and update_physics_components().
| void upload_material_data | ( | ) |
Uploads Material data to the GPU as MaterialGPU.
Definition at line 854 of file render.c.
References Material::absorption_coefficients, MaterialGPU::absorption_coefficients, MaterialGPU::albedo_handle, Material::alpha_cutoff, MaterialGPU::alpha_cutoff, Material::alpha_mode, MaterialGPU::alpha_mode, MaterialGPU::ambient, Material::ao_strength, MaterialGPU::ao_strength, MaterialGPU::arm_handle, Material::arm_tex, AUDIO_NUM_BANDS, CAST_VEC, Vector::count, DEFAULT_ARM, DEFAULT_DIFFUSE, DEFAULT_EMISSIVE, DEFAULT_NORMAL, MaterialGPU::diffuse, Material::diffuse_tex, Material::double_sided, MaterialGPU::double_sided, MaterialGPU::emissive, MaterialGPU::emissive_handle, Material::emissive_strength, MaterialGPU::emissive_strength, Material::emissive_tex, GLOBALS, Image::handle, Globals::images, Material::ka, Material::kd, Material::ke, Material::ks, MATERIAL_DATA, MATERIAL_SSBO, Globals::materials, MaterialData::materials, Material::metallic, MaterialGPU::metallic, MaterialGPU::normal_handle, Material::normal_scale, MaterialGPU::normal_scale, Material::normal_tex, Material::override_arm, Material::roughness, MaterialGPU::roughness, Material::scattering_coefficients, MaterialGPU::scattering_coefficients, MaterialGPU::specular, and upload_material_data().
Referenced by execute_globals_undo(), main(), render_light_menu(), render_main_menu(), render_material_menu(), scene_load(), scene_load_volumes(), and upload_material_data().
Transfers a Light to a LightGPU.
| l | The light to copy from. |
| lgpu | The target GPU light. |
Definition at line 602 of file render.c.
References LightGPU::area, Light::cone_angle, copy_light_to_gpu_light(), LightGPU::cos_diff, Light::dir, LightGPU::dir, Light::entity_id, LightGPU::entity_id, Light::inner_angle, LightGPU::inner_angle, Light::intensity, LightGPU::intensity, Light::layer, LightGPU::layer, Light::light_type, LightGPU::light_type, Light::mesh, LightGPU::mesh, Light::outer_angle, LightGPU::outer_angle, LightGPU::outer_cos, Light::penumbra, Light::pos, LightGPU::pos, Light::radius, LightGPU::radius, Light::rgb, LightGPU::rgb, Light::surface_area, Light::threshold, Light::tri, and LightGPU::tri.
Referenced by copy_light_to_gpu_light(), upload_bake_lights_gpu(), and upload_lights().
| void upload_lights | ( | ) |
Uploads all current Lights inside of Globals.lights to the GPU in a triple buffered LIGHT_SSBO.
Definition at line 634 of file render.c.
References CAST_VEC, copy_light_to_gpu_light(), Vector::count, current_frame, GLOBALS, gpu_light_count, GPU_LIGHTS, LIGHT_SSBO, light_ssbo_ptr, light_ssbo_size, Globals::lights, and upload_lights().
Referenced by execute_globals_undo(), main(), render_light_menu(), render_main_menu(), render_to_cubemap_face(), scene_load(), scene_load_volumes(), and upload_lights().
| void add_mesh_to_buffer | ( | Mesh * | m, |
| VertexLayout * | layout ) |
Adds a single Mesh to the MAIN_VBO.
| m | The Mesh to add. |
| layout | The VertexLayout whose offset and counts during Mesh addition. |
Definition at line 343 of file render.c.
References add_mesh_to_buffer(), calc_mesh_index_size(), calc_mesh_size(), CAST_VEC, Mesh::count, Vector::count, fill_index_buffer_mesh(), fill_vertex_buffer_mesh(), GLOBALS, Mesh::id, index_offset, layout(), Globals::meshes, Mesh::offset, Mesh::tris, vector_expand(), visize, and vsize.
Referenced by add_all_meshes_to_buffer(), and add_mesh_to_buffer().
| void add_all_meshes_to_buffer | ( | VertexLayout * | layout | ) |
Adds all Meshes that have valid MeshNodes.
| layout | The layout to use (MAIN_VAO). @critial Decide if we should upload ALL Meshes instead of just MeshNodes here so that we can separate the two. |
Definition at line 441 of file render.c.
References add_all_meshes_to_buffer(), add_mesh_to_buffer(), allocate_lightmap_ssbo(), CAST_VEC, Vector::count, MeshNode::free, GLOBALS, init_vector(), layout(), LIGHTMAP_DATA, LIGHTMAP_SSBO, MeshNode::mesh, Globals::mesh_nodes, Globals::meshes, LightmapSSBO::uvs, and Mesh::vertices.
Referenced by add_all_meshes_to_buffer(), execute_globals_undo(), LM_allocate_empty_mns(), LM_regenerate_texels(), load_lightmap_from_binary(), main(), render_light_menu(), render_main_menu(), and scene_load().
Adds a TextBox to a vertex and index buffer, to be uploaded to TEXT_VBO and TEXT_EBO.
| tvs | The out vertex Vector. |
| tis | The out index Vector. |
| tb | The TextBox to upload. |
| current_box | The index within the entire buffer, meaning a running count through each individual UIMenus. |
Definition at line 1154 of file render.c.
References add_text_box(), CAST_VEC, TextBox::color, Vector::count, TextBox::fill, TextBox::font_id, FONTS, Font::glyph_count, Font::glyphs, Glyph::height, TextBox::start, TextBox::text, TextBox::text_size, Glyph::u0, Glyph::u1, Glyph::v0, Glyph::v1, vector_expand(), Glyph::width, vec2::x, Glyph::xadvance, Glyph::xoffset, vec2::y, and Glyph::yoffset.
Referenced by add_all_text_boxes_to_draw_buffer(), and add_text_box().
| void add_all_text_boxes_to_draw_buffer | ( | ) |
Adds all TextBoxes to TEXT_VBO and iterates through each character to push indices to TEXT_EBO.
Definition at line 1220 of file render.c.
References add_all_text_boxes_to_draw_buffer(), add_text_box(), Vector::buffer, CAST_VEC, Vector::count, init_vector(), MAX_TEXT_BOXES, MENUS, UIMenu::text_boxes, TEXT_EBO, TEXT_INDEX_COUNT, and TEXT_VBO.
Referenced by add_all_text_boxes_to_draw_buffer(), execute_text_box_undo(), execute_ui_element_undo(), main(), render_text_menu(), render_ui_menu(), scene_load(), and update_performance_overlay().
| void create_and_sort_draw_commands | ( | int * | dc_cnt, |
| DrawCommand * | dcs ) |
Creates all DrawCommands based on unique SubMeshes and sorts them via DrawCommand.sort_key.
| dc_cnt | The output count of DrawCommands. |
| dcs | The output DrawCommands. |
Definition at line 1132 of file render.c.
References compare_draw_commands(), create_and_sort_draw_commands(), and populate_draw_commands().
Referenced by create_and_sort_draw_commands(), and render_to_cubemap_face().
| void render_to_cubemap_face | ( | Camera * | rprobe_cam, |
| GLuint | render_fbo, | ||
| int | render_width, | ||
| int | render_height, | ||
| bool | probe_bake ) |
Uploads per-frame data to GPU and renders main render pass to a target FBO (omits Text, UI, and postprocessing that occurs after).
| rprobe_cam | The Camera to upload for the CAM_UBO. |
| render_fbo | The main target FBO. |
| render_width | The width of the target FBO. |
| probe_bake | If this is baking ReflectionProbes. This flag controls if ReflectionProbes are sampled so that there is no accumulation. |
Definition at line 2278 of file render.c.
References mat3::a0, mat3::a1, mat3::a2, array_offset, DrawCommand::array_offset, OBBGPU::axis_x, OBBGPU::axis_y, OBBGPU::axis_z, mat3::b0, mat3::b1, mat3::b2, EditorSettings::BLOOM, BLOOM_DOWNSCALE_SHADER, BLOOM_PYRAMID, bloom_queries, BLOOM_SHADER, BLOOM_UPSCALE_SHADER, BOKEH_FBO, BOKEH_SHADER, BUFFER_FRAMES, mat3::c0, mat3::c1, mat3::c2, Camera::cam_data, CAM_UBO, cam_ubo_padded, cam_ubo_ptr, CAST_VEC, OBB::center, OBBGPU::center, COC_FBO, COC_SHADER, Vector::count, create_and_sort_draw_commands(), CULL_CLUSTERS_SHADER, CULL_DRAW_CALLS_SHADER, cull_queries, cur_history, current_frame, current_query_frame, DEPTH_DOWNSAMPLE_FBO, DEPTH_DOWNSAMPLE_SHADER, DEPTH_PRE_PASS_SHADER, DEPTH_PRE_PASS_SHADER_MSAA, Framebuffer::depth_texture, determine_closest_rprobes(), determine_light_visibility_per_mesh(), DIRECTIONAL_LIGHT_COUNT, EditorSettings::DOF, EditorSettings::DOF_focal_length, EditorSettings::DOF_fstop, DOF_HEIGHT, EditorSettings::DOF_max_blur_radius, dof_queries, EditorSettings::DOF_sensor_height, DOF_WIDTH, draw_arrays_elements(), draw_call_count, draw_command_count, draw_command_counts, draw_command_offsets, DRAW_COMMANDS, draw_dirty, EDITOR_SETTINGS, DrawCommand::element_offset, element_offset, ELEMENTS_PREFIX_SHADER, OBB::extents, OBBGPU::extents, Framebuffer::fbo, FOCAL_DISTANCE_SHADER, EditorSettings::FULL_GBUFFER, DrawCommand::fwd_shader, GALBEDO, GBUFFER_FBO, gbuffer_queries, GBUFFER_RESOLVE_FBO, DrawCommand::gbuffer_shader, get_view_planes(), GEXTRA, GLOBAL_INSTANCE_SSBO, GLOBALS, GNORMAL, GPOMDEPTH, GRID_X, GRID_Y, GRID_Z, GVEL, Framebuffer::h, GLTexture::i, INDIRECT_ARRAYS_COMMAND_BUFFER, INDIRECT_ARRAYS_COMMAND_BUFFER_OUT, INDIRECT_ELEMENTS_COMMAND_BUFFER, INDIRECT_ELEMENTS_COMMAND_BUFFER_OUT, INDIRECT_PREFIX_SHADER, instance_offset, INSTANCE_VBO, instance_vbo_ptr, JITTER_OFFSET, LIGHT_CAM, LIGHT_CAM_UBO, light_cam_ubo_padded, light_cam_ubo_ptr, SceneData::lighting_probe_volumes, Globals::lights, Globals::lights_dirty, OBBGPU::loaded, SceneData::LOADED_LIGHTING_PV, SceneData::LOADED_LIGHTING_PV_FLAG, Uniform::location, LPV_SLOTS, MAIN_EBO, MAIN_FBO, MAIN_RESOLVE_FBO, MAIN_VAO, MAIN_VBO, MAX_LIGHTS_PER_CLUSTER, mesh_node_data_gpu, Globals::mesh_nodes, Globals::meshes, EditorSettings::MSAA, ProbeVolume::obb, ProbeVolumeUBO::obb, DrawCommand::opaque, pl_queries, planes, probe_bake, PROBE_VOLUME_UBO, probe_volume_ubo_padded, probe_volume_ubo_ptr, ShaderProgram::program, CamData::proj, ShadowmapUBO::proj, LPV::pv_id, render_all_draw_commands(), RENDER_HEIGHT, render_queries, render_to_cubemap_face(), RENDER_WIDTH, OBB::rot, RPROBE_UBO, RPROBE_UBO_DATA, rprobe_ubo_padded, rprobe_ubo_ptr, Globals::scene_data, SHADOW_MAP_FBO, SHADOW_MAP_SHADER, SHADOWMAP_FRAME_DATA, SKY_SHADER, SKY_VAO, SKY_VBO, SKYBOX, sm_queries, EditorSettings::SSAO, SSAO_BLUR_FBO, SSAO_BLUR_SHADER, SSAO_FBO, SSAO_HEIGHT, SSAO_NOISE_TEXTURE, ssao_queries, SSAO_SHADER, SSAO_WIDTH, EditorSettings::SSR, SSR_FBO, SSR_HEIGHT, SSR_HISTORY_SHADER, ssr_queries, SSR_SHADER, SSR_WIDTH, DrawCommand::static_mesh, EditorSettings::TAA, TAA_FBO, taa_queries, Framebuffer::texture, time, time_since_last_render, transform_count, ShaderProgram::uniforms, update_scene_nodes(), update_skin_matrices(), upload_instance_data(), upload_instances(), upload_joint_matrices(), upload_lights(), CamData::view, ShadowmapUBO::view, VIEW_FAR, VIEW_NEAR, Framebuffer::w, write_point_light_shadows(), vec2::x, and vec2::y.
Referenced by bake_reflection_probes(), render(), and render_to_cubemap_face().
| void render | ( | ) |
The main render pass.
Calls render_to_cubemap_face() and then renders wireframes, text, ui, and postprocessing.
Definition at line 3057 of file render.c.
References ReflectionProbe::aabb, aabb_to_vertices(), EditorSettings::ACES, animation_length(), AUDIO_EMITTERS, EditorSettings::audio_menu_open, Globals::audio_portals, SceneData::audio_probe_volumes, EditorSettings::BLOOM, BLOOM_PYRAMID, BOKEH_FBO, BUFFER_FRAMES, SceneData::bvh_nodes, cam, ReflectionProbe::capture_pos, CAST_VEC, AABB::center, COC_FBO, DebugVertex::color, COLOR_GRADE_LUT, Vector::count, cur_history, current_frame, current_query_frame, DEBUG_LINE_COUNT, DEBUG_LINES, DEBUG_LINES_MAX, Framebuffer::depth_texture, EditorSettings::DOF, EditorSettings::DOF_focal_length, EditorSettings::DOF_fstop, EditorSettings::DOF_max_blur_radius, EditorSettings::DOF_sensor_height, EDITOR_APORTAL_SIZE, EDITOR_AUDIO_EMITTER_SIZE, EDITOR_LIGHT_SIZE, EDITOR_SETTINGS, AABB::extents, FBM_TEXTURE, Framebuffer::fbo, find_animation(), FONTS, frame_time, GBUFFER_RESOLVE_FBO, GLOBALS, GPU_upload_ui_elements(), GVEL, Framebuffer::h, HISTORY_TEXTURE, Mesh::hulls, GLTexture::i, Image::i, Globals::images, LightmapData::islands, Skeleton::left_hip_pos, SceneData::lighting_probe_volumes, SceneData::lightmap_data, Globals::lights, Uniform::location, EditorSettings::LUT, MAIN_FBO, main_queries, MAIN_RESOLVE_FBO, make_ortho(), master_frame, MAX_AUDIO_EMITTERS, MAX_UI_ELEMENTS, EditorSettings::MBLUR, Player::mesh, EditorSettings::mesh_node_menu_open, Globals::mesh_nodes, Globals::meshes, EditorSettings::MSAA, EditorSettings::NOISE, Skeleton::p_left, Skeleton::p_right, perm(), play_animation(), player, AudioEmitter::pos, AudioPortal::pos, DebugVertex::pos, Light::pos, POSTPROCESS_SHADER, PP_ACES, PP_BLOOM, PP_DOF, EditorSettings::pp_dview, PP_LUT, PP_MBLUR, PP_NOISE, PP_SHADER_VERSIONS, PPDVIEW_DEFAULT, ShaderProgram::program, Skeleton::q_left, Skeleton::q_right, SceneData::reflection_probes, render(), RENDER_FENCE, EditorSettings::render_framerate_target, RENDER_HEIGHT, render_probe_volume(), render_to_cubemap_face(), RENDER_WIDTH, Light::rgb, Skeleton::right_hip_pos, EditorSettings::rotation_axis, Globals::scene_data, SCREEN_HEIGHT, SCREEN_WIDTH, EditorSettings::selected_mn_id, Player::skeleton, SSR_FBO, EditorSettings::TAA, TAA_FBO, TEXT_EBO, TEXT_FBO, TEXT_INDEX_COUNT, TEXT_SHADER, TEXT_VAO, TEXT_VBO, Font::texture, Framebuffer::texture, LightmapData::texture_id, time, MeshNode::translation, ui_element_count, UI_SHADER, UI_VAO, ShaderProgram::uniforms, vec3_add(), vec3_sub(), Framebuffer::w, WIREFRAME_SHADER, EditorSettings::wireframe_toggled, WIREFRAME_VAO, and WIREFRAME_VBO.