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

Project3-Simulation part 1 and flocking #12

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3468944
following the walkthrough
Oct 18, 2013
0a9162a
Merge remote-tracking branch 'upstream/master'
Oct 20, 2013
ec76c89
part1 with rk4
Oct 20, 2013
3a6f80e
part2 first attempt with shared mem
Oct 20, 2013
c064998
part2 fish shoal
Oct 20, 2013
05ee6a8
colored balls
Oct 20, 2013
b278741
Part2 - different behaviors
Oct 20, 2013
56241e2
Update README.md
vimanyu Oct 20, 2013
45f1465
Update README.md
vimanyu Oct 20, 2013
78d1355
Update README.md
vimanyu Oct 20, 2013
c024e71
Update README.md
vimanyu Oct 21, 2013
f725e6f
Update README.md
vimanyu Oct 21, 2013
ddd1b39
add screen
Oct 21, 2013
07c62ff
Update README.md
vimanyu Oct 21, 2013
b1a11df
shared mem extern fix
Oct 21, 2013
acadf46
performance analysis
Oct 22, 2013
bc22d7c
Update README.md
vimanyu Oct 22, 2013
a5fbc8a
Merge branch 'master' of https://github.com/vimanyu/Project3-Simulation
Oct 22, 2013
8496eaa
Update README.md
vimanyu Oct 22, 2013
bca6994
flock demo
Oct 23, 2013
1357960
flocking sim
Oct 23, 2013
a8f9b4f
Update README.md
vimanyu Oct 23, 2013
8b34d02
Update README.md
vimanyu Oct 23, 2013
b761e9d
screens
Oct 23, 2013
60a987b
Merge branch 'master' of https://github.com/vimanyu/Project3-Simulation
Oct 23, 2013
309c6f5
screens
Oct 23, 2013
c7577fe
screens
Oct 23, 2013
8df555c
force add screen
Oct 23, 2013
812b2bd
Update README.md
vimanyu Oct 23, 2013
1e672ef
Update README.md
vimanyu Oct 23, 2013
a4e5d55
benchmarks on 740M GT
Oct 23, 2013
0846022
benchmarks on 740M GT
Oct 23, 2013
887e6d7
Update README.md
vimanyu Oct 23, 2013
a3426a9
benchmarks on 740M GT resized images
Oct 23, 2013
a2a7840
Merge branch 'master' of https://github.com/vimanyu/Project3-Simulation
Oct 23, 2013
14dab71
removed RK4 from Part2 as it wasnt implemented fully
vivreddy Oct 23, 2013
836f913
Update README.md
vimanyu Oct 23, 2013
3f1a6de
Update README.md
vimanyu Sep 12, 2019
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
  •  
  •  
  •  
9 changes: 8 additions & 1 deletion Part1/PROJ_WIN/Project3/Project3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<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 +71,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>
</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>
</CudaCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\glslUtility.cpp" />
Expand Down
6 changes: 3 additions & 3 deletions Part1/PROJ_WIN/Project3/Project3.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
</Filter>
</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\glslUtility.cpp">
<Filter>Resource Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\cudaMat4.h">
Expand Down
11 changes: 9 additions & 2 deletions Part1/PROJ_WIN/Project3/shaders/heightFS.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
varying float f_height;
in vec2 v_Texcoords;

void main(void)
{
gl_FragColor = vec4(0.05,0.15,0.3,1.0);
}
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);
float shade = (1.0-2.0*sqrt(f_height));
gl_FragColor = shade*color;
}
17 changes: 13 additions & 4 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;
}
43 changes: 40 additions & 3 deletions Part1/PROJ_WIN/Project3/shaders/planetFS.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
void main(void)
{
gl_FragColor = vec4(1.0);
#version 330

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

/*
http://stackoverflow.com/questions/4200224/random-noise-functions-for-glsl
*/

float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}

void main()
{
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);
float rCol1 = rand( vec2(gid*5346,gid*75676));
float rCol2 = rand( vec2(gid*323132,gid*423423));
float rCol3 = rand( vec2(gid*2312334,gid*32132));
vec3 color = rCol1*vec3(1.0,0.0,0.0)+rCol2*vec3(0.0,1.0,0.0)+rCol3*vec3(0.0,0.0,1.0) + vec3(0.1,0.1,0.1);
FragColor = vec4(color*light,1.0);
}
49 changes: 45 additions & 4 deletions Part1/PROJ_WIN/Project3/shaders/planetGS.glsl
Original file line number Diff line number Diff line change
@@ -1,15 +1,56 @@
#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;

in VertexData
{
int vid;
} VertexIn[];

flat out int gid;

const float scale = 0.03;

void main()
{
gid = VertexIn[0].vid;
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();
}
}
6 changes: 6 additions & 0 deletions Part1/PROJ_WIN/Project3/shaders/planetVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

in vec4 Position;

out VertexData
{
int vid;
} VertexOut;

void main(void)
{
gl_Position = Position;
VertexOut.vid = gl_VertexID;
}
Loading