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
353a0886
Commit
353a0886
authored
4 years ago
by
Mathias Paulin
Browse files
Options
Downloads
Patches
Plain Diff
Other noise proposal for LIC
parent
c733ee2f
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#198
passed
4 years ago
Stage: prepare
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libRender/RadiumNBR/Shaders/ImageProcessingPass/ImageProcess.frag.glsl
+38
-18
38 additions, 18 deletions
...iumNBR/Shaders/ImageProcessingPass/ImageProcess.frag.glsl
with
38 additions
and
18 deletions
src/libRender/RadiumNBR/Shaders/ImageProcessingPass/ImageProcess.frag.glsl
+
38
−
18
View file @
353a0886
...
@@ -6,49 +6,69 @@ in vec2 varTexcoord;
...
@@ -6,49 +6,69 @@ in vec2 varTexcoord;
vec2
imgSize
=
vec2
(
textureSize
(
image_sampler
,
0
)
);
vec2
imgSize
=
vec2
(
textureSize
(
image_sampler
,
0
)
);
const
int
halfsize
=
40
;
const
int
halfsize
=
40
;
const
float
dirFactor
=
1
.
;
const
float
dirFactor
=
0
.
5
;
const
float
randCeil
=
0
.
3
;
const
float
randCeil
=
0
.
3
;
#if 1
float
rand
(
vec2
co
)
{
float
rand
(
vec2
co
)
{
return
fract
(
sin
(
dot
(
co
.
xy
,
vec2
(
12
.
9898
,
78
.
233
)
)
)
*
43758
.
5453
);
return
fract
(
sin
(
dot
(
co
.
xy
,
vec2
(
12
.
9898
,
78
.
233
)
)
)
*
43758
.
5453
);
}
}
float
whiteNoise
(
in
vec2
at
)
{
float
whiteNoise
(
in
vec2
at
)
{
return
(
rand
(
floor
(
at
*
randCeil
)
/
imgSize
)
);
return
(
rand
(
floor
(
at
*
randCeil
)
/
imgSize
)
);
}
}
#else
// noise (hash) functions : taken from https://www.shadertoy.com/view/4djSRW
float
hash12
(
vec2
p
)
{
vec3
p3
=
fract
(
vec3
(
p
.
xyx
)
*
.
1031
);
p3
+=
dot
(
p3
,
p3
.
yzx
+
33
.
33
);
return
fract
((
p3
.
x
+
p3
.
y
)
*
p3
.
z
);
}
#define ITERATIONS 1
float
whiteNoise
(
in
vec2
at
)
{
float
a
=
0
.
0
;
for
(
int
t
=
0
;
t
<
ITERATIONS
;
t
++
)
{
float
v
=
float
(
t
+
1
)
*
.
152
;
vec2
pos
=
(
at
*
v
+
1517
.
01
);
a
+=
hash12
(
pos
);
}
return
a
/
float
(
ITERATIONS
);
}
#undef ITERATIONS
#endif
// desc : texture that contains direction to convolve
// desc : texture that contains direction to convolve
// invertdir invert (i.e. perpendicular) direction
// invertdir invert (i.e. perpendicular) direction
vec4
lic
(
in
sampler2D
desc
,
in
bool
invertdir
)
{
vec4
lic
(
in
sampler2D
desc
,
in
bool
invertdir
)
{
vec2
coord
;
vec2
dir
=
texelFetch
(
desc
,
ivec2
(
gl_FragCoord
.
xy
),
0
).
xy
;
vec2
dir
=
texelFetch
(
desc
,
ivec2
(
gl_FragCoord
.
xy
),
0
).
xy
;
if
(
length
(
dir
)
==
0
)
{
return
vec4
(
0
);}
if
(
invertdir
)
dir
=
vec2
(
dir
.
y
,
-
dir
.
x
);
if
(
invertdir
)
dir
=
vec2
(
dir
.
y
,
-
dir
.
x
);
vec4
res
=
vec4
(
whiteNoise
(
gl_FragCoord
.
xy
)
);
vec4
res
=
vec4
(
whiteNoise
(
gl_FragCoord
.
xy
)
);
vec2
currentdir
;
vec2
currentdir
=
dir
;
vec2
tmpdir
;
vec2
coord
=
gl_FragCoord
.
xy
;
coord
=
gl_FragCoord
.
xy
;
currentdir
=
dir
;
for
(
int
i
=
0
;
i
<
halfsize
;
i
++
)
for
(
int
i
=
1
;
i
<=
halfsize
;
i
++
)
{
{
coord
=
coord
+
dirFactor
*
vec2
(
currentdir
.
x
,
currentdir
.
y
)
;
coord
=
coord
+
dirFactor
*
currentdir
;
res
+=
vec4
(
whiteNoise
(
coord
)
);
res
+=
vec4
(
whiteNoise
(
coord
)
);
tmpdir
=
texelFetch
(
desc
,
ivec2
(
coord
),
0
).
xy
;
currentdir
=
texelFetch
(
desc
,
ivec2
(
coord
),
0
).
xy
;
if
(
invertdir
)
tmpdir
=
vec2
(
tmpdir
.
y
,
-
tmpdir
.
x
);
if
(
invertdir
)
currentdir
=
vec2
(
currentdir
.
y
,
-
currentdir
.
x
);
currentdir
=
tmpdir
;
}
}
coord
=
gl_FragCoord
.
xy
;
coord
=
gl_FragCoord
.
xy
;
currentdir
=
dir
;
currentdir
=
dir
;
for
(
int
i
=
1
;
i
<
=
halfsize
;
i
++
)
for
(
int
i
=
0
;
i
<
halfsize
;
i
++
)
{
{
coord
=
coord
-
dirFactor
*
vec2
(
currentdir
.
x
,
currentdir
.
y
)
;
coord
=
coord
-
dirFactor
*
currentdir
;
res
+=
vec4
(
whiteNoise
(
coord
)
);
res
+=
vec4
(
whiteNoise
(
coord
)
);
tmpdir
=
texelFetch
(
desc
,
ivec2
(
coord
),
0
).
xy
;
currentdir
=
texelFetch
(
desc
,
ivec2
(
coord
),
0
).
xy
;
if
(
invertdir
)
tmpdir
=
vec2
(
tmpdir
.
y
,
-
tmpdir
.
x
);
if
(
invertdir
)
currentdir
=
vec2
(
currentdir
.
y
,
-
currentdir
.
x
);
currentdir
=
tmpdir
;
}
}
res
=
res
/
(
2
.
0
f
*
float
(
halfsize
)
+
1
.
0
f
);
res
=
res
/
(
2
.
0
f
*
float
(
halfsize
)
+
1
.
0
f
);
return
smoothstep
(
0
.
1
,
0
.
9
,
res
);
return
smoothstep
(
0
.
1
,
0
.
9
,
res
);
}
}
...
@@ -70,5 +90,5 @@ void main() {
...
@@ -70,5 +90,5 @@ void main() {
out_color = vec4(result / (4 * half_width * half_width), 1);
out_color = vec4(result / (4 * half_width * half_width), 1);
*/
*/
out_color
=
lic
(
image_sampler
,
tru
e
);
out_color
=
lic
(
image_sampler
,
fals
e
);
}
}
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