forked from armory3d/armory
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37eace7
commit 3226c6e
Showing
13 changed files
with
387 additions
and
183 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Exclusive to SSAO for now | ||
#version 450 | ||
|
||
#ifdef GL_ES | ||
precision mediump float; | ||
#endif | ||
|
||
#include "../compiled.glsl" | ||
#include "../std/gbuffer.glsl" | ||
|
||
uniform sampler2D tex; | ||
uniform sampler2D gbuffer0; | ||
|
||
uniform vec2 dirInv; // texStep | ||
|
||
in vec2 texCoord; | ||
out vec4 fragColor; | ||
|
||
const float blurWeights[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216); | ||
// const float blurWeights[10] = float[] (0.132572, 0.125472, 0.106373, 0.08078, 0.05495, 0.033482, 0.018275, 0.008934, 0.003912, 0.001535); | ||
const float discardThreshold = 0.95; | ||
|
||
float doBlur(const float blurWeight, const int pos, const vec3 nor, const vec2 texCoord) { | ||
const float posadd = pos + 0.5; | ||
|
||
vec3 nor2 = getNor(texture(gbuffer0, texCoord + pos * dirInv).rg); | ||
float influenceFactor = step(discardThreshold, dot(nor2, nor)); | ||
vec4 col = texture(tex, texCoord + posadd * dirInv); | ||
fragColor += col * blurWeight * influenceFactor; | ||
float weight = blurWeight * influenceFactor; | ||
|
||
nor2 = getNor(texture(gbuffer0, texCoord - pos * dirInv).rg); | ||
influenceFactor = step(discardThreshold, dot(nor2, nor)); | ||
col = texture(tex, texCoord - posadd * dirInv); | ||
fragColor += col * blurWeight * influenceFactor; | ||
weight += blurWeight * influenceFactor; | ||
|
||
return weight; | ||
} | ||
|
||
void main() { | ||
vec3 nor = getNor(texture(gbuffer0, texCoord).rg); | ||
|
||
fragColor = texture(tex, texCoord) * blurWeights[0]; | ||
float weight = blurWeights[0]; | ||
// for (int i = 1; i < 10; i++) { | ||
weight += doBlur(blurWeights[1], 1, nor, texCoord); | ||
weight += doBlur(blurWeights[2], 2, nor, texCoord); | ||
weight += doBlur(blurWeights[3], 3, nor, texCoord); | ||
weight += doBlur(blurWeights[4], 4, nor, texCoord); | ||
// weight += doBlur(blurWeights[5], 5, nor, texCoord); | ||
// weight += doBlur(blurWeights[6], 6, nor, texCoord); | ||
// weight += doBlur(blurWeights[7], 7, nor, texCoord); | ||
// weight += doBlur(blurWeights[8], 8, nor, texCoord); | ||
// weight += doBlur(blurWeights[9], 9, nor, texCoord); | ||
// } | ||
|
||
fragColor = vec4(fragColor / weight); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"contexts": [ | ||
{ | ||
"name": "ssgi_blur_pass_x", | ||
"color_write_alpha": false, | ||
"depth_write": false, | ||
"compare_mode": "always", | ||
"cull_mode": "none", | ||
"links": [ | ||
{ | ||
"name": "dirInv", | ||
"link": "_vec2xInv" | ||
} | ||
], | ||
"texture_params": [], | ||
"vertex_shader": "ssgi_blur_pass.vert.glsl", | ||
"vertex_shader_path": "../include/pass.vert.glsl", | ||
"fragment_shader": "ssgi_blur_pass.frag.glsl" | ||
}, | ||
{ | ||
"name": "ssgi_blur_pass_y", | ||
"color_write_alpha": false, | ||
"depth_write": false, | ||
"compare_mode": "always", | ||
"cull_mode": "none", | ||
"links": [ | ||
{ | ||
"name": "dirInv", | ||
"link": "_vec2yInv" | ||
} | ||
], | ||
"texture_params": [], | ||
"vertex_shader": "ssgi_blur_pass.vert.glsl", | ||
"vertex_shader_path": "../include/pass.vert.glsl", | ||
"fragment_shader": "ssgi_blur_pass.frag.glsl" | ||
}, | ||
{ | ||
"name": "ssgi_blur_pass_y_blend", | ||
"color_write_alpha": false, | ||
"depth_write": false, | ||
"compare_mode": "always", | ||
"cull_mode": "none", | ||
"blend_source": "destination_color", | ||
"blend_destination": "blend_zero", | ||
"blend_operation": "add", | ||
"links": [ | ||
{ | ||
"name": "dirInv", | ||
"link": "_vec2yInv" | ||
} | ||
], | ||
"texture_params": [], | ||
"vertex_shader": "ssgi_blur_pass.vert.glsl", | ||
"vertex_shader_path": "../include/pass.vert.glsl", | ||
"fragment_shader": "ssgi_blur_pass.frag.glsl" | ||
}, | ||
|
||
{ | ||
"name": "ssgi_blur_pass_y_blend_add", | ||
"color_write_alpha": false, | ||
"depth_write": false, | ||
"compare_mode": "always", | ||
"cull_mode": "none", | ||
"blend_source": "blend_one", | ||
"blend_destination": "blend_one", | ||
"blend_operation": "add", | ||
"alpha_blend_source": "blend_one", | ||
"alpha_blend_destination": "blend_one", | ||
"alpha_blend_operation": "add", | ||
"links": [ | ||
{ | ||
"name": "dirInv", | ||
"link": "_vec2yInv" | ||
} | ||
], | ||
"texture_params": [], | ||
"vertex_shader": "ssgi_blur_pass.vert.glsl", | ||
"vertex_shader_path": "../include/pass.vert.glsl", | ||
"fragment_shader": "ssgi_blur_pass.frag.glsl" | ||
} | ||
] | ||
} |
Oops, something went wrong.