Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e40066f
Implemented naive acceleration calculation.
cboots Oct 17, 2013
3f66cac
Implemented planet shading.
cboots Oct 17, 2013
db58752
Improved integration error with accel softening term.
cboots Oct 19, 2013
73d6448
Implemented shared memory. Turns out it's slower, I must be doing som…
cboots Oct 19, 2013
2933a3b
Merge branch 'master' of https://github.com/CIS565-Fall-2013/Project3…
cboots Oct 20, 2013
742f8f0
Implemented shared memory version.
cboots Oct 20, 2013
f63154f
Moved part 1 to planets project
cboots Oct 20, 2013
05cb17e
Added boids project with some work on shaders done.
cboots Oct 20, 2013
a218bc0
Updated project.
cboots Oct 20, 2013
9a69c54
Removed unneeded files.
cboots Oct 20, 2013
2c27be1
Implemented basic boid shader.
cboots Oct 20, 2013
fff551c
Fixed bug in geometry shader normals not being transformed.
cboots Oct 20, 2013
1951b5c
Reworked shaders to be more correct and flexible.
cboots Oct 21, 2013
f008f90
Finished modifications to original project and everything compiles now.
cboots Oct 21, 2013
12d980b
Added some debug code to try to fix shaders.
cboots Oct 21, 2013
5ac2832
Sonofabitch. I was defining interleaved buffer stride by number of el…
cboots Oct 21, 2013
2393aa4
Played around with camera perspectives and fixed issue with Up Vector
cboots Oct 21, 2013
5df8a18
Good view of 1000 boids
cboots Oct 21, 2013
65709eb
Added arched back to BOIDS
cboots Oct 21, 2013
9960b98
Lighting still broken, but added 3D Geometry to shader
cboots Oct 21, 2013
aedfce9
Issue was radians not degrees.... >.<
cboots Oct 21, 2013
0618c67
Pushing the limits of performance on laptop.
cboots Oct 21, 2013
9278489
Changed deflection angle to be software set not glsl.
cboots Oct 21, 2013
b1114eb
Flock is now visible and following simple fly up behavior as a demons…
cboots Oct 22, 2013
3d1edc2
Added worldprops struct to hold info about the environment. Provides …
cboots Oct 22, 2013
a516068
Added ground avoidance
cboots Oct 22, 2013
9dde02e
Fixed odd boundary condition with gimble lock straight up.
cboots Oct 22, 2013
c005fbc
DO A BARREL ROLL!
cboots Oct 22, 2013
249b953
Increased view depth.
cboots Oct 22, 2013
95561c2
Fixed bug with walls sucking boids into infinity.
cboots Oct 22, 2013
912e898
Implemented fish-like schooling behavior.
cboots Oct 22, 2013
0dbc87b
Changed alignment rule to ignore speed.
cboots Oct 22, 2013
1262871
Added force saturation.
cboots Oct 22, 2013
6850e30
Something weird is happening to half the flock. Indexing bug?
cboots Oct 22, 2013
d3c1e6d
Reworked kernel and parameters to fix block bug. Flocking behavior no…
cboots Oct 23, 2013
2e0c27d
Built in Release mode. Fish schooling behavior is reasonable again.
cboots Oct 23, 2013
749c7c7
Added some screenshots
cboots Oct 23, 2013
d133857
Update README.md
cboots Oct 23, 2013
163afa4
Update README.md
cboots Oct 23, 2013
0b73e09
Added prefetch chart.
cboots Oct 23, 2013
b97f6d6
Merge branch 'master' of https://github.com/cboots/Project3-Simulation
cboots Oct 23, 2013
655196d
Update README.md
cboots Oct 23, 2013
6947206
Update README.md
cboots 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
  •  
  •  
  •  
115 changes: 115 additions & 0 deletions Boids/Boids Flocking/Boids Flocking.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\cudaMat4.h" />
<ClInclude Include="..\src\glFields.h" />
<ClInclude Include="..\src\glslUtility.h" />
<ClInclude Include="..\src\kernel.h" />
<ClInclude Include="..\src\main.h" />
<ClInclude Include="..\src\utilities.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\glFields.cpp" />
<ClCompile Include="..\src\glslUtility.cpp" />
<ClCompile Include="..\src\main.cpp" />
<ClCompile Include="..\src\utilities.cpp" />
</ItemGroup>
<ItemGroup>
<CudaCompile Include="..\src\kernel.cu" />
</ItemGroup>
<ItemGroup>
<None Include="shaders\boidFS.glsl" />
<None Include="shaders\boidGS.glsl" />
<None Include="shaders\boidVS.glsl" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D7BEFF7A-4902-4B7E-922B-B0417A66864C}</ProjectGuid>
<RootNamespace>Project3</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 5.5.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<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>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<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>
<SubSystem>Console</SubSystem>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
<CudaCompile>
<Include>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</Include>
<CompileOut>$(ProjectDir)$(Platform)/$(Configuration)/%(Filename)%(Extension).obj</CompileOut>
<GPUDebugInfo>true</GPUDebugInfo>
<GenerateLineInfo>true</GenerateLineInfo>
<HostDebugInfo>true</HostDebugInfo>
<CodeGeneration>compute_10,sm_10;compute_20,sm_20;compute_30,sm_30</CodeGeneration>
</CudaCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<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>
</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>
<CudaCompile>
<Include>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</Include>
<CompileOut>$(ProjectDir)$(Platform)/$(Configuration)/%(Filename)%(Extension).obj</CompileOut>
<CodeGeneration>compute_10,sm_10;compute_20,sm_20;compute_30,sm_30</CodeGeneration>
</CudaCompile>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\CUDA 5.5.targets" />
</ImportGroup>
</Project>
67 changes: 67 additions & 0 deletions Boids/Boids Flocking/Boids Flocking.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Header Files">
<UniqueIdentifier>{34e81b93-fee9-4d66-a05e-67ce494472ae}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Source Files">
<UniqueIdentifier>{b073acb6-04b2-466e-865f-609d73000662}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{e810980a-d5f5-4bc2-9d61-f5fb91044ef7}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\cudaMat4.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\glslUtility.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\kernel.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\main.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\utilities.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\glFields.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\glslUtility.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\utilities.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\glFields.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CudaCompile Include="..\src\kernel.cu">
<Filter>Source Files</Filter>
</CudaCompile>
</ItemGroup>
<ItemGroup>
<None Include="shaders\boidFS.glsl">
<Filter>Resource Files</Filter>
</None>
<None Include="shaders\boidGS.glsl">
<Filter>Resource Files</Filter>
</None>
<None Include="shaders\boidVS.glsl">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>
26 changes: 26 additions & 0 deletions Boids/Boids Flocking/shaders/boidFS.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#version 330

uniform mat4 u_projMatrix;
uniform mat4 u_viewMatrix;
uniform vec3 u_lightPos;


in vec3 fs_EyeNormal;
in vec3 fs_Color;
in vec3 fs_EyeLightVector;
in vec2 fs_TexCoord;


out vec4 FragColor;

void main()
{

vec4 diffuseColor = vec4(fs_Color, 1.0);

//calculate diffuse term and clamp to the range [0, 1]
float diffuseTerm = clamp(dot(normalize(fs_EyeNormal), normalize(fs_EyeLightVector)), 0.0, 1.0);

//TODO: Use texture coordinates in some way
FragColor = diffuseColor*(diffuseTerm*0.9+0.1);//Small 5% ambient term
}
173 changes: 173 additions & 0 deletions Boids/Boids Flocking/shaders/boidGS.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
#version 330

uniform mat4 u_projMatrix;
uniform mat4 u_viewMatrix;
uniform vec3 u_lightPos;


layout (points) in;
layout (triangle_strip, max_vertices = 12) out;


in VertexData{
vec3 EyeNormal;
vec3 EyeForward;
vec3 Color;
float Length;
float HalfWingSpan;
float DeltaSweep;
float HalfBodyHeight;
float WingDeflection;
}vertexData[];


out vec3 fs_EyeNormal;
out vec3 fs_Color;
out vec3 fs_EyeLightVector;
out vec2 fs_TexCoord;



//From http://www.neilmendoza.com/glsl-rotation-about-an-arbitrary-axis/
mat4 rotationMatrix(vec3 axis, float angle)
{
axis = normalize(axis);
float s = sin(angle);
float c = cos(angle);
float oc = 1.0 - c;

return mat4(oc * axis.x * axis.x + c, oc * axis.x * axis.y - axis.z * s, oc * axis.z * axis.x + axis.y * s, 0.0,
oc * axis.x * axis.y + axis.z * s, oc * axis.y * axis.y + c, oc * axis.y * axis.z - axis.x * s, 0.0,
oc * axis.z * axis.x - axis.y * s, oc * axis.y * axis.z + axis.x * s, oc * axis.z * axis.z + c, 0.0,
0.0, 0.0, 0.0, 1.0);
}


void main()
{
vec3 Position = gl_in[0].gl_Position.xyz;

vec3 Up = normalize(vertexData[0].EyeNormal.xyz);
vec3 Forward = normalize(vertexData[0].EyeForward.xyz);
vec3 Right = normalize(cross(Forward, Up));

mat4 Rotate = rotationMatrix(Forward, vertexData[0].WingDeflection);
mat4 Rotate_T = transpose(Rotate);

//Passthrough color
fs_Color = vertexData[0].Color;

vec3 EyeLightPos = vec3(u_viewMatrix*vec4(u_lightPos, 1.0));
vec3 BackTopPos = Position + vertexData[0].HalfBodyHeight*Up;
vec3 BackBottomPos = Position - vertexData[0].HalfBodyHeight*Up;
vec3 RightWingtipPos = Position + vec3(Rotate * vec4(-vertexData[0].DeltaSweep*Forward + vertexData[0].HalfWingSpan*Right,0.0));
vec3 LeftWingtipPos = Position + vec3(Rotate_T * vec4(-vertexData[0].DeltaSweep*Forward - vertexData[0].HalfWingSpan*Right,0.0));
vec3 FrontPos = Position + vertexData[0].Length*Forward;

vec3 RightTipUpNormal = normalize(cross(FrontPos - RightWingtipPos, BackTopPos-RightWingtipPos ));
vec3 RightTipDownNormal = normalize(cross(BackBottomPos-RightWingtipPos, FrontPos-RightWingtipPos ));
vec3 LeftTipUpNormal = normalize(cross(BackTopPos-LeftWingtipPos, FrontPos - LeftWingtipPos ));
vec3 LeftTipDownNormal = normalize(cross(FrontPos-LeftWingtipPos, BackBottomPos-LeftWingtipPos));
vec3 TopNormal = normalize((RightTipUpNormal +LeftTipUpNormal )/2.0);
vec3 BottomNormal = normalize((RightTipDownNormal+LeftTipDownNormal)/2.0);
vec3 BackLeftTipNormal = normalize(cross(BackBottomPos-LeftWingtipPos, BackTopPos-LeftWingtipPos));
vec3 BackRightTipNormal = normalize(cross(BackTopPos-RightWingtipPos, BackBottomPos-RightWingtipPos));
vec3 BackNormal = normalize((BackRightTipNormal + BackLeftTipNormal)/2.0);

//************TOP Strip**************
//=====Compute right wingtip======
gl_Position = u_projMatrix*vec4(RightWingtipPos,1.0);
fs_EyeNormal = RightTipUpNormal;
fs_EyeLightVector = EyeLightPos - RightWingtipPos;
fs_TexCoord = vec2(1.0,0.0);
EmitVertex();

//=====Compute front point======
gl_Position = u_projMatrix*vec4(FrontPos,1.0);
fs_EyeNormal = TopNormal;
fs_EyeLightVector = EyeLightPos - FrontPos;
fs_TexCoord = vec2(0.5,0.5);
EmitVertex();

//====Compute back center top point====
gl_Position = u_projMatrix*vec4(BackTopPos,1.0);
fs_EyeNormal = TopNormal;
fs_EyeLightVector = EyeLightPos - BackTopPos;
fs_TexCoord = vec2(0.5,0.0);
EmitVertex();

//====Compute left wingtip====
gl_Position = u_projMatrix*vec4(LeftWingtipPos,1.0);
fs_EyeNormal = LeftTipUpNormal;
fs_EyeLightVector = EyeLightPos - LeftWingtipPos;
fs_TexCoord = vec2(0.0,0.0);
EmitVertex();

EndPrimitive();


//************BOTTOM Strip**************
//=====Compute right wingtip======
gl_Position = u_projMatrix*vec4(RightWingtipPos,1.0);
fs_EyeNormal = RightTipDownNormal;
fs_EyeLightVector = EyeLightPos - RightWingtipPos;
fs_TexCoord = vec2(1.0,1.0);
EmitVertex();

//=====Compute back center bottom point======
gl_Position = u_projMatrix*vec4(BackBottomPos,1.0);
fs_EyeNormal = BottomNormal;
fs_EyeLightVector = EyeLightPos - BackBottomPos;
fs_TexCoord = vec2(0.5,1.0);
EmitVertex();

//====Compute front point====
gl_Position = u_projMatrix*vec4(FrontPos,1.0);
fs_EyeNormal = BottomNormal;
fs_EyeLightVector = EyeLightPos - FrontPos;
fs_TexCoord = vec2(0.5,0.5);
EmitVertex();

//====Compute left wingtip====
gl_Position = u_projMatrix*vec4(LeftWingtipPos,1.0);
fs_EyeNormal = LeftTipDownNormal;
fs_EyeLightVector = EyeLightPos - LeftWingtipPos;
fs_TexCoord = vec2(0.0,1.0);
EmitVertex();

EndPrimitive();




//************BACK Strip**************
//=====Compute right wingtip======
gl_Position = u_projMatrix*vec4(RightWingtipPos,1.0);
fs_EyeNormal = BackRightTipNormal;
fs_EyeLightVector = EyeLightPos - RightWingtipPos;
fs_TexCoord = vec2(0.0,0.0);
EmitVertex();

//=====Compute back center top point======
gl_Position = u_projMatrix*vec4(BackTopPos,1.0);
fs_EyeNormal = BackNormal;
fs_EyeLightVector = EyeLightPos - BackTopPos;
fs_TexCoord = vec2(0.5,0.5);
EmitVertex();

//=====Compute back center bottom point======
gl_Position = u_projMatrix*vec4(BackBottomPos,1.0);
fs_EyeNormal = BackNormal;
fs_EyeLightVector = EyeLightPos - BackBottomPos;
fs_TexCoord = vec2(0.0,0.5);
EmitVertex();

//====Compute left wingtip====
gl_Position = u_projMatrix*vec4(LeftWingtipPos,1.0);
fs_EyeNormal = BackLeftTipNormal;
fs_EyeLightVector = EyeLightPos - LeftWingtipPos;
fs_TexCoord = vec2(0.0,1.0);
EmitVertex();

EndPrimitive();
}
Loading