#pragma once #include "hd2d/GL.h" #include #include namespace hd2d { class ModelBatch; // Baked contact ambient occlusion on the ground under 3D scenery: a dark, // tight core at a tree trunk / bush / rock base plus a wide, soft canopy // shadow under tall models. Sampled by terrain, sprite and model shaders, so // grass tufts and bushes growing at a tree's foot darken too. Rebuild after // moving instances. class GroundOcclusion { public: GroundOcclusion() = default; GroundOcclusion(const GroundOcclusion&) = delete; GroundOcclusion& operator=(const GroundOcclusion&) = delete; ~GroundOcclusion(); // Covers the rectangle [min, max] (world xz). Uses every batch whose // `groundOcclusion` strength is > 0. void build(glm::vec2 min, glm::vec2 max, const std::vector& batches, int texelsPerUnit = 8); GLuint texture() const { return tex_; } glm::vec4 rect() const { return rect_; } // matches uGroundAO in common.glsl private: GLuint tex_ = 0; glm::vec4 rect_{0.0f}; }; } // namespace hd2d