Skip to content
Snippets Groups Projects
Commit 332a0f4e authored by Mathias Paulin's avatar Mathias Paulin :speech_balloon:
Browse files

Prototype of LIC function

parent 361cdaf8
No related branches found
No related tags found
No related merge requests found
......@@ -54,11 +54,47 @@ vec4 lic(in sampler2D desc,in bool invertdir) {
*/
vec4 lic(in sampler2D desc,in bool invertdir, in vec2 imgSize) {
const int halfsize = 10;
vec2 coord = varTexcoord;
vec2 dir = texture(desc,coord).xy;
if ( length(dir) <0.0001 )
return vec4(0);
if(invertdir)
dir = vec2(dir.y,-dir.x);
float res = whiteNoise( dir, imgSize);
vec2 currentdir = dir;
for(int i=1;i<=halfsize;i++) {
coord = coord + currentdir;//*halfsize;
currentdir = texture(desc,coord).xy;
res += whiteNoise( currentdir, imgSize);
if(invertdir)
currentdir = vec2(currentdir.y,-currentdir.x);
}
coord = varTexcoord;
currentdir = dir;
for(int i=1;i<=halfsize;i++) {
coord = coord - currentdir;//*halfsize;
currentdir = texture(desc,coord).xy;
res += whiteNoise( currentdir, imgSize);
if(invertdir)
currentdir = vec2(currentdir.y,-currentdir.x);
}
res = res/(2.0f*float(halfsize)+1.0f);
return vec4(vec3(res), 0);
}
void main() {
vec2 imgSize = vec2(textureSize(image_sampler, 0));
/*
// 4x4 filtering for test
const int half_width = 2;
vec2 texelSize = 1.0 / vec2(textureSize(image_sampler, 0));
vec2 texelSize = 1.0 / vec2(imgSize);
vec3 result = vec3(0.0);
for (int x = -half_width; x < half_width; ++x)
{
......@@ -70,8 +106,10 @@ void main() {
}
out_color = vec4(result / (4 * half_width * half_width), 1);
*/
vec2 imgSize = vec2(textureSize(image_sampler, 0));
/*
out_color = vec4( vec3( whiteNoise( varTexcoord, imgSize) ), 1);
*/
out_color = lic(image_sampler, false, imgSize);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment