Commit 651ae2ba authored by amandaghassaei's avatar amandaghassaei
Browse files

renaming

parent 84ad9608
......@@ -146,10 +146,10 @@
uniform sampler2D u_originalPosition;
uniform sampler2D u_externalForces;
uniform sampler2D u_mass;
uniform sampler2D u_meta;//[beamsIndex, numBeam, creaseMeta2Index, numCreases]
uniform sampler2D u_meta;//[beamsIndex, numBeam, nodeCreaseMetaIndex, numCreases]
uniform sampler2D u_beamMeta;//[k, d, length, otherNodeIndex]
uniform sampler2D u_creaseMeta;//[k, d, targetTheta]
uniform sampler2D u_creaseMeta2;//[creaseIndex, nodeIndex, -, -]
uniform sampler2D u_nodeCreaseMeta;//[creaseIndex, nodeIndex, -, -]
uniform sampler2D u_normals;
uniform sampler2D u_theta;//[theta, z, normal1Index, normal2Index]
uniform sampler2D u_creaseGeo;//[h1, h2, coef1, coef2]
......@@ -206,9 +206,9 @@
float nodeCreaseIndex1D = meta[2]+float(j);
vec2 nodeCreaseIndex = vec2(mod(nodeCreaseIndex1D, u_textureDimNodeCreases.x)+0.5, floor(nodeCreaseIndex1D/u_textureDimNodeCreases.x)+0.5);
vec2 scaledNodeCreaseIndex = nodeCreaseIndex/u_textureDimNodeCreases;
vec4 creaseMeta2 = texture2D(u_creaseMeta2, scaledNodeCreaseIndex);//[creaseIndex, length to node, nodeType (1 or 2), isReaction]
vec4 nodeCreaseMeta = texture2D(u_nodeCreaseMeta, scaledNodeCreaseIndex);//[creaseIndex, length to node, nodeType (1 or 2), isReaction]
float creaseIndex1D = creaseMeta2[0];
float creaseIndex1D = nodeCreaseMeta[0];
vec2 creaseIndex = vec2(mod(creaseIndex1D, u_textureDimCreases.x)+0.5, floor(creaseIndex1D/u_textureDimCreases.x)+0.5);
vec2 scaledCreaseIndex = creaseIndex/u_textureDimCreases;
......@@ -220,7 +220,7 @@
float targetTheta = creaseMeta[2] * u_creasePercent;
float angForce = creaseMeta[0]*(targetTheta-thetas[0]);// + creaseMeta[1]*thetas[1];
float nodeNum = creaseMeta2[1];//1, 2, 3, 4
float nodeNum = nodeCreaseMeta[1];//1, 2, 3, 4
if (nodeNum > 2.0){//crease reaction, node is on a crease
......@@ -375,13 +375,13 @@
uniform vec2 u_textureDimCreases;
uniform sampler2D u_lastPosition;
uniform sampler2D u_originalPosition;
uniform sampler2D u_creaseMeta3;
uniform sampler2D u_creaseMeta2;
void main(){
vec2 fragCoord = gl_FragCoord.xy;
vec2 scaledFragCoord = fragCoord/u_textureDimCreases;
vec4 creaseMeta = texture2D(u_creaseMeta3, 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;
vec2 node2Index = vec2(mod(creaseMeta[1], u_textureDim.x)+0.5, floor(creaseMeta[1]/u_textureDim.x)+0.5)/u_textureDim;
......
......@@ -25,9 +25,9 @@ function initDynamicSolver(globals){
var normals;
var faceVertexIndices;//[a,b,c]
var creaseMeta;//[k, d, targetTheta]
var creaseMeta2;//[creaseIndex (thetaIndex), nodeIndex (1/2/3/4), -, -]
var creaseMeta3;//[node1Index, node2Index, node3index, node4index]//nodes 1 and 2 are opposite crease, 3 and 4 are on crease
var creaseMeta;//[k, d, targetTheta, -] textureDimCreases
var creaseMeta2;//[node1Index, node2Index, node3index, node4index]//nodes 1 and 2 are opposite crease, 3 and 4 are on crease, textureDimCreases
var nodeCreaseMeta;//[creaseIndex (thetaIndex), nodeIndex (1/2/3/4), -, -] textureDimNodeCreases
var creaseGeo;//[h1, h2, coef1, coef2]
var creaseVectors;//indices of crease nodes
var theta;//[theta, w, normalIndex1, normalIndex2]
......@@ -129,12 +129,12 @@ function initDynamicSolver(globals){
gpuMath.setProgram("updateCreaseGeo");
//already at textureDimCreasesxtextureDimCreases
gpuMath.step("updateCreaseGeo", ["u_lastPosition", "u_originalPosition", "u_creaseMeta3"], "u_creaseGeo");
gpuMath.step("updateCreaseGeo", ["u_lastPosition", "u_originalPosition", "u_creaseMeta2"], "u_creaseGeo");
gpuMath.setProgram("velocityCalc");
gpuMath.setSize(textureDim, textureDim);
gpuMath.step("velocityCalc", ["u_lastPosition", "u_lastVelocity", "u_originalPosition", "u_externalForces",
"u_mass", "u_meta", "u_beamMeta", "u_creaseMeta", "u_creaseMeta2", "u_normals", "u_theta", "u_creaseGeo"], "u_velocity");
"u_mass", "u_meta", "u_beamMeta", "u_creaseMeta", "u_nodeCreaseMeta", "u_normals", "u_theta", "u_creaseGeo"], "u_velocity");
gpuMath.step("positionCalc", ["u_velocity", "u_lastPosition", "u_mass"], "u_position");
gpuMath.swapTextures("u_theta", "u_lastTheta");
......@@ -264,8 +264,8 @@ function initDynamicSolver(globals){
gpuMath.initFrameBufferForTexture("u_normals", true);
gpuMath.initTextureFromData("u_meta", textureDim, textureDim, "FLOAT", meta, true);
gpuMath.initTextureFromData("u_creaseMeta2", textureDimNodeCreases, textureDimNodeCreases, "FLOAT", creaseMeta2, true);
gpuMath.initTextureFromData("u_creaseMeta3", textureDimCreases, textureDimCreases, "FLOAT", creaseMeta3, true);
gpuMath.initTextureFromData("u_nodeCreaseMeta", textureDimNodeCreases, textureDimNodeCreases, "FLOAT", nodeCreaseMeta, true);
gpuMath.initTextureFromData("u_creaseMeta2", textureDimCreases, textureDimCreases, "FLOAT", creaseMeta2, true);
gpuMath.initTextureFromData("u_creaseGeo", textureDimCreases, textureDimCreases, "FLOAT", creaseGeo, true);
gpuMath.initFrameBufferForTexture("u_creaseGeo", true);
gpuMath.initTextureFromData("u_faceVertexIndices", textureDimFaces, textureDimFaces, "FLOAT", faceVertexIndices, true);
......@@ -285,7 +285,7 @@ function initDynamicSolver(globals){
gpuMath.setUniformForProgram("velocityCalc", "u_meta", 5, "1i");
gpuMath.setUniformForProgram("velocityCalc", "u_beamMeta", 6, "1i");
gpuMath.setUniformForProgram("velocityCalc", "u_creaseMeta", 7, "1i");
gpuMath.setUniformForProgram("velocityCalc", "u_creaseMeta2", 8, "1i");
gpuMath.setUniformForProgram("velocityCalc", "u_nodeCreaseMeta", 8, "1i");
gpuMath.setUniformForProgram("velocityCalc", "u_normals", 9, "1i");
gpuMath.setUniformForProgram("velocityCalc", "u_theta", 10, "1i");
gpuMath.setUniformForProgram("velocityCalc", "u_creaseGeo", 11, "1i");
......@@ -331,7 +331,7 @@ function initDynamicSolver(globals){
gpuMath.createProgram("updateCreaseGeo", vertexShader, document.getElementById("updateCreaseGeo").text);
gpuMath.setUniformForProgram("updateCreaseGeo", "u_lastPosition", 0, "1i");
gpuMath.setUniformForProgram("updateCreaseGeo", "u_originalPosition", 1, "1i");
gpuMath.setUniformForProgram("updateCreaseGeo", "u_creaseMeta3", 2, "1i");
gpuMath.setUniformForProgram("updateCreaseGeo", "u_creaseMeta2", 2, "1i");
gpuMath.setUniformForProgram("updateCreaseGeo", "u_textureDim", [textureDim, textureDim], "2f");
gpuMath.setUniformForProgram("updateCreaseGeo", "u_textureDimCreases", [textureDimCreases, textureDimCreases], "2f");
......@@ -475,8 +475,8 @@ function initDynamicSolver(globals){
normals = new Float32Array(textureDimFaces*textureDimFaces*4);
faceVertexIndices = new Float32Array(textureDimFaces*textureDimFaces*4);
creaseMeta = new Float32Array(textureDimCreases*textureDimCreases*4);
creaseMeta2 = new Float32Array(textureDimNodeCreases*textureDimNodeCreases*4);
creaseMeta3 = new Float32Array(textureDimCreases*textureDimCreases*4);
nodeCreaseMeta = new Float32Array(textureDimNodeCreases*textureDimNodeCreases*4);
creaseMeta2 = new Float32Array(textureDimCreases*textureDimCreases*4);
creaseGeo = new Float32Array(textureDimCreases*textureDimCreases*4);
creaseVectors = new Float32Array(textureDimCreases*textureDimCreases*4);
theta = new Float32Array(textureDimCreases*textureDimCreases*4);
......@@ -512,22 +512,22 @@ function initDynamicSolver(globals){
// console.log(nodeInvCreases);
meta[i*4+3] = nodeCreases.length + nodeInvCreases.length;
for (var j=0;j<nodeCreases.length;j++){
creaseMeta2[index*4] = nodeCreases[j].getIndex();
creaseMeta2[index*4+1] = nodeCreases[j].getNodeIndex(nodes[i]);//type 1, 2, 3, 4
nodeCreaseMeta[index*4] = nodeCreases[j].getIndex();
nodeCreaseMeta[index*4+1] = nodeCreases[j].getNodeIndex(nodes[i]);//type 1, 2, 3, 4
index++;
}
for (var j=0;j<nodeInvCreases.length;j++){
creaseMeta2[index*4] = nodeInvCreases[j].getIndex();
creaseMeta2[index*4+1] = nodeInvCreases[j].getNodeIndex(nodes[i]);//type 1, 2, 3, 4
nodeCreaseMeta[index*4] = nodeInvCreases[j].getIndex();
nodeCreaseMeta[index*4+1] = nodeInvCreases[j].getNodeIndex(nodes[i]);//type 1, 2, 3, 4
index++;
}
}
for (var i=0;i<creases.length;i++){
var crease = creases[i];
creaseMeta3[i*4] = crease.node1.getIndex();
creaseMeta3[i*4+1] = crease.node2.getIndex();
creaseMeta3[i*4+2] = crease.edge.nodes[0].getIndex();
creaseMeta3[i*4+3] = crease.edge.nodes[1].getIndex();
creaseMeta2[i*4] = crease.node1.getIndex();
creaseMeta2[i*4+1] = crease.node2.getIndex();
creaseMeta2[i*4+2] = crease.edge.nodes[0].getIndex();
creaseMeta2[i*4+3] = crease.edge.nodes[1].getIndex();
index++;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment