summaryrefslogtreecommitdiffhomepage
path: root/shaders
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-06-10 19:17:21 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-06-10 19:17:21 +0200
commitaa5089b36453026ad33ce3cc3c11210774a45c84 (patch)
treefd54a9c53ea957d5dd34c746de1c7e09afae73a3 /shaders
parenta0152f2c253dbf3c2c23d83a261d89e97310b430 (diff)
wip
Diffstat (limited to 'shaders')
-rw-r--r--shaders/lightmap.cpp7
-rw-r--r--shaders/lightmap.frag4
2 files changed, 7 insertions, 4 deletions
diff --git a/shaders/lightmap.cpp b/shaders/lightmap.cpp
index 7fa76d69..bc61a434 100644
--- a/shaders/lightmap.cpp
+++ b/shaders/lightmap.cpp
@@ -116,12 +116,15 @@ void lightmap_shader::add_light(Vector2i neighbor_offset, const light_s& light)
I = 1;
break;
case light_falloff::linear:
- I = std::fmax(1.f, light.dist * tile_size);
+ I = light.dist * tile_size / 5;
break;
case light_falloff::quadratic:
- I = std::fmax(1.f, light.dist * tile_size * 100);
+ I = light.dist * tile_size * 100;
break;
}
+
+ I = std::fmax(1.f, I);
+
auto I_clip = I * tile_size;
auto center = light.center + chunk_offset + Vector2(neighbor_offset)*chunk_size;
auto center_clip = Vector2{center} * scale; // clip coordinate
diff --git a/shaders/lightmap.frag b/shaders/lightmap.frag
index d560dcc6..db1cf895 100644
--- a/shaders/lightmap.frag
+++ b/shaders/lightmap.frag
@@ -14,9 +14,9 @@ void main() {
//float dist = sqrt(tmp.x*tmp.x + tmp.y*tmp.y);
float A = 1;
if (falloff == 0) // linear
- A = 1 - min(1, dist / I);
+ A = I/(I + dist);
else if (falloff == 2) // quadratic
- A = I/(1 + I + dist*dist);
+ A = I/(I + dist*dist);
//I = sqrt(color_intensity.w*1.5)*16;
//dist = sqrt(tmp.x*tmp.x + tmp.y*tmp.y);
//float alpha = 1 - min(1, dist / I);