Initial commit: Final state of the master project
This commit is contained in:
45
Research/shaders/GI.frag
Normal file
45
Research/shaders/GI.frag
Normal file
@@ -0,0 +1,45 @@
|
||||
#version 430 core
|
||||
|
||||
in vec2 UV;
|
||||
out vec4 color;
|
||||
|
||||
uniform sampler2D shadeless;
|
||||
uniform sampler2D direct;
|
||||
uniform sampler2D indirect;
|
||||
|
||||
const int kernelSize = 5;
|
||||
const float[kernelSize][kernelSize] kernel = {
|
||||
{ 2.0, 4.0, 5.0, 4.0, 2.0 },
|
||||
{ 4.0, 9.0, 12.0, 9.0, 4.0 },
|
||||
{ 5.0, 12.0, 15.0, 12.0, 5.0 },
|
||||
{ 4.0, 9.0, 12.0, 9.0, 4.0 },
|
||||
{ 2.0, 4.0, 5.0, 4.0, 2.0 },
|
||||
};
|
||||
const float kernelNormalizer = 1.0 / 115.0;
|
||||
const float lightStrength = 1.0;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
ivec2 screenSize = textureSize(shadeless, 0);
|
||||
|
||||
vec4 smoothIndirect = vec4(0);
|
||||
ivec2 startCoord = ivec2(screenSize * UV) - ((kernelSize - 1) / 2);
|
||||
for (int i = 0; i < kernelSize; i++) {
|
||||
for (int j = 0; j < kernelSize; j++) {
|
||||
ivec2 coord = startCoord + ivec2(i, j);
|
||||
if (coord.x >= 0 && coord.y >= 0)
|
||||
smoothIndirect += kernel[i][j] * texelFetch(indirect, coord, 0);
|
||||
}
|
||||
}
|
||||
smoothIndirect *= kernelNormalizer * lightStrength;
|
||||
|
||||
vec4 shadelessPx = texture(shadeless, UV);
|
||||
vec4 directPx = texture(direct, UV);
|
||||
|
||||
//color = shadelessPx * smoothIndirect;
|
||||
color = shadelessPx * directPx + shadelessPx * smoothIndirect;
|
||||
//color = texture(indirect, UV);
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user