cgv
Loading...
Searching...
No Matches
a_buffer.h
1#pragma once
2
3#include <cgv/render/shader_program.h>
4#include <cgv/render/texture.h>
5#include <cgv/render/vertex_buffer.h>
6#include <cgv_gl/gl/gl.h>
7
8#include "gl/lib_begin.h"
9
10namespace cgv {
11 namespace render {
12
15class CGV_API a_buffer
16{
17 shader_compile_options prog_options;
18 shader_compile_options last_prog_options;
19 bool init_frame_called;
20protected:
31 int head_pointers_binding_point;
32 int nodes_binding_point;
33 // GPU objects
34 shader_program clear_ssbo_prog;
35 shader_program a_buffer_prog;
36
37 void ensure_buffers(context& ctx);
38
39 void update_shader_program_options(shader_compile_options& options, bool include_binding_points);
40public:
46 float z_fight_removal_exp = -5.0f;
50 a_buffer(unsigned _fragments_per_pixel = 32, unsigned _nodes_per_pixel = 64, int _depth_tex_unit = 0,
51 int _node_counter_binding_point = 0, int _head_pointers_binding_point = 0, int _nodes_binding_point = 1);
57 bool init(context& ctx);
59 void destruct(context& ctx);
61 void init_frame(context& ctx);
63 void update_shader_program_options(shader_compile_options& options);
65
70 bool enable(context& ctx, shader_program& prog, int tex_unit = -1);
72 void disable(context& ctx, size_t* out_node_count = nullptr);
74 void finish_frame(context& ctx);
75
76 int& ref_depth_tex_unit() { return depth_tex_unit; }
77 int& ref_node_counter_binding_point () { return node_counter_binding_point ; }
78 int& ref_head_pointers_binding_point() { return head_pointers_binding_point ; }
79 int& ref_nodes_binding_point () { return nodes_binding_point ; }
80};
81 }
82}
83
84#include <cgv/config/lib_end.h>
float z_fight_removal_exp
set thickness of fragments to 10^z_fight_removal_exp where this is measured in scaling of depth buffe...
Definition a_buffer.h:46
unsigned nodes_per_pixel
to be reserved number of fragment nodes per pixel (changes are applied when in init_frame() function)
Definition a_buffer.h:55
int z_fight_removal
whether to use volumetric blending of thickened fragments
Definition a_buffer.h:44
unsigned fragments_per_pixel
to be handled fragments per pixel (changes are applied when in init_frame() function)
Definition a_buffer.h:53
a_buffer(unsigned _fragments_per_pixel=32, unsigned _nodes_per_pixel=64, int _depth_tex_unit=0, int _node_counter_binding_point=0, int _head_pointers_binding_point=0, int _nodes_binding_point=1)
construct and configure
Definition a_buffer.cxx:29
bool pre_multiply_opacity
whether to assume that fragment color is already multiplied with opacity
Definition a_buffer.h:42
void destruct(context &ctx)
destruct all render objects
Definition a_buffer.cxx:55
bool init(context &ctx)
construct internally used programs
Definition a_buffer.cxx:45
unsigned z_fight_window_width
size of disambiguation windows
Definition a_buffer.h:48
texture depth_tex
Depth texture used to emulate depth buffer.
Definition a_buffer.h:22
bool enable(context &ctx, shader_program &prog, int tex_unit=-1)
Enable writing fragments to a_buffer with provided program.
Definition a_buffer.cxx:102
void disable(context &ctx, size_t *out_node_count=nullptr)
finish writing fragments to a_buffer and return current number of nodes in node buffer
Definition a_buffer.cxx:134
cgv::render::vertex_buffer node_counter_buffer
Buffers used to store per pixel frament lists.
Definition a_buffer.h:24
int node_counter_binding_point
Buffer binding point indices.
Definition a_buffer.h:30
void init_frame(context &ctx)
ensure that a_buffer size corresponds to context size
Definition a_buffer.cxx:64
int depth_tex_unit
Default texture unit used for depth texture.
Definition a_buffer.h:28
void finish_frame(context &ctx)
per fragment sort nodes and blend over current framebuffer
Definition a_buffer.cxx:150
base class for all drawables, which is independent of the used rendering API.
Definition context.h:670
Stores preprocessor options used for conditionally compiling shader programs.
Definition shader_code.h:73
a shader program combines several shader code fragments to a complete definition of the shading pipel...
the texture class encapsulates all functionality independent of the rendering api.
Definition texture.h:15
a vertex buffer is an unstructured memory block on the GPU.
namespace for api independent GPU programming
@ VBT_ATOMIC_COUNTER
The buffer contains atomic counter and will be bound to GL_ATOMIC_COUNTER_BUFFER.
Definition context.h:482
@ VBT_STORAGE
The buffer contains arbitrary data and will be bound to GL_SHADER_STORAGE_BUFFER.
Definition context.h:481
this header is dependency free
Definition print.h:11