Skip to content

Commit 200f3f7

Browse files
oguzerogluphemavax
authored andcommitted
feat: motionblur
1 parent f5bb186 commit 200f3f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+30775
-0
lines changed

motionblur/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Oğuz Eroğlu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

motionblur/README

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
_____ ______ _______ ____ _______ __
2+
| __ \ / __ \ \ / / ____| _ \_ _\ \ / /
3+
| |__) | | | \ \_/ / | __| |_) || | \ \ / /
4+
| _ /| | | |\ /| | |_ | _ < | | \ \/ /
5+
| | \ \| |__| | | | | |__| | |_) || |_ \ /
6+
|_| \_\\____/ |_| \_____|____/_____| \/
7+
8+
by Oğuz Eroğlu - github.com/oguzeroglu
9+
10+
This is the deployment folder of your project. Serve the "application.html"
11+
using a web server to start your application. Do not change the directory
12+
structure of this folder.

motionblur/application.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset=utf-8>
5+
<meta name='viewport' content='width=device-width'/>
6+
<title>demo1</title>
7+
<link rel="stylesheet" href="./css/jquery.terminal-1.11.3.min.css">
8+
<script src="./js/roygbiv.js"></script>
9+
<style>
10+
body { margin: 0; position: fixed; display: flex;}
11+
canvas {display: block;}
12+
@font-face {
13+
font-family: hack;
14+
src: url(./css/Hack-Bold.ttf);
15+
}
16+
.noselect {
17+
-webkit-touch-callout: none;
18+
-webkit-user-select: none;
19+
-khtml-user-select: none;
20+
-moz-user-select: none;
21+
-ms-user-select: none;
22+
user-select: none;
23+
}
24+
#cliDiv {
25+
background-color: #000000;
26+
opacity: 1;
27+
display: block;
28+
width: 100%;
29+
}
30+
.terminal, .cmd, .terminal, .cmd .prompt {
31+
color: lime;
32+
font-family: hack;
33+
}
34+
</style>
35+
</head>
36+
<body style="background-color:black;">
37+
<!-- CLI -->
38+
<div id="cliDiv">
39+
<div id="terminalDiv" class="terminal noselect"></div>
40+
</div>
41+
<!-- 3D CONTENT -->
42+
<canvas id="rendererCanvas"></canvas>
43+
</body>
44+
</html>

motionblur/css/Hack-Bold.ttf

310 KB
Binary file not shown.

motionblur/css/jquery.terminal-1.11.3.min.css

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

motionblur/js/application.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

motionblur/js/roygbiv.js

Lines changed: 29363 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
precision lowp float;
2+
precision lowp int;
3+
4+
uniform sampler2D texture;
5+
uniform vec4 color;
6+
uniform mat3 uvTransform;
7+
8+
void main(){
9+
vec2 uv = (uvTransform * vec3(gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1.0)).xy;
10+
vec4 textureColor = texture2D(texture, uv);
11+
if (textureColor.a < 0.5){
12+
discard;
13+
}else{
14+
gl_FragColor = color * textureColor;
15+
}
16+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
precision lowp float;
2+
precision lowp int;
3+
4+
attribute float size;
5+
6+
uniform vec4 expandInfo;
7+
uniform float shrinkStartSize;
8+
9+
void main(){
10+
11+
float expandFlag = expandInfo[0];
12+
float expandTargetSize = expandInfo[1];
13+
float expandTick = expandInfo[2];
14+
float expandDelta = expandInfo[3];
15+
16+
gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
17+
if (expandFlag < 5.0 && expandFlag > -5.0){
18+
gl_PointSize = 5.0 * size;
19+
}else if (expandFlag > 5.0){
20+
float newSize = size + (expandDelta * expandTick);
21+
if (newSize <= expandTargetSize){
22+
gl_PointSize = 5.0 * newSize;
23+
}else{
24+
gl_PointSize = 5.0 * expandTargetSize;
25+
}
26+
}else if (expandFlag < -5.0){
27+
float newSize = shrinkStartSize - (expandDelta * expandTick);
28+
if (newSize > size){
29+
gl_PointSize = 5.0 * newSize;
30+
}else{
31+
gl_PointSize = 5.0 * size;
32+
}
33+
}
34+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
precision lowp float;
2+
precision lowp int;
3+
4+
#define LOG2 1.442695
5+
#define ALPHA_TEST 0.5
6+
7+
varying vec3 vColor;
8+
varying vec2 vUV;
9+
varying float vAlpha;
10+
varying float hasDiffuseFlag;
11+
varying float hasAlphaFlag;
12+
varying float hasAOFlag;
13+
varying float hasEmissiveFlag;
14+
varying vec3 vWorldPosition;
15+
16+
uniform vec3 cameraPosition;
17+
uniform vec3 emissiveColor;
18+
uniform vec4 fogInfo;
19+
uniform vec4 forcedColor;
20+
uniform mat3 textureMatrix;
21+
uniform sampler2D diffuseMap;
22+
uniform sampler2D alphaMap;
23+
uniform sampler2D aoMap;
24+
uniform sampler2D emissiveMap;
25+
uniform float aoIntensity;
26+
uniform float emissiveIntensity;
27+
uniform samplerCube cubeTexture;
28+
29+
void main(){
30+
31+
if (forcedColor.x >= -10.0){
32+
gl_FragColor = vec4(forcedColor.y, forcedColor.z, forcedColor.w, forcedColor.x);
33+
return;
34+
}
35+
36+
vec2 transformedUV = vUV;
37+
38+
vec4 diffuseColor = vec4(1.0, 1.0, 1.0, 1.0);
39+
40+
if (hasDiffuseFlag > 0.0){
41+
diffuseColor = texture2D(diffuseMap, transformedUV);
42+
}
43+
44+
gl_FragColor = vec4(vColor, vAlpha) * diffuseColor;
45+
46+
if (hasAlphaFlag > 0.0){
47+
float val = texture2D(alphaMap, transformedUV).g;
48+
gl_FragColor.a *= val;
49+
if (val <= ALPHA_TEST){
50+
discard;
51+
}
52+
}
53+
54+
if (hasAOFlag > 0.0){
55+
float ao = (texture2D(aoMap, transformedUV).r - 1.0) * aoIntensity + 1.0;
56+
gl_FragColor.rgb *= ao;
57+
}
58+
59+
if (hasEmissiveFlag > 0.0){
60+
vec4 eColor = texture2D(emissiveMap, transformedUV);
61+
vec3 totalEmissiveRadiance = vec3(emissiveIntensity, emissiveIntensity, emissiveIntensity) * emissiveColor;
62+
totalEmissiveRadiance *= eColor.rgb;
63+
gl_FragColor.rgb += totalEmissiveRadiance;
64+
}
65+
66+
if (fogInfo[0] >= 0.0){
67+
float fogDensity = fogInfo[0];
68+
float fogR = fogInfo[1];
69+
float fogG = fogInfo[2];
70+
float fogB = fogInfo[3];
71+
float z = gl_FragCoord.z / gl_FragCoord.w;
72+
float fogFactor = exp2(-fogDensity * fogDensity * z * z * LOG2);
73+
fogFactor = clamp(fogFactor, 0.0, 1.0);
74+
gl_FragColor = vec4(mix(vec3(fogR, fogG, fogB), gl_FragColor.rgb, fogFactor), gl_FragColor.a);
75+
}else if (fogInfo[0] < 0.0 && fogInfo[0] > -50.0){
76+
vec3 coord = normalize(vWorldPosition - cameraPosition);
77+
vec4 cubeTextureColor = textureCube(cubeTexture, coord) * vec4(fogInfo[1], fogInfo[2], fogInfo[3], 1.0);
78+
float fogDensity = -fogInfo[0];
79+
float z = gl_FragCoord.z / gl_FragCoord.w;
80+
float fogFactor = exp2(-fogDensity * fogDensity * z * z * LOG2);
81+
gl_FragColor = vec4(mix(cubeTextureColor.rgb, gl_FragColor.rgb, fogFactor), gl_FragColor.a);
82+
}
83+
84+
}

0 commit comments

Comments
 (0)