Loads and loads of small improvements I added while developing on my game
This commit is contained in:
parent
41421b1df9
commit
a7c71e7ea1
107 changed files with 2278 additions and 1023 deletions
|
|
@ -1,6 +1,8 @@
|
|||
#version 330
|
||||
#define PI 3.14159265359
|
||||
|
||||
uniform sampler2D renderedTexture;
|
||||
uniform float RenderScale;
|
||||
|
||||
uniform bool First;
|
||||
uniform float Threshold;
|
||||
|
|
@ -9,27 +11,35 @@ uniform bool Horizontal;
|
|||
|
||||
uniform float[32] Weights;
|
||||
uniform int WeightCount;
|
||||
uniform float Power;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
vec4 GetRenderColorOffset(vec2 offset);
|
||||
|
||||
float brightness(vec3 c)
|
||||
{
|
||||
return max(max(c.r, c.g), c.b);
|
||||
}
|
||||
|
||||
float bright;
|
||||
|
||||
float GetWeight(int dif) {
|
||||
return Weights[dif];
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec3 thres = vec3(First ? Threshold : 0);
|
||||
|
||||
vec2 tex_offset = 1.0 / textureSize(renderedTexture, 0);
|
||||
vec3 result = max(GetRenderColorOffset(vec2(0)).rgb - thres, 0) * Weights[0];
|
||||
vec2 tex_offset = 1.0 / textureSize(renderedTexture, 0) * vec2(Horizontal ? 1 : 0, Horizontal ? 0 : 1);
|
||||
|
||||
if (Horizontal) {
|
||||
for(int i = 1; i < WeightCount; i++) {
|
||||
result += max(GetRenderColorOffset(vec2(tex_offset.x * i, 0)).rgb - thres, 0) * Weights[i];
|
||||
result += max(GetRenderColorOffset(vec2(-tex_offset.x * i, 0)).rgb - thres, 0) * Weights[i];
|
||||
}
|
||||
} else {
|
||||
for(int i = 1; i < WeightCount; i++) {
|
||||
result += GetRenderColorOffset(vec2(0, tex_offset.x * i)).rgb * Weights[i];
|
||||
result += GetRenderColorOffset(vec2(0, -tex_offset.x * i)).rgb * Weights[i];
|
||||
}
|
||||
vec3 result = max(GetRenderColorOffset(vec2(0)).rgb - thres, 0) * (First ? Power : 1);
|
||||
result *= GetWeight(0);
|
||||
|
||||
for(int i = 1; i < WeightCount; i++) {
|
||||
result += max(GetRenderColorOffset(tex_offset * i).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||
result += max(GetRenderColorOffset(-tex_offset * i).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||
}
|
||||
|
||||
color = vec4(result, 1);
|
||||
}
|
||||
|
|
@ -1,10 +1,16 @@
|
|||
#version 330
|
||||
|
||||
in vec2 vTexture;
|
||||
in vec2 TransformedTexture;
|
||||
|
||||
uniform sampler2D renderedTexture;
|
||||
uniform sampler2D Scene;
|
||||
uniform sampler2D Bloom;
|
||||
|
||||
uniform float MinAmount;
|
||||
uniform float MaxAmount;
|
||||
uniform sampler2D AmountMap;
|
||||
uniform bool HasAmountMap;
|
||||
|
||||
uniform float Exposure;
|
||||
uniform bool HDR;
|
||||
|
||||
|
|
@ -12,10 +18,13 @@ layout(location = 0) out vec4 color;
|
|||
|
||||
void main() {
|
||||
vec3 result = texture(Bloom, vTexture).rgb;
|
||||
if (HasAmountMap) result *= clamp(length(texture(AmountMap, TransformedTexture).rgb) * (MaxAmount - MinAmount) + MinAmount, 0, 1);
|
||||
if (!HDR) {
|
||||
result = vec3(1.0) - exp(-result * Exposure);
|
||||
}
|
||||
result += texture(renderedTexture, vTexture).rgb;
|
||||
|
||||
|
||||
result = texture(Scene, vTexture).rgb + result;
|
||||
|
||||
color = vec4(result, 1);
|
||||
}
|
||||
11
SMCode/SM.Base/PostEffects/Shaders/bloom_merge_vert.glsl
Normal file
11
SMCode/SM.Base/PostEffects/Shaders/bloom_merge_vert.glsl
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#version 330
|
||||
|
||||
layout(location = 1) in vec2 aTex;
|
||||
|
||||
uniform mat3 TextureTransform;
|
||||
|
||||
out vec2 TransformedTexture;
|
||||
|
||||
void vertex() {
|
||||
TransformedTexture = vec2(TextureTransform * vec3(aTex, 1));
|
||||
}
|
||||
12
SMCode/SM.Base/PostEffects/Shaders/finalize_gamma.glsl
Normal file
12
SMCode/SM.Base/PostEffects/Shaders/finalize_gamma.glsl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#version 330
|
||||
|
||||
in vec2 vTexture;
|
||||
|
||||
uniform sampler2D Scene;
|
||||
uniform float Gamma;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main() {
|
||||
color = vec4(pow(texture(Scene, vTexture).rgb, vec3(1 / Gamma)), 1);
|
||||
}
|
||||
15
SMCode/SM.Base/PostEffects/Shaders/finalize_hdr.glsl
Normal file
15
SMCode/SM.Base/PostEffects/Shaders/finalize_hdr.glsl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 330
|
||||
|
||||
in vec2 vTexture;
|
||||
|
||||
uniform sampler2D Scene;
|
||||
uniform float Exposure;
|
||||
uniform float Gamma;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main() {
|
||||
vec3 result = vec3(1) - exp(-texture(Scene, vTexture).rgb * Exposure);
|
||||
|
||||
color = vec4(pow(result, vec3(1 / Gamma)), 1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue