Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nathan's pull request #18

Open
wants to merge 69 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
ba1310f
Now we have simple force calculation working.
Oct 19, 2013
8e8b438
Got the basic height field working.
Oct 19, 2013
b38c305
Well, now we no longer hit any debug asserts.
Oct 19, 2013
aac4c75
Now we have the naive force calculation working.
Oct 19, 2013
1563889
Merge remote-tracking branch 'upstream/master'
Oct 19, 2013
0cb976d
Now we can draw the planets as squares. Yay!
Oct 19, 2013
3ab774e
Now we have our nice spacetime shader. Time to move onto using shared
Oct 19, 2013
0657af0
Performance comparison done on naiveAcc. Time to implement sharedAcc.
Oct 19, 2013
753c509
Code is down for shared memory, and it compiles. Next step is to see …
Oct 19, 2013
f41cbcb
Working with shared memory!
Oct 19, 2013
12b7d7a
Added profile. Bumped up the number of planets. Now I also have a tile
Oct 20, 2013
9236bd4
Code is down for tiling, but with our small initial example it doesn't
Oct 20, 2013
2837e89
Shared works for 32 bodies (one tile)
Oct 20, 2013
da3f054
Now using shared memory works for 64 bodies
Oct 20, 2013
452bcaf
Now working on 1024 bodies. Shared memory actually makes it worse with
Oct 20, 2013
8227fca
Added implicit Euler
Oct 20, 2013
9879c9d
Using a cutoff radius gets us better results.
Oct 20, 2013
9ea2448
Last commit before we try prefetching
Oct 20, 2013
1bc38a5
Loop unrolling appears to work!
Oct 20, 2013
7406d23
Now we don't have to manually adjust the tile size. Still appears to be
Oct 20, 2013
807ec3d
Changed blockSize so that now we pass it in
Oct 20, 2013
0217fef
Went ahead and proved that the tile size CAN be larger than the block
Oct 20, 2013
32584c9
Now we can print out the elapsed time for the first 100 kernel execut…
Oct 20, 2013
7a315e3
Last commit before we attempt to add collisions!
Oct 21, 2013
1da2776
Code down for collisions
Oct 21, 2013
1530f48
Almost ready to add in collisions.
Oct 21, 2013
5a1feee
Added collisions. Not quite working... is the radius too small?
Oct 21, 2013
7c7e571
Collisions seem to work. Radius is small
Oct 21, 2013
099fc9b
It works! Penalty force seems a little funny though
Oct 21, 2013
7ef81c9
Elastic collisions work!
Oct 21, 2013
f50fd26
Collision detection works well, with nice clumping.
Oct 21, 2013
6f91518
Going back to no collisions for nao.
Oct 21, 2013
a5c67e8
Last commit before adding RK4
Oct 21, 2013
681b3e8
Updated README
Oct 21, 2013
b91bb5a
Revert "Updated README"
Oct 21, 2013
74a57a3
Revert "Last commit before adding RK4"
Oct 21, 2013
c25a416
Collision detection is now back in!
Oct 21, 2013
105963f
Now we are back to the "standard" demo. Time to add flocking!
Oct 21, 2013
c93f600
Now collisions conserve energy (or at least are better at conserving
Oct 21, 2013
d43a784
Duplicated the nbody project in order to start with flocking.
Oct 21, 2013
c6fb6a0
Well, the star mass is zero. I'll figure out how to get rid of it later.
Oct 22, 2013
5c1440c
Well, now we have a pointer to the device position vector
Oct 22, 2013
524ebee
Got the guy to work. It's a little buggy though.
Oct 22, 2013
a4acc1e
Added control law. Dunno if it works though.
Oct 22, 2013
2121915
Well, now we get the ball moving independetly of the other stuff
Oct 23, 2013
df5be3b
Merge branch 'master' of https://github.com/nmarshak1337/CUDA-NBody-Sim
Oct 23, 2013
a454db5
Now it actually works.
Oct 23, 2013
0954019
Got seek working. Disabled collisions, because it causes horrible,
Oct 23, 2013
794b798
Got arrival working, I think.
Oct 23, 2013
f0a7147
Separation works!
Oct 23, 2013
311df47
Added enum for behavior type
Oct 23, 2013
99021bf
Switching between states works. Separation spazzes a bit when agents are
Oct 23, 2013
9a8a4e5
Prevented separation from spazzing.
Oct 23, 2013
6e67966
Leader following works
Oct 23, 2013
26ba57f
Turned the planets into triangles. I just need the triangles to rotat…
Oct 23, 2013
287d8ad
Got triangles to rotate! Yippee!
Oct 23, 2013
28f76da
We've proved that we change rotation dynamically. Now it's time to
Oct 23, 2013
ac97e3f
Got the rotation array working.
Oct 23, 2013
792eb30
Angles are expressed as FLOATS now.
Oct 23, 2013
b7252f8
Added angular velocity array
Oct 23, 2013
56269b1
Code is down for calculation of control torque.
Oct 23, 2013
b0a3074
Base framework is now there for angular accelerations.
Oct 23, 2013
4744d27
Well, now we have torques. Phew!
Oct 23, 2013
a633f8c
Ready to drop in numerical integration of angle/angular velocity
Oct 23, 2013
bba641a
Numerical integration of angular acceleration is there. Now to give it a
Oct 23, 2013
89ffc51
Angle control works... sort of!
Oct 23, 2013
3e93738
Got angle control to work!
Oct 23, 2013
790f6d8
Updated README
Oct 23, 2013
0d4df48
We are back to using shared, tile size and block size are both 128
Oct 23, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 6 additions & 2 deletions Part1/PROJ_WIN/Project3/Project3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{D7BEFF7A-4902-4B7E-922B-B0417A66864C}</ProjectGuid>
<RootNamespace>Project3</RootNamespace>
<ProjectName>NBODY</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand All @@ -26,7 +27,7 @@
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
<PlatformToolset>v100</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -62,7 +63,7 @@
<GPUDebugInfo>true</GPUDebugInfo>
<GenerateLineInfo>true</GenerateLineInfo>
<HostDebugInfo>true</HostDebugInfo>
<CodeGeneration>compute_10,sm_10;compute_20,sm_20;compute_30,sm_30</CodeGeneration>
<CodeGeneration>compute_10,sm_10;</CodeGeneration>
</CudaCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -71,11 +72,14 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include;C:/ProgramData/NVIDIA Corporation/CUDA Samples/v5.5/common/inc;../shared/glew/includes;../shared/freeglut/includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>../shared/glew/lib;../shared/freeglut/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>cudart.lib; glew32.lib;glu32.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
8 changes: 7 additions & 1 deletion Part1/PROJ_WIN/Project3/shaders/heightFS.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
varying float f_height;
varying vec2 v_Texcoords;

void main(void)
{
gl_FragColor = vec4(0.05,0.15,0.3,1.0);
float shade = (1.0-2.0*sqrt(f_height));
float alpha = float(mod(v_Texcoords.x+0.025, 0.05) > 0.046 || mod(v_Texcoords.y+0.025, 0.05) > 0.046);
vec4 color = mix(vec4(0.05,0.15,0.3,1.0), vec4(0.05, 0.3, 0.4, 1.0), alpha);
gl_FragColor = shade*color;
}
15 changes: 12 additions & 3 deletions Part1/PROJ_WIN/Project3/shaders/heightVS.glsl
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
uniform mat4 u_projMatrix;
uniform sampler2D u_height;

attribute vec4 Position;
attribute vec2 Texcoords;

varying vec2 v_Texcoords;
varying float f_height;

void main(void)
{
vec4 pos = u_projMatrix * Position;
pos.z += 0.01;
gl_Position = pos;
v_Texcoords = Texcoords;
vec4 pos = Position;
f_height = texture2D(u_height, Texcoords).w;
pos.z = -0.01-clamp(f_height,0.0,2.0);
pos = u_projMatrix * pos;
gl_Position = pos;
}
28 changes: 25 additions & 3 deletions Part1/PROJ_WIN/Project3/shaders/planetFS.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
void main(void)
#version 330

in vec3 WorldCoord;
in vec3 ToCam;
in vec3 Up;
in vec3 Right;
in vec2 TexCoord;
out vec4 FragColor;

void main()
{
gl_FragColor = vec4(1.0);
}
vec2 coord = 2.01 * (TexCoord - vec2(0.5));
float r = length(coord);
if (r >= 1.0) { discard; }
float dist = length(WorldCoord);
if(dist <= 0.01)
{
FragColor = vec4(1.0);
return;
}
vec3 N = Right*-coord.x + Up*coord.y + ToCam*sqrt(1-r*r);
vec3 L = normalize(-WorldCoord);
float light = 0.1 + 0.9*clamp(dot(N,L),0.0, 1.0)*exp(-dist);
vec3 color = vec3(0.4, 0.1, 0.6);
FragColor = vec4(color*light,1.0);
}
40 changes: 37 additions & 3 deletions Part1/PROJ_WIN/Project3/shaders/planetGS.glsl
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
#version 330

uniform mat4 u_projMatrix;
uniform vec3 u_cameraPos;

layout (points) in;
layout (points) out;
layout (max_vertices = 1) out;
layout (triangle_strip) out;
layout (max_vertices = 4) out;

out vec3 WorldCoord;
out vec3 ToCam;
out vec3 Up;
out vec3 Right;
out vec2 TexCoord;

const float scale = 0.03;

void main()
{
vec3 Position = gl_in[0].gl_Position.xyz;
gl_Position = u_projMatrix * vec4(Position, 1.0);
WorldCoord = Position;

ToCam = normalize(u_cameraPos - Position);
Up = vec3(0.0, 0.0, 1.0);
Right = cross(ToCam, Up);
Up = cross(Right, ToCam);

vec3 Pos = Position + scale*Right - scale*Up;
gl_Position = u_projMatrix * vec4(Pos, 1.0);
TexCoord = vec2(0.0, 0.0);
EmitVertex();

Pos = Position + scale*Right + scale*Up;
gl_Position = u_projMatrix * vec4(Pos, 1.0);
TexCoord = vec2(0.0, 1.0);
EmitVertex();

Pos = Position - scale*Right - scale*Up;
gl_Position = u_projMatrix * vec4(Pos, 1.0);
TexCoord = vec2(1.0, 0.0);
EmitVertex();

Pos = Position - scale*Right + scale*Up;
gl_Position = u_projMatrix * vec4(Pos, 1.0);
TexCoord = vec2(1.0, 1.0);
EmitVertex();

EndPrimitive();
}
Loading