Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libRendering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STORM
repos
Radium
libRendering
Commits
c733ee2f
Commit
c733ee2f
authored
4 years ago
by
dlyr
Browse files
Options
Downloads
Patches
Plain Diff
update lic image processing shader
parent
332a0f4e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libRender/RadiumNBR/Shaders/ImageProcessingPass/ImageProcess.frag.glsl
+38
-79
38 additions, 79 deletions
...iumNBR/Shaders/ImageProcessingPass/ImageProcess.frag.glsl
with
38 additions
and
79 deletions
src/libRender/RadiumNBR/Shaders/ImageProcessingPass/ImageProcess.frag.glsl
+
38
−
79
View file @
c733ee2f
layout
(
location
=
0
)
out
vec4
out_color
;
layout
(
location
=
0
)
out
vec4
out_color
;
uniform
sampler2D
depth_sampler
;
uniform
sampler2D
image_sampler
;
in
vec2
varTexcoord
;
vec2
imgSize
=
vec2
(
textureSize
(
image_sampler
,
0
)
);
const
int
halfsize
=
40
;
const
float
dirFactor
=
1
.;
const
float
randCeil
=
0
.
3
;
// replace the nois texture : TODO verify the properties of the generated noise
float
whiteNoise
(
in
vec2
at
,
in
vec2
scale
)
{
return
(
noise1
(
at
*
scale
)
+
0
.
5
)
*
0
.
5
;
float
rand
(
vec2
co
)
{
return
fract
(
sin
(
dot
(
co
.
xy
,
vec2
(
12
.
9898
,
78
.
233
)
)
)
*
43758
.
5453
);
}
float
whiteNoise
(
in
vec2
at
)
{
return
(
rand
(
floor
(
at
*
randCeil
)
/
imgSize
)
);
}
// desc : texture that contains direction to convolve
// invertdir invert (i.e. perpendicular) direction
vec4
lic
(
in
sampler2D
desc
,
in
bool
invertdir
)
{
/*
// LIC function to be adapted ...
//desc : texture de direction (vecteurs)
// invertdir pour faire "perpendiculaire" a desc,
// noise une texture de bruit "poivre et sel"
// sw, sh : screensize
vec4 lic(in sampler2D desc,in bool invertdir) {
const int halfsize = 10;
vec2
coord
;
vec2 dir = texture2D(desc,gl_TexCoord[0].st).xy;
//
vec2 dir = texelFetch(desc,ivec2(gl_
Tex
Coord
[0].st*1.0/vec2(sw,sh)),0
).xy;
if
(
invertdir
)
dir = vec2(dir.y,-dir.x);
vec4 res =
texture2D(n
oise
,
gl_
Tex
Coord
[0].st
);
vec2
dir
=
texelFetch
(
desc
,
ivec2
(
gl_
Frag
Coord
.
xy
),
0
).
xy
;
if
(
invertdir
)
dir
=
vec2
(
dir
.
y
,
-
dir
.
x
);
vec4
res
=
vec4
(
whiteN
oise
(
gl_
Frag
Coord
.
xy
)
);
vec2
currentdir
;
vec2
tmpdir
;
coord = gl_
Tex
Coord
[0].st
;
coord
=
gl_
Frag
Coord
.
xy
;
currentdir
=
dir
;
for(int i=1;i<=halfsize;i++) {
coord = coord+vec2(currentdir.x*sw,currentdir.y*sh);
res += texture2D(noise,coord);
tmpdir = texture2D(desc,coord).xy;
//tmpdir = texelFetch(desc,ivec2(coord*1.0/vec2(sw,sh)),0).xy;
if(invertdir)
tmpdir = vec2(tmpdir.y,-tmpdir.x);
currentdir = tmpdir;
}
coord = gl_TexCoord[0].st;
currentdir = dir;
for(int i=1;i<=halfsize;i++) {
coord = coord-vec2(currentdir.x*sw,currentdir.y*sh);
res += texture2D(noise,coord);
tmpdir = texture2D(desc,coord).xy;
//tmpdir = texelFetch(desc,ivec2(coord*1.0/vec2(sw,sh)),0).xy;
if(invertdir)
tmpdir = vec2(tmpdir.y,-tmpdir.x);
for
(
int
i
=
1
;
i
<=
halfsize
;
i
++
)
{
coord
=
coord
+
dirFactor
*
vec2
(
currentdir
.
x
,
currentdir
.
y
);
res
+=
vec4
(
whiteNoise
(
coord
)
);
tmpdir
=
texelFetch
(
desc
,
ivec2
(
coord
),
0
).
xy
;
if
(
invertdir
)
tmpdir
=
vec2
(
tmpdir
.
y
,
-
tmpdir
.
x
);
currentdir
=
tmpdir
;
}
res = res/(2.0f*float(halfsize)+1.0f);
return vec4(res.x);
}
*/
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
;
coord
=
gl_FragCoord
.
xy
;
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
);
for
(
int
i
=
1
;
i
<=
halfsize
;
i
++
)
{
coord
=
coord
-
dirFactor
*
vec2
(
currentdir
.
x
,
currentdir
.
y
);
res
+=
vec4
(
whiteNoise
(
coord
)
);
tmpdir
=
texelFetch
(
desc
,
ivec2
(
coord
),
0
).
xy
;
if
(
invertdir
)
tmpdir
=
vec2
(
tmpdir
.
y
,
-
tmpdir
.
x
);
currentdir
=
tmpdir
;
}
res
=
res
/
(
2
.
0
f
*
float
(
halfsize
)
+
1
.
0
f
);
return
vec4
(
vec3
(
res
),
0
);
res
=
res
/
(
2
.
0
f
*
float
(
halfsize
)
+
1
.
0
f
);
return
smoothstep
(
0
.
1
,
0
.
9
,
res
);
}
void
main
()
{
vec2
imgSize
=
vec2
(
textureSize
(
image_sampler
,
0
));
/*
// 4x4 filtering for test
const int half_width = 2;
vec2 texelSize = 1.0 / vec2(
imgSize
);
vec2 texelSize = 1.0 / vec2(
textureSize(image_sampler, 0)
);
vec3 result = vec3(0.0);
for (int x = -half_width; x < half_width; ++x)
{
...
...
@@ -106,10 +69,6 @@ void main() {
}
out_color = vec4(result / (4 * half_width * half_width), 1);
*/
/*
out_color = vec4( vec3( whiteNoise( varTexcoord, imgSize) ), 1);
*/
out_color
=
lic
(
image_sampler
,
false
,
imgSize
);
out_color
=
lic
(
image_sampler
,
true
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment