Add blurring of lightmap (and refactoring)
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#version 430 core
|
||||
in vec2 vTexPos;
|
||||
out vec4 fColor;
|
||||
|
||||
uniform vec2 winSize;
|
||||
uniform sampler2D screenTexture;
|
||||
|
||||
const float hOff = 1.0 / winSize.x;
|
||||
const float vOff = 1.0 / winSize.y;
|
||||
//const float verOff = 1.0 / 600.0;
|
||||
|
||||
//const float kernel[9] = float[](
|
||||
// 0.025,0.05,0.1, 0.2, 0.25, 0.2,0.1, 0.05, 0.025
|
||||
// 0.1,0.1,0.1,0.1,0.2,0.1,0.1,0.1,0.1
|
||||
// );
|
||||
const float kernel[5] = float[](
|
||||
0.175,
|
||||
0.175,0.3,0.175,
|
||||
0.175
|
||||
);
|
||||
const float off[5] = float[](
|
||||
vOff,
|
||||
-hOff,0.0,hOff,
|
||||
-vOff
|
||||
);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sampleTex[5];
|
||||
for(int i=0; i<5; i++)
|
||||
{
|
||||
sampleTex[i] = vec4(texture(screenTexture, vTexPos + off[i]));
|
||||
}
|
||||
vec4 col = vec4(0,0,0,0);
|
||||
for (int i = 0; i < 5; i++)
|
||||
col += sampleTex[i] * kernel[i];
|
||||
fColor = col;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#version 430 core
|
||||
in vec2 vTexPos;
|
||||
out vec4 fColor;
|
||||
|
||||
uniform vec2 winSize;
|
||||
uniform sampler2D screenTexture;
|
||||
|
||||
const float hOff = 2.0 / 600;
|
||||
const float vOff = 2.0 / 600;
|
||||
const float frac = 1.0 / 9;
|
||||
const vec2 off[9] = vec2[](
|
||||
vec2( vOff,hOff )
|
||||
, vec2( vOff,0.0 )
|
||||
, vec2( vOff,-hOff )
|
||||
, vec2( 0.0,hOff )
|
||||
, vec2( 0.0,0.0 )
|
||||
, vec2( 0.0,-hOff )
|
||||
, vec2( -vOff,hOff )
|
||||
, vec2( -vOff,0.0 )
|
||||
, vec2( -vOff,-hOff )
|
||||
);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sampleTex[9];
|
||||
for(int i=0; i<9; i++)
|
||||
{
|
||||
sampleTex[i] = vec4(texture(screenTexture, vTexPos + off[i]));
|
||||
}
|
||||
vec4 col = vec4(0,0,0,0);
|
||||
for (int i = 0; i < 9; i++)
|
||||
col += sampleTex[i] * frac;
|
||||
fColor = col;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#version 430 core
|
||||
layout (location = 0) in vec2 pos;
|
||||
layout (location = 1) in vec2 texPos;
|
||||
out vec2 vTexPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(pos,0,1);
|
||||
vTexPos = texPos;
|
||||
}
|
||||
@@ -6,11 +6,5 @@ uniform sampler2D screenTexture;
|
||||
|
||||
void main()
|
||||
{
|
||||
// vec4 col = vec4(0,0,0,0);
|
||||
// for (int i = 0; i < 9; i++)
|
||||
// {
|
||||
// col +=
|
||||
// }
|
||||
fColor = texture(screenTexture, vTexPos);
|
||||
// fColor = vec4(1,1,1,0);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#version 430 core
|
||||
in vec2 vTexPos;
|
||||
out vec4 fColor;
|
||||
|
||||
uniform vec2 winSize;
|
||||
uniform sampler2D screenTexture;
|
||||
|
||||
const float horOff = 1.0 / winSize.x;
|
||||
//const float verOff = 1.0 / 600.0;
|
||||
|
||||
//const float kernel[9] = float[](
|
||||
// 0.025,0.05,0.1, 0.2, 0.25, 0.2,0.1, 0.05, 0.025
|
||||
// 0.1,0.1,0.1,0.1,0.2,0.1,0.1,0.1,0.1
|
||||
// );
|
||||
const float kernel[3] = float[](
|
||||
0.25,0.5, 0.25
|
||||
);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 sampleTex[3];
|
||||
for(int i=0; i<3; i++)
|
||||
{
|
||||
sampleTex[i] = vec4(texture(screenTexture, vTexPos + vec2((i-1)*horOff,0)));
|
||||
}
|
||||
vec4 col = vec4(0,0,0,0);
|
||||
for (int i = 0; i < 3; i++)
|
||||
col += sampleTex[i] * kernel[i];
|
||||
fColor = col;
|
||||
}
|
||||
Reference in New Issue
Block a user