Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
justanothercell committed Jun 7, 2023
2 parents 2f103ff + e0059ef commit 86078cc
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions mods/world/assets/world-shader.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,34 @@ void main() {
#[fragment]
#version 450 core

//#define BLOOM_STRENGTH 5

in vec2 v_FrameCoord;

uniform sampler2D u_Frame;
uniform sampler2D u_LightMap;

#ifdef BLOOM_STRENGTH
uniform float u_BloomWeight[BLOOM_STRENGTH] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
#endif

layout (location = 0) out vec4 r_Color;

void main() {
vec4 glowing = texture(u_LightMap, v_FrameCoord);

r_Color = texture(u_Frame, v_FrameCoord) + glowing;
#ifdef BLOOM_STRENGTH
vec3 glowing = texture(u_LightMap, v_FrameCoord).rgb * u_BloomWeight[0];
vec2 tex_offset = 1.0 / vec2(1920, 1080);

for(int i = 1; i < BLOOM_STRENGTH; i++)
{
glowing += texture(u_LightMap, v_FrameCoord + vec2(tex_offset.x * i, 0.0)).rgb * u_BloomWeight[i];
glowing += texture(u_LightMap, v_FrameCoord - vec2(tex_offset.x * i, 0.0)).rgb * u_BloomWeight[i];
glowing += texture(u_LightMap, v_FrameCoord + vec2(0.0, tex_offset.y * i)).rgb * u_BloomWeight[i];
glowing += texture(u_LightMap, v_FrameCoord - vec2(0.0, tex_offset.y * i)).rgb * u_BloomWeight[i];
}
#else
vec3 glowing = texture(u_LightMap, v_FrameCoord).rgb * 1.3;
#endif

r_Color = texture(u_Frame, v_FrameCoord) + vec4(glowing, 0.0);
}

0 comments on commit 86078cc

Please sign in to comment.