Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OrigamiSimulator
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amanda Ghassaei
OrigamiSimulator
Commits
308889db
Commit
308889db
authored
Jun 1, 2017
by
amandaghassaei
Browse files
Options
Downloads
Patches
Plain Diff
cleaning up code
parent
7dd459e6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
index.html
+28
-31
28 additions, 31 deletions
index.html
with
28 additions
and
31 deletions
index.html
+
28
−
31
View file @
308889db
...
@@ -305,6 +305,12 @@
...
@@ -305,6 +305,12 @@
uniform
sampler2D
u_originalPosition
;
uniform
sampler2D
u_originalPosition
;
uniform
float
u_dt
;
uniform
float
u_dt
;
vec4
getFromArray
(
float
index1D
,
vec2
dimensions
,
sampler2D
tex
){
vec2
index
=
vec2
(
mod
(
index1D
,
dimensions
.
x
)
+
0.5
,
floor
(
index1D
/
dimensions
.
x
)
+
0.5
);
vec2
scaledIndex
=
index
/
dimensions
;
return
texture2D
(
tex
,
scaledIndex
);
}
void
main
(){
void
main
(){
vec2
fragCoord
=
gl_FragCoord
.
xy
;
vec2
fragCoord
=
gl_FragCoord
.
xy
;
...
@@ -317,13 +323,8 @@
...
@@ -317,13 +323,8 @@
return
;
return
;
}
}
vec2
normal1Index
=
vec2
(
mod
(
lastTheta
[
2
],
u_textureDimFaces
.
x
)
+
0.5
,
floor
(
lastTheta
[
2
]
/
u_textureDimFaces
.
x
)
+
0.5
);
vec3
normal1
=
getFromArray
(
lastTheta
[
2
],
u_textureDimFaces
,
u_normals
).
xyz
;
normal1Index
/=
u_textureDimFaces
;
vec3
normal2
=
getFromArray
(
lastTheta
[
3
],
u_textureDimFaces
,
u_normals
).
xyz
;
vec2
normal2Index
=
vec2
(
mod
(
lastTheta
[
3
],
u_textureDimFaces
.
x
)
+
0.5
,
floor
(
lastTheta
[
3
]
/
u_textureDimFaces
.
x
)
+
0.5
);
normal2Index
/=
u_textureDimFaces
;
vec3
normal1
=
texture2D
(
u_normals
,
normal1Index
).
xyz
;
vec3
normal2
=
texture2D
(
u_normals
,
normal2Index
).
xyz
;
float
dotNormals
=
dot
(
normal1
,
normal2
);
//normals are already normalized, no need to divide by length
float
dotNormals
=
dot
(
normal1
,
normal2
);
//normals are already normalized, no need to divide by length
if
(
dotNormals
<
-
1.0
)
dotNormals
=
-
1.0
;
if
(
dotNormals
<
-
1.0
)
dotNormals
=
-
1.0
;
...
@@ -364,26 +365,21 @@
...
@@ -364,26 +365,21 @@
uniform
sampler2D
u_lastPosition
;
uniform
sampler2D
u_lastPosition
;
uniform
sampler2D
u_originalPosition
;
uniform
sampler2D
u_originalPosition
;
vec3
getPosition
(
float
index1D
){
vec2
index
=
vec2
(
mod
(
index1D
,
u_textureDim
.
x
)
+
0.5
,
floor
(
index1D
/
u_textureDim
.
x
)
+
0.5
);
vec2
scaledIndex
=
index
/
u_textureDim
;
return
texture2D
(
u_lastPosition
,
scaledIndex
).
xyz
+
texture2D
(
u_originalPosition
,
scaledIndex
).
xyz
;
}
void
main
(){
void
main
(){
vec2
fragCoord
=
gl_FragCoord
.
xy
;
vec2
fragCoord
=
gl_FragCoord
.
xy
;
vec2
scaledFragCoord
=
fragCoord
/
u_textureDimFaces
;
vec2
scaledFragCoord
=
fragCoord
/
u_textureDimFaces
;
vec3
indices
=
texture2D
(
u_faceVertexIndices
,
scaledFragCoord
).
xyz
;
vec3
indices
=
texture2D
(
u_faceVertexIndices
,
scaledFragCoord
).
xyz
;
float
nodeIndex1D
=
indices
[
0
];
vec3
a
=
getPosition
(
indices
[
0
]);
vec2
nodeIndex
=
vec2
(
mod
(
nodeIndex1D
,
u_textureDim
.
x
)
+
0.5
,
floor
(
nodeIndex1D
/
u_textureDim
.
x
)
+
0.5
);
vec3
b
=
getPosition
(
indices
[
1
]);
vec2
scaledNodeIndex
=
nodeIndex
/
u_textureDim
;
vec3
c
=
getPosition
(
indices
[
2
]);
vec3
a
=
texture2D
(
u_lastPosition
,
scaledNodeIndex
).
xyz
+
texture2D
(
u_originalPosition
,
scaledNodeIndex
).
xyz
;
nodeIndex1D
=
indices
[
1
];
nodeIndex
=
vec2
(
mod
(
nodeIndex1D
,
u_textureDim
.
x
)
+
0.5
,
floor
(
nodeIndex1D
/
u_textureDim
.
x
)
+
0.5
);
scaledNodeIndex
=
nodeIndex
/
u_textureDim
;
vec3
b
=
texture2D
(
u_lastPosition
,
scaledNodeIndex
).
xyz
+
texture2D
(
u_originalPosition
,
scaledNodeIndex
).
xyz
;
nodeIndex1D
=
indices
[
2
];
nodeIndex
=
vec2
(
mod
(
nodeIndex1D
,
u_textureDim
.
x
)
+
0.5
,
floor
(
nodeIndex1D
/
u_textureDim
.
x
)
+
0.5
);
scaledNodeIndex
=
nodeIndex
/
u_textureDim
;
vec3
c
=
texture2D
(
u_lastPosition
,
scaledNodeIndex
).
xyz
+
texture2D
(
u_originalPosition
,
scaledNodeIndex
).
xyz
;
vec3
normal
=
normalize
(
cross
(
b
-
a
,
c
-
a
));
vec3
normal
=
normalize
(
cross
(
b
-
a
,
c
-
a
));
...
@@ -399,21 +395,22 @@
...
@@ -399,21 +395,22 @@
uniform
sampler2D
u_originalPosition
;
uniform
sampler2D
u_originalPosition
;
uniform
sampler2D
u_creaseMeta2
;
uniform
sampler2D
u_creaseMeta2
;
vec3
getPosition
(
float
index1D
){
vec2
index
=
vec2
(
mod
(
index1D
,
u_textureDim
.
x
)
+
0.5
,
floor
(
index1D
/
u_textureDim
.
x
)
+
0.5
);
vec2
scaledIndex
=
index
/
u_textureDim
;
return
texture2D
(
u_lastPosition
,
scaledIndex
).
xyz
+
texture2D
(
u_originalPosition
,
scaledIndex
).
xyz
;
}
void
main
(){
void
main
(){
vec2
fragCoord
=
gl_FragCoord
.
xy
;
vec2
fragCoord
=
gl_FragCoord
.
xy
;
vec2
scaledFragCoord
=
fragCoord
/
u_textureDimCreases
;
vec2
scaledFragCoord
=
fragCoord
/
u_textureDimCreases
;
vec4
creaseMeta
=
texture2D
(
u_creaseMeta2
,
scaledFragCoord
);
vec4
creaseMeta
=
texture2D
(
u_creaseMeta2
,
scaledFragCoord
);
vec2
node1Index
=
vec2
(
mod
(
creaseMeta
[
0
],
u_textureDim
.
x
)
+
0.5
,
floor
(
creaseMeta
[
0
]
/
u_textureDim
.
x
)
+
0.5
)
/
u_textureDim
;
vec3
node1
=
getPosition
(
creaseMeta
[
0
]);
vec2
node2Index
=
vec2
(
mod
(
creaseMeta
[
1
],
u_textureDim
.
x
)
+
0.5
,
floor
(
creaseMeta
[
1
]
/
u_textureDim
.
x
)
+
0.5
)
/
u_textureDim
;
vec3
node2
=
getPosition
(
creaseMeta
[
1
]);
vec2
node3Index
=
vec2
(
mod
(
creaseMeta
[
2
],
u_textureDim
.
x
)
+
0.5
,
floor
(
creaseMeta
[
2
]
/
u_textureDim
.
x
)
+
0.5
)
/
u_textureDim
;
vec3
node3
=
getPosition
(
creaseMeta
[
2
]);
vec2
node4Index
=
vec2
(
mod
(
creaseMeta
[
3
],
u_textureDim
.
x
)
+
0.5
,
floor
(
creaseMeta
[
3
]
/
u_textureDim
.
x
)
+
0.5
)
/
u_textureDim
;
vec3
node4
=
getPosition
(
creaseMeta
[
3
]);
vec3
node1
=
texture2D
(
u_originalPosition
,
node1Index
).
xyz
+
texture2D
(
u_lastPosition
,
node1Index
).
xyz
;
vec3
node2
=
texture2D
(
u_originalPosition
,
node2Index
).
xyz
+
texture2D
(
u_lastPosition
,
node2Index
).
xyz
;
vec3
node3
=
texture2D
(
u_originalPosition
,
node3Index
).
xyz
+
texture2D
(
u_lastPosition
,
node3Index
).
xyz
;
vec3
node4
=
texture2D
(
u_originalPosition
,
node4Index
).
xyz
+
texture2D
(
u_lastPosition
,
node4Index
).
xyz
;
float
tol
=
0.01
;
float
tol
=
0.01
;
...
...
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