summaryrefslogtreecommitdiffhomepage
path: root/shaders/lightmap.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'shaders/lightmap.hpp')
-rw-r--r--shaders/lightmap.hpp45
1 files changed, 30 insertions, 15 deletions
diff --git a/shaders/lightmap.hpp b/shaders/lightmap.hpp
index 655534ff..f9f29156 100644
--- a/shaders/lightmap.hpp
+++ b/shaders/lightmap.hpp
@@ -39,41 +39,56 @@ struct lightmap_shader final : GL::AbstractShaderProgram
struct Framebuffer final {
GL::Framebuffer fb{NoCreate};
//GL::Renderbuffer depth{NoCreate};
- GL::Texture2D color{NoCreate};
+ GL::Texture2D scratch{NoCreate}, accum{NoCreate};
};
- void begin(Vector2i neighbor_offset, const light_s& light);
+ void begin_light(Vector2i neighbor_offset, const light_s& light);
void add_chunk(Vector2i neighbor_offset, chunk& c);
void add_entities(Vector2i neighbor_offset, chunk& c);
void add_geometry(Vector2i neighbor_offset, chunk& c);
void add_rect(Vector2i neighbor_offset, Vector2 min, Vector2 max);
void add_rect(Vector2i neighbor_offset, Pair<Vector2, Vector2> minmax);
- void end();
- GL::Texture2D& texture();
+ void finish_light_only();
+ void finish_and_blend_light();
+ GL::Texture2D& scratch_texture();
+ GL::Texture2D& accum_texture();
+ void begin_accum();
+ void end_accum();
private:
+ enum {
+ ColorIntensityUniform = 0,
+ CenterUniform = 1,
+ FalloffUniform = 2,
+ SizeUniform = 3,
+ ModeUniform = 4,
+ SamplerUniform = 5,
+ };
+
+ enum : Int {
+ TextureSampler = 1,
+ };
+
+ enum ShaderMode : uint32_t {
+ DrawLightmapMode = 1,
+ BlendLightmapMode = 2,
+ };
+
static Framebuffer make_framebuffer(Vector2i size);
GL::Mesh make_mesh();
void add_light(Vector2i neighbor_offset, const light_s& light);
- void flush_vertexes();
+ void flush_vertexes(ShaderMode mode);
void add_quad(const std::array<Vector2, 4>& quad);
void bind();
+ void clear_scratch();
void clear();
static std::array<UnsignedShort, 6> quad_indexes(size_t N);
static Vector2 project_vertex(Vector2 light, Vector2 vertex, Vector2 length);
- enum : int {
- ColorIntensityUniform = 0,
- CenterUniform = 1,
- FalloffUniform = 2,
- SizeUniform = 3,
- //DepthUniform = 4,
- };
-
- Framebuffer framebuffer, accum;
+ Framebuffer framebuffer;
Array<std::array<Vector2, 4>> _quads;
Array<std::array<UnsignedShort, 6>> _indexes;
- size_t _count = 0;
+ size_t _count = (size_t)-1;
GL::Buffer _vertex_buf{NoCreate}, _index_buf{NoCreate};
GL::Mesh _mesh{NoCreate};
Optional<Vector2> _light_center;