summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-08-22 07:38:46 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-08-22 07:40:06 +0200
commit0fbb841c2dd5c76de867f47a9cf6d1d0fc83d9ee (patch)
treec266fd65fc27bda5de453fce26feaf16a85fe7ff
parent4c91679a1cdbb1804f1ddd570e020269c4a59524 (diff)
wip
-rw-r--r--editor/imgui.cpp2
-rw-r--r--main/draw.cpp2
-rw-r--r--main/main-impl.hpp4
-rw-r--r--shaders/lightmap.cpp2
-rw-r--r--shaders/lightmap.hpp3
-rw-r--r--shaders/shader.frag2
6 files changed, 11 insertions, 4 deletions
diff --git a/editor/imgui.cpp b/editor/imgui.cpp
index 399a2e69..b4b17c88 100644
--- a/editor/imgui.cpp
+++ b/editor/imgui.cpp
@@ -204,6 +204,7 @@ void app::draw_light_info()
void app::draw_lightmap_test()
{
+#if 0
fm_debug_assert(_tested_light != 0);
constexpr auto preview_size = ImVec2{512, 512};
@@ -242,6 +243,7 @@ void app::draw_lightmap_test()
ImGui::End();
if (!is_open)
_tested_light = 0;
+#endif
}
static constexpr auto SCENERY_POPUP_NAME = "##scenery-popup"_s;
diff --git a/main/draw.cpp b/main/draw.cpp
index 78cd1906..b21bbc8a 100644
--- a/main/draw.cpp
+++ b/main/draw.cpp
@@ -123,6 +123,7 @@ auto main_impl::get_draw_bounds() const noexcept -> draw_bounds
return {x0, x1, y0, y1};
}
+#if 0
bool main_impl::draw_lights_for_chunk(chunk& c, Vector2b neighbor_offset) noexcept
{
bool ret = false;
@@ -166,6 +167,7 @@ bool main_impl::draw_lights(chunk& c, const std::array<chunk*, 8>& ns) noexcept
_lightmap_shader.end_accum();
return ret;
}
+#endif
void main_impl::draw_world() noexcept
{
diff --git a/main/main-impl.hpp b/main/main-impl.hpp
index a6457524..2afac162 100644
--- a/main/main-impl.hpp
+++ b/main/main-impl.hpp
@@ -121,8 +121,8 @@ private:
void recalc_viewport(Vector2i fb_size, Vector2i win_size) noexcept;
void draw_world() noexcept;
- bool draw_lights(chunk& c, const std::array<chunk*, 8>& neighbors) noexcept;
- bool draw_lights_for_chunk(chunk& c, Vector2b neighbor_offset) noexcept;
+ //bool draw_lights(chunk& c, const std::array<chunk*, 8>& neighbors) noexcept;
+ //bool draw_lights_for_chunk(chunk& c, Vector2b neighbor_offset) noexcept;
draw_bounds get_draw_bounds() const noexcept override;
diff --git a/shaders/lightmap.cpp b/shaders/lightmap.cpp
index d857f3ba..ddfa2f46 100644
--- a/shaders/lightmap.cpp
+++ b/shaders/lightmap.cpp
@@ -204,7 +204,7 @@ lightmap_shader::lightmap_shader()
setUniform(LightColorUniform, Color3{1, 1, 1});
setUniform(SizeUniform, Vector2(1 / (chunk_size * max_neighbors)));
setUniform(CenterFragcoordUniform, Vector2(0, 0));
- setUniform(CenterClipUniform, Vector2(-1, 1));
+ setUniform(CenterClipUniform, Vector2(-1, -1));
setUniform(IntensityUniform, 1.f);
setUniform(ModeUniform, DrawLightmapMode);
setUniform(FalloffUniform, (uint32_t)light_falloff::constant);
diff --git a/shaders/lightmap.hpp b/shaders/lightmap.hpp
index e48d4b5d..a5564a9b 100644
--- a/shaders/lightmap.hpp
+++ b/shaders/lightmap.hpp
@@ -134,7 +134,8 @@ private:
//void clear_accum();
static std::array<UnsignedShort, 6> quad_indexes(size_t N);
- GL::Buffer vertex_buf{NoCreate}, index_buf{NoCreate}; // set to {NoCreate} on capacity change
+ // todo use setData() and a boolean flag on capacity change
+ GL::Buffer vertex_buf{NoCreate}, index_buf{NoCreate};
Array<std::array<Vector3, 4>> vertexes; // todo make a contiguous allocation
Array<std::array<UnsignedShort, 6>> indexes;
size_t count = 0, capacity = 0;
diff --git a/shaders/shader.frag b/shaders/shader.frag
index faea53fb..98c18e10 100644
--- a/shaders/shader.frag
+++ b/shaders/shader.frag
@@ -12,6 +12,8 @@ layout (location = 1) noperspective in vec2 frag_light_coord;
out vec4 color;
//layout (depth_greater) out float gl_FragDepth;
+layout(pixel_center_integer) in vec4 gl_FragCoord;
+
void main() {
vec4 light = tint;
if (enable_lightmap)