Commit 9488e0b7 authored by Sabrina Templeton's avatar Sabrina Templeton
Browse files

still debugging

parent 82f1e07f
// the version should be specified by a macro at compile time
// e.g. #version 410 or #version 330
#version 410
//#version 410
layout( location = 0 ) out vec4 fragColor;
in vec3 v_Position;
in vec3 v_Normal;
in vec3 v_Parameter;
flat in int v_Index;
in float v_Index;
const int ncolor = 256;
......@@ -25,7 +25,7 @@ void
get_color( float u , out vec3 color ) {
float umin = 0.;//u_umin;
float umax = u_nb_points;//u_umax;
float umax = u_nb_points +1;//u_umax;
// int indx = int(ncolor*(u - umin)/(umax - umin));
int indx = int(ncolor*(u - umin)/(umax - umin));
......@@ -44,9 +44,9 @@ int indx = int(ncolor*(u - umin)/(umax - umin));
void main() {
vec3 color = vec3(.8, .8, .8);//vec3(0.8,0.8,0.2);
vec3 color = vec3(.2, .2, .2);//vec3(0.8,0.8,0.2);
int idx = v_Index;//gl_PrimitiveID;
float idx = v_Index;//gl_PrimitiveID;
float f = idx;
......@@ -64,7 +64,7 @@ void main() {
#else
get_color(idx, color);
//get_color(idx, color);
#endif
......
// the version should be specified by a macro at compile time
// e.g. #version 410 or #version 330
#version 410
layout (points) in;
//#version 410
layout (points) in;
precision highp float;
// uniform mat4 u_ModelViewProjectionMatrix;
// uniform mat4 u_NormalMatrix;
// uniform mat4 u_ModelViewMatrix;
......@@ -41,11 +41,11 @@ const int MAX_VERTS = 30;
// out vec3 v_Parameter;
flat in int[] instance_ID;
flat out int v_Index; //this might not need to be flat but doesnt seem to work otherwise
out float v_Index;
//out vec3 v_Ind;
layout (triangle_strip, max_vertices = 100) out; // this was 40, upped it for debugging purposes
layout (triangle_strip, max_vertices = 40) out; // this was 40, upped it for debugging purposes
//uniform usamplerBuffer connectivity;
uniform samplerBuffer seeds;
......@@ -67,14 +67,17 @@ void render_poly(vec3[MAX_VERTS] poly, vec3 center, int space){
}
gl_Position = u_ModelViewProjectionMatrix*vec4(p0, 1.0);
v_Index = float(instance_ID[0]);
EmitVertex();
gl_Position = u_ModelViewProjectionMatrix*vec4(p1, 1.0);
v_Index = float(instance_ID[0]);
EmitVertex();
gl_Position = u_ModelViewProjectionMatrix*vec4(center, 1.0);
gl_PrimitiveID = instance_ID[0];
//gl_PrimitiveID = instance_ID[0];
v_Index = float(instance_ID[0]);
EmitVertex();
EndPrimitive();
......@@ -155,7 +158,7 @@ vec3 calc_intersect(vec3 p1, vec3 p2, vec3 q1, vec3 q2){ // p1 and p2 are seeds,
l2 = abs(l2 + d);
float l12 = l1 + l2;
if (l12 > 1e-30) {
if (l12 > 1e-30) { // was 1e-30, changed to 1e-6
l1 /= l12;
l2 /= l12;
}
......@@ -200,14 +203,14 @@ void calc_poly(vec3 zi, vec3 zj, inout vec3[MAX_VERTS] curr_poly, inout int cspa
int side1 = 0; // initialize side 1 and side 2
int side2 = 0;
//calculate side 1
if (dist(b0, zi) < dist(b0, zj)) {
if (distance(b0, zi) < distance(b0, zj)) {
side1 = 1;
}
else {
side1 = -1;
}
//calculate side 2
if (dist(b1, zi) < dist(b1, zj)) {
if (distance(b1, zi) < distance(b1, zj)) {
side2 = 1;
}
else {
......@@ -251,7 +254,7 @@ void
main() {
// lookup the seed points, taking in glPrimitiveIDIn
int site_idx = instance_ID[0];
v_Index = instance_ID[0];
//v_Index = instance_ID[0];
//v_Ind = vec3(instance_ID[0], instance_ID[0], instance_ID[0])
vec3 p0 = vec3(texelFetch( seeds , site_idx ).xy, 0);
//vec3 p1 = vec3(texelFetch( seeds , 0 ).xy, 0);
......@@ -361,6 +364,7 @@ main() {
}
//if (site_idx == 0) {
render_poly(curr_poly, p0, space);
render_square(vec3(1, 1, 0), .01);
//}
//render_square(p0, .03);
......
// the version should be specified by a macro at compile time
// e.g. #version 410 or #version 330
#version 410
//#version 410
// this code taken from example of tetrahedron/volume toy by Philip
flat out int instance_ID;
layout (location = 0 ) in vec3 a_Position;
......
......@@ -71,7 +71,7 @@ UT_TEST_CASE( test1 )
//initialize the shader:
graphics::ShaderProgram shader("voronoi");
graphics::ShaderProgram shader("voronoi",false,{"#version 410"});
shader.use();
graphics::gl_index vertex_array;
......@@ -79,7 +79,7 @@ UT_TEST_CASE( test1 )
GL_CALL( glBindVertexArray(vertex_array) );
//generate random seeds desired times 3
int num_points = 2e5;
int num_points = 1e6;
int size = num_points*3;
......@@ -102,9 +102,26 @@ UT_TEST_CASE( test1 )
//std::cout << seeds[i] << std::endl;
//printf("loop ran, %d point added", i);
};
//std::cout << "Test Print!!!!!!!!!!!!!";
// //std::cout << "Test Print!!!!!!!!!!!!!";
//here is the non random way to generate points
// float dx = 1 / (sqrt(num_points) + 1); //delta y is the same if we're going for a grid
// std::cout << dx << std::endl;
// for (int i = 1; i < sqrt(num_points) +1; i ++ ){
// for (int j = 1; j < sqrt(num_points) +1; j ++ ){
// float x = j * dx;
// float y = i * dx;
// seeds.push_back(x);
// seeds.push_back(y);
// seeds.push_back(0.0);
// }
// }
//cout << seeds;
//*/ //uncomment this to restore to random
......@@ -149,7 +166,7 @@ UT_TEST_CASE( test1 )
nns->set_points( num_points , seeds_d.data() );
index_t nb_neighbors = 50;//index_t(num_points); // since there are only seven points right now, this number will probably be more like 50 later
index_t nb_neighbors = 30;//index_t(num_points); // since there are only seven points right now, this number will probably be more like 50 later
std::vector<index_t> neighbors(nb_neighbors);
std::vector<index_t> total_neighbors(nb_neighbors * num_points); // i don't know if this is the correct number if, for example, nb points and nb neighbors are not the same (which they usually will not be)
std::vector<double> neighbors_sq_dist(nb_neighbors);
......@@ -308,11 +325,12 @@ UT_TEST_CASE( test1 )
int points_remaining = num_points;
int first_point_to_draw = 0;
int call_size = 1e3;
while (points_remaining > 0){
std::cout << "one iteration" << std::endl;
//std::cout << "one iteration" << std::endl;
std::cout << points_remaining << std::endl;
// std::cout << first_point_to_draw << std::endl;
if (points_remaining < 1e4){
if (points_remaining < call_size){
// std::cout << "if statement" << std::endl;
// std::cout << first_point_to_draw << std::endl;
// std::cout << first_point_to_draw + points_remaining << std::endl;
......@@ -321,14 +339,15 @@ UT_TEST_CASE( test1 )
}
else{
//std::cout << "test" << std::endl;
GL_CALL( glDrawArrays(GL_POINTS, first_point_to_draw , 1e4 ) );
points_remaining -= 1e4;
first_point_to_draw += 1e4;
GL_CALL( glDrawArrays(GL_POINTS, first_point_to_draw , call_size ) );
points_remaining -= call_size;
first_point_to_draw += call_size;
}
}
}
//GL_CALL( glDrawArrays(GL_POINTS, 0, points_remaining ) );
clock_t TIME3 = clock();
printf("--> GPU run time = %g seconds\n",real_t(TIME3-TIME2)/real_t(CLOCKS_PER_SEC));
......
Supports Markdown
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