summaryrefslogtreecommitdiffhomepage
path: root/shaders
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-08-24 15:48:51 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-08-24 15:48:51 +0200
commit5e0e9a76a9c683768b035ddaa51fec23bdce7484 (patch)
treefb1296b6fb7b6b275e00a56011b701e8b8587ca5 /shaders
parentcf4d036d530e5e3fe1c1b23f734479b4f56e3eae (diff)
a
Diffstat (limited to 'shaders')
-rw-r--r--shaders/lightmap.cpp10
-rw-r--r--shaders/lightmap.frag4
-rw-r--r--shaders/lightmap.vert2
3 files changed, 8 insertions, 8 deletions
diff --git a/shaders/lightmap.cpp b/shaders/lightmap.cpp
index f10e1f91..3a516d45 100644
--- a/shaders/lightmap.cpp
+++ b/shaders/lightmap.cpp
@@ -29,10 +29,10 @@ constexpr auto neighbor_count = lightmap_shader::neighbor_count;
constexpr auto chunk_size = TILE_SIZE2 * TILE_MAX_DIM;
constexpr auto chunk_offset = TILE_SIZE2/2;
-constexpr auto image_size = iTILE_SIZE2 * TILE_MAX_DIM * neighbor_count;
+constexpr auto image_size = TILE_SIZE2 * TILE_MAX_DIM * neighbor_count;
constexpr auto clip_start = Vector2{-1, -1};
-constexpr auto clip_scale = 2/(chunk_size * neighbor_count);
+constexpr auto clip_scale = 2/image_size;
constexpr auto shadow_wall_depth = 4.f;
@@ -176,7 +176,7 @@ lightmap_shader::lightmap_shader()
attachShaders({vert, frag});
CORRADE_INTERNAL_ASSERT_OUTPUT(link());
- framebuffer = make_framebuffer(image_size);
+ framebuffer = make_framebuffer(Vector2i(image_size));
auto blend_vertexes = std::array<Vector3, 4>{{
{ 1, -1, 0 }, /* 3--1 1 */
@@ -237,7 +237,7 @@ void lightmap_shader::add_light(Vector2 neighbor_offset, const light_s& light)
framebuffer.fb.clearColor(0, Color4{0, 0, 0, 1});
setUniform(LightColorUniform, color * alpha);
- setUniform(SizeUniform, 1 / (chunk_size * neighbor_count));
+ setUniform(SizeUniform, 1 / image_size);
setUniform(CenterFragcoordUniform, center_fragcoord);
setUniform(CenterClipUniform, center_clip);
setUniform(RangeUniform, I);
@@ -261,7 +261,7 @@ void lightmap_shader::add_light(Vector2 neighbor_offset, const light_s& light)
void lightmap_shader::bind()
{
framebuffer.fb.bind();
- GL::Renderer::setScissor({{}, image_size});
+ GL::Renderer::setScissor({{}, Vector2i(image_size)});
framebuffer.fb.clearColor(1, Color4{0, 0, 0, 1});
using BlendFunction = Magnum::GL::Renderer::BlendFunction;
GL::Renderer::setBlendFunction(0, BlendFunction::One, BlendFunction::Zero);
diff --git a/shaders/lightmap.frag b/shaders/lightmap.frag
index deaaa894..f6ca40a2 100644
--- a/shaders/lightmap.frag
+++ b/shaders/lightmap.frag
@@ -2,7 +2,7 @@ precision mediump float;
layout (location = 2) uniform sampler2D sampler0;
layout (location = 3) uniform vec3 light_color;
-layout (location = 4) uniform vec2 size;
+layout (location = 4) uniform vec2 scale;
layout (location = 5) uniform vec2 center_fragcoord;
layout (location = 6) uniform vec2 center_clip;
layout (location = 7) uniform float range;
@@ -32,7 +32,7 @@ void main() {
}
else if (mode == 2) // blend
{
- color1 = texture(sampler0, gl_FragCoord.xy * size);
+ color1 = texture(sampler0, gl_FragCoord.xy * scale);
}
else if (mode == 0) // shadows
{
diff --git a/shaders/lightmap.vert b/shaders/lightmap.vert
index aceaf4d5..24f07736 100644
--- a/shaders/lightmap.vert
+++ b/shaders/lightmap.vert
@@ -2,7 +2,7 @@ precision mediump float;
layout (location = 2) uniform sampler2D sampler0;
layout (location = 3) uniform vec3 light_color;
-layout (location = 4) uniform vec2 size;
+layout (location = 4) uniform vec2 scale;
layout (location = 5) uniform vec2 center_fragcoord;
layout (location = 6) uniform vec2 center_clip;
layout (location = 7) uniform float range;