Posted by
ElvJOGL on
Feb 10, 2016; 1:28pm
URL: https://forum.jogamp.org/Extending-Functionality-of-Shader-Programs-tp4036139p4036145.html
This is what I mean about counting the pixels inside a polygon.
In mathematics there is a person that created a theorem, his name is Pick and his theorem is called Pick's Theorem.
A = i + b/2 - 1
if you go by the equation above, counting the number of pixels that make up the boundary in this case variable {b} in the equation, and then counting the number of pixels in the interior in this case variable {i} in this equation, then as you apply the equation you will get the exact Area of a Triangle. Pick's Theorem applies to triangles because triangles are the most simple polygon there is.
You can prove this in a graphing paper, you draw a triangle and trace the points that are in the boundary and inside the interior then you apply that equation and you get the exact Area of the triangle. This does not work in plain blank paper. It has to be on graphing paper because when you drawing something in graphing paper like a triangle, then you are drawing it to exact scale.
Now that I have said much about that, lets go into what is called Higher Dimensions of the Pick's Theorem.
If instead of a triangle you have a Quad (such as a rectangle), then you looking not at a polygon to which you can apply Pick's Theorem, but you looking at a Polynomial, in which case you have apply Ehrhart's Polynomial to get the Area.
That is why it is important for me to count the pixels inside the polygons, because with that information, I can deduce whether 1). I might be doing Pick's Theorem correctly, and 2). whether I can also calculate Ehrhart's Polynomial out of whatever polygon you throw at the program. (That also includes geometry subtraction, which I will do at some point later once I get a good example working.)
You all your life you have gone thinking that the only way you get the area of triangle is by calculating the height and the base length and divide by 2. That seams reasonable. So you might think that both Pick's Theorem and the way they teach you in school how to find the area of a triangle should yield the same result. It all depends, in whether both equations are referring to the same scaled up triangle. (That is why I said, not to draw the triangle in the a plain blank paper, because that will not be accurate.)
Now to re-reference the question that I asked in this post:
http://forum.jogamp.org/I-am-New-To-GLSL-C-OpenGL-Shader-program-tp4036135.htmlWell you didn't quite answer my question when I asked it.
So I will ask again here if you get to see @elect.
Ok, does the Shader program bellow if you were to implemented in JOGL, will it change syntax? Or the Shader language in C or in JOGL are the same syntax?
//-------------------------------------------------------------------- //
#version 430 core
//"offset" is an input vertex attribute
layout (location = 0) in vec4 offset;
void main(void){
const vec4[3](vec4( 0.25, -0.25, 0.5, 1.0),
vec4(-0.25, -0.25, 0.5, 1.0),
vec4( 0.25, 0.25, 0.5, 1.0));
//add "offset" to our hard-coded vertex position
gl_Position = vertices[gl_VertexID] + offset;
}
//--------------------------------------------------------------------