Good looking blur, need some fixes, but framerates takes a huge hit.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#version 430
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
uniform int MipMapLevel;
|
||||
uniform bool Horizontal;
|
||||
uniform vec2 ScreenSize[5];
|
||||
|
||||
layout (binding = 0) uniform sampler2D Texture;
|
||||
|
||||
in VertexData{
|
||||
vec2 TextureCoordinate;
|
||||
}Input;
|
||||
|
||||
out vec4 fragmentColor;
|
||||
|
||||
uniform float offset[3] = float[]( 0.0, 1.3846153846, 3.2307692308 );
|
||||
uniform float weight[5] = float[]( 0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162 );
|
||||
|
||||
void main()
|
||||
{
|
||||
//vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
|
||||
vec3 result = textureLod(Texture, vec2(gl_FragCoord)/ScreenSize[0], MipMapLevel ).rgb * weight[0];
|
||||
|
||||
if(Horizontal) {
|
||||
for( int i = 1; i<3; i++) {
|
||||
result += textureLod( Texture, Input.TextureCoordinate + vec2(offset[i], 0.0), MipMapLevel ).rgb * weight[i];
|
||||
result += textureLod( Texture, Input.TextureCoordinate - vec2(offset[i], 0.0), MipMapLevel ).rgb * weight[i];
|
||||
}
|
||||
} else {
|
||||
for( int i = 1; i<3; i++) {
|
||||
result += textureLod( Texture, Input.TextureCoordinate + vec2(0.0, offset[i]), MipMapLevel ).rgb * weight[i];
|
||||
result += textureLod( Texture, Input.TextureCoordinate - vec2(0.0, offset[i]), MipMapLevel ).rgb * weight[i];
|
||||
}
|
||||
}
|
||||
fragmentColor = vec4(result, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#version 430
|
||||
|
||||
layout (location = 0) in vec3 Position;
|
||||
|
||||
out VertexData{
|
||||
vec2 TextureCoordinate;
|
||||
}Output;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(Position, 1.0);
|
||||
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#version 430
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
uniform int MipMapLevel;
|
||||
layout (binding = 0) uniform sampler2D Texture;
|
||||
|
||||
in VertexData{
|
||||
@@ -14,11 +15,14 @@ uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.01
|
||||
void main()
|
||||
{
|
||||
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
|
||||
vec3 result = texture(Texture, Input.TextureCoordinate).rgb * weight[0];
|
||||
vec3 result = textureLod(Texture, Input.TextureCoordinate, MipMapLevel).rgb * weight[0];
|
||||
//vec3 result = texture(Texture, Input.TextureCoordinate).rgb * weight[0];
|
||||
|
||||
for(int i = 1; i < 5; ++i) {
|
||||
result += texture(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
||||
result += texture(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
||||
result += textureLod(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0), MipMapLevel).rgb * weight[i];
|
||||
result += textureLod(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0), MipMapLevel).rgb * weight[i];
|
||||
//result += texture(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
||||
//result += texture(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
||||
}
|
||||
fragmentColor = vec4(result, 1.0);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#version 430
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
uniform int MipMapLevel;
|
||||
layout (binding = 0) uniform sampler2D Texture;
|
||||
|
||||
in VertexData{
|
||||
@@ -14,11 +15,14 @@ uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.01
|
||||
void main()
|
||||
{
|
||||
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
|
||||
vec3 result = texture(Texture, Input.TextureCoordinate).rgb * weight[0];
|
||||
//vec3 result = texture(Texture, Input.TextureCoordinate).rgb * weight[0];
|
||||
vec3 result = textureLod(Texture, Input.TextureCoordinate, MipMapLevel).rgb * weight[0];
|
||||
|
||||
for(int i = 1; i < 5; ++i) {
|
||||
result += texture(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
||||
result += texture(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
||||
result += textureLod(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i), MipMapLevel).rgb * weight[i];
|
||||
result += textureLod(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i), MipMapLevel).rgb * weight[i];
|
||||
//result += texture(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
||||
//result += texture(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
||||
}
|
||||
fragmentColor = vec4(result, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#version 430
|
||||
|
||||
layout (binding = 0) uniform sampler2D Texture0;
|
||||
layout (binding = 1) uniform sampler2D Texture1;
|
||||
|
||||
in VertexData{
|
||||
vec2 TextureCoordinate;
|
||||
}Input;
|
||||
|
||||
out vec4 fragmentColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texel0 = texture(Texture0, Input.TextureCoordinate);
|
||||
vec4 texel1 = texture(Texture1, Input.TextureCoordinate);
|
||||
|
||||
fragmentColor = texel0 + texel1;
|
||||
//fragmentColor = vec4(1,0.5,0.7,1);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#version 430
|
||||
|
||||
layout (location = 0) in vec3 Position;
|
||||
|
||||
out VertexData{
|
||||
vec2 TextureCoordinate;
|
||||
}Output;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(Position, 1.0);
|
||||
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
|
||||
}
|
||||
Reference in New Issue
Block a user