This commit is contained in:
Branimir Karadžić 2018-09-20 15:49:56 -07:00
Родитель 2066d36774
Коммит fd65b5a36e
6 изменённых файлов: 39 добавлений и 34 удалений

Просмотреть файл

@ -7,16 +7,14 @@ $input v_wpos, v_view, v_normal, v_tangent, v_bitangent, v_texcoord0
#include "../common/common.sh"
uniform vec4 u_color;
void main()
{
// the albedo-buffer of the g-buffer.
// the albedo-buffer of the g-buffer.
gl_FragData[0] = u_color;
// for convenience, we also output the same color, to the first texture of the texture chain used for bloom.
// this color will now be bloomed, in the following passes.
gl_FragData[1] = u_color;
}

Просмотреть файл

@ -13,12 +13,12 @@ SAMPLER2D(s_light, 1);
void main()
{
vec3 hdrColor = texture2D(s_albedo, v_texcoord0).rgb;
hdrColor += texture2D(s_light, v_texcoord0).rgb;
// instead of some fancy tonemapping operator, we just clamp it, to keep it simple.
vec3 finalColor = clamp(hdrColor, 0.0, 1.0);
float g = 2.2;
gl_FragColor = vec4(pow(finalColor, vec3(1.0 / g, 1.0 / g, 1.0 / g) ), 1.0);
gl_FragColor = vec4(pow(finalColor, vec3(1.0 / g, 1.0 / g, 1.0 / g) ), 1.0);
}

Просмотреть файл

@ -14,29 +14,29 @@ uniform vec4 u_pixelSize;
void main()
{
vec2 halfpixel = 0.5 * vec2(u_pixelSize.x, u_pixelSize.y);
vec2 oneepixel = 1.0 * vec2(u_pixelSize.x, u_pixelSize.y);
vec2 halfpixel = 0.5 * vec2(u_pixelSize.x, u_pixelSize.y);
vec2 oneepixel = 1.0 * vec2(u_pixelSize.x, u_pixelSize.y);
vec2 uv = v_texcoord0.xy;
vec4 sum = vec4(0.0, 0.0, 0.0, 0.0);
sum += (4.0/32.0) * texture2D(s_tex, uv).rgba;
sum += (4.0/32.0) * texture2D(s_tex, uv + vec2(-halfpixel.x, -halfpixel.y));
sum += (4.0/32.0) * texture2D(s_tex, uv + vec2(+halfpixel.x, +halfpixel.y));
sum += (4.0/32.0) * texture2D(s_tex, uv + vec2(+halfpixel.x, -halfpixel.y));
sum += (4.0/32.0) * texture2D(s_tex, uv + vec2(-halfpixel.x, +halfpixel.y) );
sum += (2.0/32.0) * texture2D(s_tex, uv + vec2(+oneepixel.x, 0.0));
sum += (2.0/32.0) * texture2D(s_tex, uv + vec2(-oneepixel.x, 0.0));
sum += (2.0/32.0) * texture2D(s_tex, uv + vec2(0.0, +oneepixel.y));
sum += (2.0/32.0) * texture2D(s_tex, uv + vec2(0.0, -oneepixel.y));
sum += (1.0/32.0) * texture2D(s_tex, uv + vec2(+oneepixel.x, +oneepixel.y));
sum += (1.0/32.0) * texture2D(s_tex, uv + vec2(-oneepixel.x, +oneepixel.y));
sum += (1.0/32.0) * texture2D(s_tex, uv + vec2(+oneepixel.x, -oneepixel.y));
sum += (1.0/32.0) * texture2D(s_tex, uv + vec2(-oneepixel.x, -oneepixel.y));
sum += (4.0/32.0) * texture2D(s_tex, uv + vec2(-halfpixel.x, -halfpixel.y) );
sum += (4.0/32.0) * texture2D(s_tex, uv + vec2(+halfpixel.x, +halfpixel.y) );
sum += (4.0/32.0) * texture2D(s_tex, uv + vec2(+halfpixel.x, -halfpixel.y) );
sum += (4.0/32.0) * texture2D(s_tex, uv + vec2(-halfpixel.x, +halfpixel.y) );
sum += (2.0/32.0) * texture2D(s_tex, uv + vec2(+oneepixel.x, 0.0) );
sum += (2.0/32.0) * texture2D(s_tex, uv + vec2(-oneepixel.x, 0.0) );
sum += (2.0/32.0) * texture2D(s_tex, uv + vec2(0.0, +oneepixel.y) );
sum += (2.0/32.0) * texture2D(s_tex, uv + vec2(0.0, -oneepixel.y) );
sum += (1.0/32.0) * texture2D(s_tex, uv + vec2(+oneepixel.x, +oneepixel.y) );
sum += (1.0/32.0) * texture2D(s_tex, uv + vec2(-oneepixel.x, +oneepixel.y) );
sum += (1.0/32.0) * texture2D(s_tex, uv + vec2(+oneepixel.x, -oneepixel.y) );
sum += (1.0/32.0) * texture2D(s_tex, uv + vec2(-oneepixel.x, -oneepixel.y) );
gl_FragColor.xyzw = sum;
}

Просмотреть файл

@ -1,9 +1,13 @@
$input v_texcoord0
/*
* Copyright 2018 Eric Arnebäck. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
SAMPLER2D(s_tex, 0);
//SAMPLER2D(s_target_tex, 1);
uniform vec4 u_pixelSize;
uniform vec4 u_intensity;
@ -12,20 +16,20 @@ void main()
{
vec2 halfpixel = 1.0 * vec2(u_pixelSize.x, u_pixelSize.y);
vec2 uv = v_texcoord0.xy;
vec4 sum = vec4(0.0, 0.0, 0.0, 0.0);
sum += (2.0 / 16.0) * texture2D(s_tex, uv + vec2(-halfpixel.x , 0.0));
sum += (2.0 / 16.0) * texture2D(s_tex, uv + vec2(0.0, halfpixel.y));
sum += (2.0 / 16.0) * texture2D(s_tex, uv + vec2(halfpixel.x , 0.0));
sum += (2.0 / 16.0) * texture2D(s_tex, uv + vec2(0.0, -halfpixel.y));
sum += (1.0 / 16.0) * texture2D(s_tex, uv + vec2(-halfpixel.x, -halfpixel.y));
sum += (1.0 / 16.0) * texture2D(s_tex, uv + vec2(-halfpixel.x, halfpixel.y));
sum += (1.0 / 16.0) * texture2D(s_tex, uv + vec2(halfpixel.x, -halfpixel.y));
sum += (1.0 / 16.0) * texture2D(s_tex, uv + vec2(halfpixel.x, halfpixel.y));
sum += (4.0 / 16.0) * texture2D(s_tex, uv);
gl_FragColor.xyzw = u_intensity.x * sum;
}

Просмотреть файл

@ -6,13 +6,12 @@ $output v_wpos, v_view, v_normal, v_tangent, v_bitangent, v_texcoord0
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"
void main()
{
vec3 wpos = mul(u_model[0], vec4(a_position, 1.0) ).xyz;
gl_Position = mul(u_viewProj, vec4(wpos, 1.0) );
v_texcoord0 = a_texcoord0;
}

Просмотреть файл

@ -1,6 +1,10 @@
$input a_position, a_texcoord0
$output v_texcoord0
/*
* Copyright 2018 Eric Arnebäck. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "../common/common.sh"