Commit dac26064 authored by amandaghassaei's avatar amandaghassaei

verlet integration in gpu

parent 147f2aba
......@@ -116,6 +116,17 @@ define(['glBoilerplate'], function(glBoilerplate){
this.frameBuffers[texture2Name] = temp;
};
GPUMath.prototype.swap3Textures = function(texture1Name, texture2Name, texture3Name){
var temp = this.textures[texture3Name];
this.textures[texture3Name] = this.textures[texture2Name];
this.textures[texture2Name] = this.textures[texture1Name];
this.textures[texture1Name] = temp;
temp = this.frameBuffers[texture3Name];
this.frameBuffers[texture3Name] = this.frameBuffers[texture2Name];
this.frameBuffers[texture2Name] = this.frameBuffers[texture1Name];
this.frameBuffers[texture1Name] = temp;
};
GPUMath.prototype.readyToRead = function(){
return gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE;
};
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,8 +3,9 @@ precision highp float;
uniform vec2 u_textureDim;
uniform float u_dt;
uniform sampler2D u_velocity;
uniform sampler2D u_acceleration;
uniform sampler2D u_lastTranslation;
uniform sampler2D u_lastLastTranslation;
uniform sampler2D u_mass;
void main(){
......@@ -18,9 +19,10 @@ void main(){
}
vec3 lastTranslation = texture2D(u_lastTranslation, scaledFragCoord).xyz;
vec3 velocity = texture2D(u_velocity, scaledFragCoord).xyz;
vec3 lastLastTranslation = texture2D(u_lastLastTranslation, scaledFragCoord).xyz;
vec3 acceleration = texture2D(u_acceleration, scaledFragCoord).xyz;
vec3 translation = lastTranslation + velocity*u_dt;
vec3 translation = 2.0*lastTranslation - lastLastTranslation + acceleration*u_dt*u_dt;
gl_FragColor = vec4(translation, 0);
}
\ No newline at end of file
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