Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gl-react-native-v2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ym
gl-react-native-v2
Commits
5a5fccf5
"...ios/Video.xcodeproj/xcshareddata/xcschemes/Video.xcscheme" did not exist on "c749a3825aca0476376bad45c003dad3fc70e9b8"
Commit
5a5fccf5
authored
Jan 09, 2016
by
Gaëtan Renaudeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make the Simple blur over ui example more efficient & more profile
parent
0c589f77
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
31 deletions
+36
-31
Examples/Simple/src/Blur1D.js
Examples/Simple/src/Blur1D.js
+9
-12
Examples/Simple/src/index.js
Examples/Simple/src/index.js
+13
-18
ios/GLCanvas.m
ios/GLCanvas.m
+14
-1
No files found.
Examples/Simple/src/Blur1D.js
View file @
5a5fccf5
...
...
@@ -11,23 +11,20 @@ uniform vec2 direction;
uniform vec2 resolution;
// from https://github.com/Jam3/glsl-fast-gaussian-blur
vec4 blur
13
(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
vec4 blur
9
(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
vec4 color = vec4(0.0);
vec2 off1 = vec2(1.411764705882353) * direction;
vec2 off2 = vec2(3.2941176470588234) * direction;
vec2 off3 = vec2(5.176470588235294) * direction;
color += texture2D(image, uv) * 0.1964825501511404;
color += texture2D(image, uv + (off1 / resolution)) * 0.2969069646728344;
color += texture2D(image, uv - (off1 / resolution)) * 0.2969069646728344;
color += texture2D(image, uv + (off2 / resolution)) * 0.09447039785044732;
color += texture2D(image, uv - (off2 / resolution)) * 0.09447039785044732;
color += texture2D(image, uv + (off3 / resolution)) * 0.010381362401148057;
color += texture2D(image, uv - (off3 / resolution)) * 0.010381362401148057;
vec2 off1 = vec2(1.3846153846) * direction;
vec2 off2 = vec2(3.2307692308) * direction;
color += texture2D(image, uv) * 0.2270270270;
color += texture2D(image, uv + (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv - (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv + (off2 / resolution)) * 0.0702702703;
color += texture2D(image, uv - (off2 / resolution)) * 0.0702702703;
return color;
}
void main () {
gl_FragColor = blur
13
(t, uv, resolution, direction);
gl_FragColor = blur
9
(t, uv, resolution, direction);
}
`
}
...
...
Examples/Simple/src/index.js
View file @
5a5fccf5
...
...
@@ -256,14 +256,10 @@ class Simple extends Component {
width
=
{
256
}
height
=
{
160
}
factor
=
{
factor
}
>
<
Blur
width
=
{
256
}
height
=
{
160
}
factor
=
{
factor
/
2
}
>
<
View
style
=
{{
width
:
256
,
height
:
160
,
padding
:
10
,
backgroundColor
:
"
#f9f9f9
"
}}
>
<
Slider
style
=
{{
height
:
80
}}
max
=
{
2
}
max
=
{
1
}
onChange
=
{
factor
=>
this
.
setState
({
factor
})}
/
>
<
View
style
=
{{
height
:
60
,
flexDirection
:
"
row
"
,
alignItems
:
"
center
"
}}
>
...
...
@@ -275,7 +271,6 @@ class Simple extends Component {
<
/View
>
<
/Blur
>
<
/Blur
>
<
/HueRotate
>
<
/Surface
>
<
Text
>
Note
:
This
is
highly
experimental
and
not
yet
performant
enough
.
<
/Text
>
...
...
ios/GLCanvas.m
View file @
5a5fccf5
#import "RCTBridge.h"
#import "RCTUtils.h"
#import "RCTConvert.h"
...
...
@@ -492,6 +491,9 @@ RCT_NOT_IMPLEMENTED(-init)
for
(
GLRenderData
*
child
in
renderData
.
children
)
weak_recDraw
(
child
);
RCT_PROFILE_BEGIN_EVENT
(
0
,
@"node"
,
nil
);
RCT_PROFILE_BEGIN_EVENT
(
0
,
@"bind fbo"
,
nil
);
if
(
renderData
.
fboId
==
-
1
)
{
glBindFramebuffer
(
GL_FRAMEBUFFER
,
defaultFBO
);
glViewport
(
0
,
0
,
w
,
h
);
...
...
@@ -501,23 +503,34 @@ RCT_NOT_IMPLEMENTED(-init)
[
fbo
setShapeWithWidth
:
w
withHeight
:
h
];
[
fbo
bind
];
}
RCT_PROFILE_END_EVENT
(
0
,
@"gl"
,
nil
);
RCT_PROFILE_BEGIN_EVENT
(
0
,
@"bind shader"
,
nil
);
[
renderData
.
shader
bind
];
RCT_PROFILE_END_EVENT
(
0
,
@"gl"
,
nil
);
RCT_PROFILE_BEGIN_EVENT
(
0
,
@"bind textures"
,
nil
);
for
(
NSString
*
uniformName
in
renderData
.
textures
)
{
GLTexture
*
texture
=
renderData
.
textures
[
uniformName
];
int
unit
=
[((
NSNumber
*
)
renderData
.
uniforms
[
uniformName
])
intValue
];
[
texture
bind
:
unit
];
}
RCT_PROFILE_END_EVENT
(
0
,
@"gl"
,
nil
);
RCT_PROFILE_BEGIN_EVENT
(
0
,
@"bind set uniforms"
,
nil
);
for
(
NSString
*
uniformName
in
renderData
.
uniforms
)
{
[
renderData
.
shader
setUniform
:
uniformName
withValue
:
renderData
.
uniforms
[
uniformName
]];
}
RCT_PROFILE_END_EVENT
(
0
,
@"gl"
,
nil
);
RCT_PROFILE_BEGIN_EVENT
(
0
,
@"draw"
,
nil
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glClearColor
(
0
.
0
,
0
.
0
,
0
.
0
,
0
.
0
);
glClear
(
GL_COLOR_BUFFER_BIT
);
glDrawArrays
(
GL_TRIANGLES
,
0
,
6
);
RCT_PROFILE_END_EVENT
(
0
,
@"gl"
,
nil
);
RCT_PROFILE_END_EVENT
(
0
,
@"gl"
,
nil
);
};
// DRAWING THE SCENE
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment