Improved Bloom-Effect
[Can be now used, instead of filling another HDR-ColorAttachment, you just "overfill" the "color" buffer.]
This commit is contained in:
parent
4c18127c88
commit
af90d617d3
3 changed files with 14 additions and 17 deletions
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
uniform sampler2D renderedTexture;
|
||||
|
||||
uniform bool First;
|
||||
uniform float Threshold;
|
||||
|
||||
uniform bool Horizontal;
|
||||
|
||||
uniform float[32] Weights;
|
||||
|
|
@ -12,13 +15,15 @@ layout(location = 0) out vec4 color;
|
|||
vec4 GetRenderColorOffset(vec2 offset);
|
||||
|
||||
void main() {
|
||||
vec3 thres = vec3(First ? Threshold : 0);
|
||||
|
||||
vec2 tex_offset = 1.0 / textureSize(renderedTexture, 0);
|
||||
vec3 result = GetRenderColorOffset(vec2(0)).rgb * Weights[0];
|
||||
vec3 result = max(GetRenderColorOffset(vec2(0)).rgb - thres, 0) * Weights[0];
|
||||
|
||||
if (Horizontal) {
|
||||
for(int i = 1; i < WeightCount; i++) {
|
||||
result += GetRenderColorOffset(vec2(tex_offset.x * i, 0)).rgb * Weights[i];
|
||||
result += GetRenderColorOffset(vec2(-tex_offset.x * i, 0)).rgb * Weights[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++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue