Skip to content

Project 3 Submission #5

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

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5d175d5
force calculations
mchen15 Oct 18, 2013
e70cbdf
commenting base code and changed project name
mchen15 Oct 18, 2013
c008d44
additional comments
mchen15 Oct 18, 2013
853e5fb
updated shaders
mchen15 Oct 18, 2013
c163e6c
rk2
mchen15 Oct 19, 2013
488c9eb
race condition bug fix
mchen15 Oct 19, 2013
2d1e455
part 1 completed.
mchen15 Oct 19, 2013
7849071
renamed project
mchen15 Oct 19, 2013
45d6dbd
added timing code
mchen15 Oct 19, 2013
cf2e94d
added part 2 and deleted linux projects
mchen15 Oct 19, 2013
1d0fad3
fixed shared memory bug
mchen15 Oct 20, 2013
f8e6260
removed linux project files from part 2
mchen15 Oct 20, 2013
16cdf4c
untested alignment, cohesion, separation, and flocking
mchen15 Oct 20, 2013
0841867
continue debugging flocking
mchen15 Oct 20, 2013
1ffbeeb
added arrival. Fixing flocking still
mchen15 Oct 20, 2013
d8a6c84
added pause button. Separation done
mchen15 Oct 20, 2013
3471d41
cohesion done
mchen15 Oct 20, 2013
30ad964
alginment done
mchen15 Oct 20, 2013
924f023
flocking done
mchen15 Oct 20, 2013
f435492
adjusted arrival
mchen15 Oct 20, 2013
e7b514b
commit before attempting to use acceleration instead
mchen15 Oct 20, 2013
7e3968a
acceleration stuff commented out for now
mchen15 Oct 21, 2013
e753952
fixed shared memory problem
mchen15 Oct 21, 2013
ce4bd4b
more modifications for the flocking portion
mchen15 Oct 22, 2013
809dea1
change sphere shading for part 1
mchen15 Oct 22, 2013
f380867
changed boids shading for part 2
mchen15 Oct 22, 2013
c00c69a
update readme for part 1
mchen15 Oct 22, 2013
d97fe6e
added chart and updated readme for part 1
mchen15 Oct 22, 2013
f1f170c
Update README.md
mchen15 Oct 22, 2013
6e31608
switches for rendering plane in part2
mchen15 Oct 22, 2013
a98ef76
Merge branch 'master' of https://github.com/mchen15/Project3-Simulation
mchen15 Oct 22, 2013
896110a
Updated readme
mchen15 Oct 22, 2013
c17f6b7
Fixed bug when using glm::normalize. Passing velocity vector to shaders
mchen15 Oct 22, 2013
ad7135e
position wrapping
mchen15 Oct 23, 2013
cb82415
coding done
mchen15 Oct 23, 2013
9abd994
updated readme
mchen15 Oct 23, 2013
bd39993
updated readme again
mchen15 Oct 23, 2013
b4814e8
read me update
mchen15 Oct 23, 2013
4f3858f
initialize vel to 0 and updated read me
mchen15 Oct 23, 2013
0cdb188
updated read me
mchen15 Oct 23, 2013
cb53d4b
final read me update
mchen15 Oct 23, 2013
3434336
Update README.md
mchen15 Oct 23, 2013
983b019
Update README.md
mchen15 Oct 23, 2013
fca6e54
Update README.md
mchen15 Oct 23, 2013
3bba6fb
additional video footage
mchen15 Oct 23, 2013
c1ebc6f
Update README.md
mchen15 Oct 24, 2013
a93c8b6
Update README.md
mchen15 Feb 12, 2014
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
  •  
  •  
  •  
33 changes: 0 additions & 33 deletions Part1/PROJ_NIX/makefile

This file was deleted.

4 changes: 0 additions & 4 deletions Part1/PROJ_NIX/shaders/heightFS.glsl

This file was deleted.

9 changes: 0 additions & 9 deletions Part1/PROJ_NIX/shaders/heightVS.glsl

This file was deleted.

4 changes: 0 additions & 4 deletions Part1/PROJ_NIX/shaders/planetFS.glsl

This file was deleted.

15 changes: 0 additions & 15 deletions Part1/PROJ_NIX/shaders/planetGS.glsl

This file was deleted.

8 changes: 0 additions & 8 deletions Part1/PROJ_NIX/shaders/planetVS.glsl

This file was deleted.

File renamed without changes.
10 changes: 9 additions & 1 deletion Part1/PROJ_WIN/Project3/Project3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{D7BEFF7A-4902-4B7E-922B-B0417A66864C}</ProjectGuid>
<RootNamespace>Project3</RootNamespace>
<ProjectName>Project3-Part1</ProjectName>
</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>v100</PlatformToolset>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
Expand Down Expand Up @@ -71,12 +72,19 @@
<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>
<SubSystem>Console</SubSystem>
</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>
</CudaCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\glslUtility.cpp" />
Expand Down
13 changes: 11 additions & 2 deletions Part1/PROJ_WIN/Project3/shaders/heightFS.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
varying vec2 v_Texcoords;
varying float f_height;

void main(void)
{
gl_FragColor = vec4(0.05,0.15,0.3,1.0);
}
float shade = (0.8-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);
//vec4 color = mix(vec4(0,0,0, 1.0), vec4(0.49,1,0.3,0), alpha);
vec4 color = mix(vec4(1,1,1, 1.0), vec4(0.49,1,0.3,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.z moves the plane up and down & the clamp parameters decides the max/min depth of the hole
pos = u_projMatrix * pos;
gl_Position = pos;
}
40 changes: 37 additions & 3 deletions Part1/PROJ_WIN/Project3/shaders/planetFS.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
void main(void)
#version 330

in fColor
{
gl_FragColor = vec4(1.0);
}
vec3 color;
}frag;

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

out vec4 FragColor;

void main()
{
// takes the "texture" coordinates produces in the GS and uses them to decide where in the quad this fragment is.
// We discard any fragments outside of our desired radius in order to simulate the edge of the sphere.
vec2 coord = 2.01 * (TexCoord - vec2(0.5));
float r = length(coord);
if (r >= 1.0) { discard; }

//the center object is a star, so simply color it white
float dist = length(WorldCoord);
if(dist <= 0.01)
{
FragColor = vec4(1.0);
return;
}

// calculating the fake intersection point and its lighting
vec3 N = Right*-coord.x + Up*coord.y + ToCam*sqrt(1-r*r);
vec3 L = normalize(-WorldCoord);
float light = 0.2 + 0.9*clamp(dot(N,L),0.0, 1.0)*exp(-dist);
//vec3 color = vec3(0.4, 0.1, 0.6);
FragColor = vec4(frag.color*light,1.0);
}
62 changes: 58 additions & 4 deletions Part1/PROJ_WIN/Project3/shaders/planetGS.glsl
Original file line number Diff line number Diff line change
@@ -1,15 +1,69 @@
#version 330

// want to create a geometry shader that takes in points and emits triangle strips
// sample geometry shader: http://www.lighthouse3d.com/tutorials/glsl-core-tutorial/geometry-shader/

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;

in vColor
{
vec3 color;
}vertices[];

out fColor
{
vec3 color;
}frag;

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


const float scale = 0.03;

void main()
{
int i;
for (int i = 0 ; i < gl_in.length() ; ++i) // gl_in.length() is 1
{
frag.color = vertices[i].color;
}

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); // note that z axis is the up vector here
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();
}
}
7 changes: 7 additions & 0 deletions Part1/PROJ_WIN/Project3/shaders/planetVS.glsl
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
#version 330

in vec4 Position;
in vec3 Color;

out vColor
{
vec3 color;
}vertex;

void main(void)
{
gl_Position = Position;
vertex.color = Color;
}
Loading