summaryrefslogtreecommitdiffhomepage
path: root/shaders
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-08-23 03:51:59 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-08-23 03:51:59 +0200
commit8e4781b3103f68965b2aba4e914f7c3281ccbc59 (patch)
treefe140971aa60c4a7d018c3c3f5cd7a9e9dbebf24 /shaders
parente659a6f6edc857fa424b1aafe319f1a9be74a840 (diff)
ok so shadows aren't very slow anymore
Diffstat (limited to 'shaders')
-rw-r--r--shaders/lightmap.cpp7
-rw-r--r--shaders/lightmap.frag4
-rw-r--r--shaders/lightmap.vert13
3 files changed, 14 insertions, 10 deletions
diff --git a/shaders/lightmap.cpp b/shaders/lightmap.cpp
index 186be81a..2f61e846 100644
--- a/shaders/lightmap.cpp
+++ b/shaders/lightmap.cpp
@@ -23,6 +23,7 @@ namespace floormat {
namespace {
+// todo add back drawing an 8x8 grid
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;
@@ -265,13 +266,15 @@ void lightmap_shader::add_light(const light_s& light)
setUniform(ModeUniform, DrawLightmapMode);
AbstractShaderProgram::draw(blend_mesh);
-#if 0
+#if 1
+ setUniform(ModeUniform, DrawShadowsMode);
setUniform(LightColorUniform, Color3{0, 0, 0});
+ setUniform(IntensityUniform, 1 );
fm_assert(occlusion_mesh.id());
auto mesh_view = GL::MeshView{occlusion_mesh};
mesh_view.setCount((int32_t)count*6);
- AbstractShaderProgram::draw(mesh_view);
mesh_view.setIndexRange(0, 0, uint32_t(count*6 - 1));
+ AbstractShaderProgram::draw(mesh_view);
#endif
#if 0
diff --git a/shaders/lightmap.frag b/shaders/lightmap.frag
index 1f8c5e01..4922db8e 100644
--- a/shaders/lightmap.frag
+++ b/shaders/lightmap.frag
@@ -33,4 +33,8 @@ void main() {
{
color = texture(sampler, gl_FragCoord.xy * size);
}
+ else if (mode == 0) // shadows
+ {
+ color = vec4(0, 0, 0, 1);
+ }
}
diff --git a/shaders/lightmap.vert b/shaders/lightmap.vert
index 900038c4..1f49404f 100644
--- a/shaders/lightmap.vert
+++ b/shaders/lightmap.vert
@@ -16,15 +16,12 @@ layout (location = 0) in vec3 position;
void main() {
vec2 pos = position.xy;
- if (mode == 0)
+ vec2 dir = pos - center_clip;
+ float len = length(dir);
+ if (len > 1e-6)
{
- vec2 dir = pos - center_clip;
- float len = length(dir);
- if (len > 1e-6)
- {
- vec2 dir_norm = dir * (1/len);
- pos += dir_norm * position.z * 4;
- }
+ vec2 dir_norm = dir * (1/len);
+ pos += dir_norm * position.z * 4;
}
gl_Position = vec4(pos, 0, 1);
}