Commit 9dccffe2 authored by Sabrina Templeton's avatar Sabrina Templeton
Browse files

start at very hardcoded geo shader code

parent 13bf33d5
......@@ -48,10 +48,10 @@ uniform samplerBuffer seeds;
// render full square
void render_square(vec3 pt) {
//define all four points of the square
vec3 bl = pt + vec3(-.02, -.02, 0);
vec3 br = pt + vec3(.02, -.02, 0);
vec3 tl = pt + vec3(-.02, .02, 0);
vec3 tr = pt + vec3(.02, .02, 0);
vec3 bl = pt + vec3(-.01, -.01, 0);
vec3 br = pt + vec3(.01, -.01, 0);
vec3 tl = pt + vec3(-.01, .01, 0);
vec3 tr = pt + vec3(.01, .01, 0);
//top triangle
......@@ -87,6 +87,43 @@ void render_square(vec3 pt) {
EndPrimitive();
}
float dist(vec3 a, vec3 b){
float comp1 = pow(b.x - a.x, 2);
float comp2 = pow(b.y - a.y, 2);
return comp1 + comp2;
}
vec3 calc_intersect(vec3 zi,vec3 zj, vec3 b0, vec3 b1){ // b0 and b1 are border pts
return vec3(.15, .15, 0);
}
void calc_poly(vec3 zi, vec3 zj){
//where zi is the pt and zj is the current nearest neighbor
//first step : start with just the initial polygon for now and perform one clip
vec3 curr_poly1 = vec3(0, 0, 0);
vec3 curr_poly2 = vec3(1, 0, 0);
vec3 curr_poly3 = vec3(1, 1, 0);
vec3 curr_poly4 = vec3(0, 1, 0);
//one iteration of what would be a for loop
int side1 = 0;
int side2 = 0;
if (dist(curr_poly1, zi) < dist(curr_poly1, zj)) {
side1 = 1;
}
else {
side1 = -1;
}
vec3 intersect = vec3(0, 0, 0);
//again there's more to do here but I'm going to start by just calculating the intersection pt in the most hardcoded way possible
if (side1 != side2) intersect = calc_intersect(zi, zj, curr_poly1, curr_poly2); //b0 and b1 are the current border points
//test if the intersect point works
render_square(intersect);
}
......@@ -97,9 +134,15 @@ main() {
// lookup the seed points, taking in glPrimitiveIDIn
vec3 p0 = vec3(texelFetch( seeds , gl_PrimitiveIDIn ).xy, 0);
// lookup the first nearest neighbor
// this will obviously change once we are actually fetching from the nearest neighbor instead of the seed
vec3 nn0 = vec3(texelFetch( seeds, gl_PrimitiveIDIn + 1).xy, 0);
calc_poly(p0, nn0);
render_square(p0);
//dist(vec3(0, 0, 0), vec3(5, 3, 0));
}
......
......@@ -79,12 +79,25 @@ UT_TEST_CASE( test1 )
//generate random seeds desired times 3
int num_points = 7.;
int size = num_points*3;
std::vector<graphics::gl_float> seeds;
srand (time(NULL));
for (int i = 0; i < size; i ++){
seeds.push_back(rand() % 10 * 0.01);
//printf("loop ran, %d point added", i);
/* uncomment this to restore to random
// std::vector<graphics::gl_float> seeds;
// srand (time(NULL));
// for (int i = 0; i < size; i ++){
// seeds.push_back(rand() % 10 * 0.01);
// //printf("loop ran, %d point added", i);
// };
*/ //uncomment this to restore to random
std::vector<graphics::gl_float> seeds = {
0.05, 0.1 , 0.0,
0.05, 0.06 , 0.0,
0.03, 0.14 , 0.0,
0.11, 0.10 , 0.0,
0.0, 0.05 , 0.0,
1.0, 1.0 , 0.0,
1.0, 1.0 , 0.0,
};
std::vector<real_t> seeds_d( seeds.begin() , seeds.end() ); //convert the seeds to double
......
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