Skip to content

Commit 46db482

Browse files
authored
[TPHD] Add new Bloom graphic pack (#642)
With the new bloom graphic pack you can simply choose a preset of the amount of bloom and brightness/post-processing inside the shadow land, or you can fine-tune it to your likings with the custom options. Thanks to @KoB-Kirito for making this dedicated bloom pack!
1 parent 2ddb628 commit 46db482

8 files changed

+1593
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#version 430
2+
#extension GL_ARB_texture_gather : enable
3+
#extension GL_ARB_separate_shader_objects : enable
4+
5+
6+
// shader 49865bd2e62efda1: tints the bloom mask and applies it to the frame
7+
8+
9+
#ifdef VULKAN
10+
#define ATTR_LAYOUT(__vkSet, __location) layout(set = __vkSet, location = __location)
11+
#define UNIFORM_BUFFER_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(set = __vkSet, binding = __vkLocation, std140)
12+
#define TEXTURE_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(set = __vkSet, binding = __vkLocation)
13+
#define GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale.xy,gl_FragCoord.z, 1.0/gl_FragCoord.w)
14+
15+
#else
16+
#define ATTR_LAYOUT(__vkSet, __location) layout(location = __location)
17+
#define UNIFORM_BUFFER_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(binding = __glLocation, std140)
18+
#define TEXTURE_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(binding = __glLocation)
19+
#define GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale,gl_FragCoord.zw)
20+
21+
#endif
22+
23+
#ifdef VULKAN
24+
layout(set = 1, binding = 1) uniform ufBlock
25+
{
26+
uniform ivec4 uf_remappedPS[1]; // holds area specific bloom tint color
27+
uniform vec4 uf_fragCoordScale;
28+
};
29+
30+
#else
31+
uniform ivec4 uf_remappedPS[1]; // holds area specific bloom tint color
32+
uniform vec2 uf_fragCoordScale;
33+
34+
#endif
35+
36+
TEXTURE_LAYOUT(0, 1, 0) uniform sampler2D textureUnitPS0; // bloom mask created in 6e2f31b2b2fcab1f
37+
layout(location = 0) in vec4 passParameterSem0; // pixel coord
38+
layout(location = 0) out vec4 passPixelColor0; // pixel color, alpha = blend of original pixel -> used to dampen non-bloom areas in shadow world
39+
40+
41+
// more compatible interpolation
42+
float mixf(float x, float y, float a)
43+
{
44+
return x * (1.0 - a) + y * a;
45+
}
46+
47+
48+
void main()
49+
{
50+
// get pixel coord
51+
vec2 coord = passParameterSem0.xy;
52+
53+
// get bloom mask
54+
vec3 mask = texture(textureUnitPS0, coord).xyz;
55+
56+
// get area specific color tint
57+
vec4 tint = vec4(0.0);
58+
tint.x = intBitsToFloat(uf_remappedPS[0].x);
59+
tint.y = intBitsToFloat(uf_remappedPS[0].y);
60+
tint.z = intBitsToFloat(uf_remappedPS[0].z);
61+
tint.w = intBitsToFloat(uf_remappedPS[0].w);
62+
63+
// get luminance of tint: removes color, keeps intended brightness
64+
float tintLuminance = dot(tint.xyz, vec3(0.299, 0.587, 0.114)); // percieved approximation
65+
66+
// apply custom tint color
67+
tint.x = mixf(tintLuminance, tint.x, $bloom_tint_strength);
68+
tint.y = mixf(tintLuminance, tint.y, $bloom_tint_strength);
69+
tint.z = mixf(tintLuminance, tint.z, $bloom_tint_strength);
70+
71+
// apply tint on mask
72+
vec4 outColor = vec4(0.0);
73+
outColor.x = mask.x * tint.x;
74+
outColor.y = mask.y * tint.y;
75+
outColor.z = mask.z * tint.z;
76+
77+
// custom brightness reduction, only in shadow world below 1.0
78+
outColor.w = mixf(1.0, tint.w, $shadow_world_darkening);
79+
80+
// export
81+
passPixelColor0 = vec4(outColor.x, outColor.y, outColor.z, outColor.w);
82+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#version 430
2+
#extension GL_ARB_texture_gather : enable
3+
#extension GL_ARB_separate_shader_objects : enable
4+
5+
6+
// shader 5f422bf63e25be7f: desaturates colors (shadow world only)
7+
// desaturates the image by shifting colors towards the red channel
8+
// used in shadow world only, as far as tested
9+
// grading values always seem to be: 1.0, 1.0, 1.0, ~0.33
10+
11+
12+
#ifdef VULKAN
13+
#define ATTR_LAYOUT(__vkSet, __location) layout(set = __vkSet, location = __location)
14+
#define UNIFORM_BUFFER_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(set = __vkSet, binding = __vkLocation, std140)
15+
#define TEXTURE_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(set = __vkSet, binding = __vkLocation)
16+
#define GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale.xy,gl_FragCoord.z, 1.0/gl_FragCoord.w)
17+
18+
layout(set = 1, binding = 1) uniform ufBlock
19+
{
20+
uniform ivec4 uf_remappedPS[1]; // grading
21+
};
22+
23+
#else
24+
#define ATTR_LAYOUT(__vkSet, __location) layout(location = __location)
25+
#define UNIFORM_BUFFER_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(binding = __glLocation, std140)
26+
#define TEXTURE_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(binding = __glLocation)
27+
#define GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale,gl_FragCoord.zw)
28+
29+
uniform ivec4 uf_remappedPS[1]; // grading
30+
31+
#endif
32+
33+
34+
TEXTURE_LAYOUT(0, 1, 0) uniform sampler2D textureUnitPS0; // frame
35+
layout(location = 0) in vec4 passParameterSem1; // pixel coordinate
36+
layout(location = 0) out vec4 passPixelColor0; // output. w is alpha, overlayed
37+
38+
39+
// more compatible interpolation
40+
float mixf(float x, float y, float a)
41+
{
42+
return x * (1.0 - a) + y * a;
43+
}
44+
45+
46+
void main()
47+
{
48+
// get texel color
49+
vec2 coord = passParameterSem1.xy;
50+
vec3 texel = texture(textureUnitPS0, coord).xyz;
51+
52+
// get grading
53+
vec4 grading = vec4(0.0);
54+
grading.x = intBitsToFloat(uf_remappedPS[0].x); // 1.0
55+
grading.y = intBitsToFloat(uf_remappedPS[0].y); // 1.0
56+
grading.z = intBitsToFloat(uf_remappedPS[0].z); // 1.0
57+
grading.w = intBitsToFloat(uf_remappedPS[0].w); // alpha, ~0.33
58+
59+
// shift towards red channel
60+
vec4 color = vec4(0.0);
61+
color.x = texel.x * grading.x; // red * 1.0
62+
color.y = texel.x * grading.y; // red * 1.0
63+
color.z = texel.x * grading.z; // red * 1.0
64+
color.w = mixf(0.0, grading.w, $shadow_world_desaturation); // apply custom strength
65+
66+
// export
67+
passPixelColor0 = vec4(color.x, color.y, color.z, color.w);
68+
69+
70+
// test current grading colors
71+
//passPixelColor0 = vec4(grading.x, grading.y, grading.z, 1.0);
72+
73+
// test current grading alpha
74+
//passPixelColor0 = vec4(grading.w, grading.w, grading.w, 1.0);
75+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#version 430
2+
#extension GL_ARB_texture_gather : enable
3+
#extension GL_ARB_separate_shader_objects : enable
4+
5+
6+
// shader 6e2f31b2b2fcab1f: creates bloom mask
7+
8+
9+
#ifdef VULKAN
10+
#define ATTR_LAYOUT(__vkSet, __location) layout(set = __vkSet, location = __location)
11+
#define UNIFORM_BUFFER_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(set = __vkSet, binding = __vkLocation, std140)
12+
#define TEXTURE_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(set = __vkSet, binding = __vkLocation)
13+
#define GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale.xy,gl_FragCoord.z, 1.0/gl_FragCoord.w)
14+
15+
#else
16+
#define ATTR_LAYOUT(__vkSet, __location) layout(location = __location)
17+
#define UNIFORM_BUFFER_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(binding = __glLocation, std140)
18+
#define TEXTURE_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(binding = __glLocation)
19+
#define GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale,gl_FragCoord.zw)
20+
21+
#endif
22+
23+
#ifdef VULKAN
24+
layout(set = 1, binding = 1) uniform ufBlock
25+
{
26+
uniform ivec4 uf_remappedPS[1]; // mask threshold
27+
uniform vec4 uf_fragCoordScale;
28+
};
29+
30+
#else
31+
uniform ivec4 uf_remappedPS[1]; // mask threshold
32+
uniform vec2 uf_fragCoordScale;
33+
34+
#endif
35+
36+
TEXTURE_LAYOUT(0, 1, 0) uniform sampler2D textureUnitPS0; // frame
37+
layout(location = 0) out vec4 passPixelColor0; // outputs to a texture used by c612390d4c70f430, 95a5a89d62998e0d and 49865bd2e62efda1
38+
39+
40+
void main()
41+
{
42+
// get mask threshold data
43+
float cutoff = intBitsToFloat(uf_remappedPS[0].x); // ~0.39: 0-1, higher = less glowing pixels
44+
float contrast = intBitsToFloat(uf_remappedPS[0].y); // 4.5: higher = sharper edges
45+
46+
// get texture coordinate of this pixel
47+
vec4 coord = GET_FRAGCOORD();
48+
coord.x = coord.x * intBitsToFloat(0x3b088889); // align to scale/grid?
49+
coord.y = coord.y * intBitsToFloat(0x3b72b9d6);
50+
51+
// get color of this pixel
52+
vec3 color = texture(textureUnitPS0, vec2(coord.x, coord.y)).xyz;
53+
54+
// calculate luminance = percieved brightness
55+
float luminance = dot(color, vec3(0.299, 0.587, 0.114)); // percieved approximation
56+
57+
// apply threshold, removes dark areas from the mask
58+
luminance = contrast * (luminance - cutoff) * $bloom_strength; // apply custom strength
59+
60+
// apply to color and clamp
61+
color.x = clamp(luminance * color.x, 0.0, 1.0);
62+
color.y = clamp(luminance * color.y, 0.0, 1.0);
63+
color.z = clamp(luminance * color.z, 0.0, 1.0);
64+
65+
// export
66+
passPixelColor0 = vec4(color.x, color.y, color.z, 0.0);
67+
}

0 commit comments

Comments
 (0)