OpenGL: How to fill a polygon gradiently smoothly without spurious star edges - opengl

Suppose the polygon is a hexagon.
To fill it gradiently, assume there are many smaller hexagons inside.
The smaller the hexagon, the pixel on that hexagon has a brighter color.
However, after I finish it, I find that there are spurious star edges between the center and the corners, like in the attached image (ignore the two discs inside).
How should I design an algorithm to make the filling more smoothly?

Related

How to remove eyelashes noise using ellipse detection

Hopeful end result of detecting ellipse in photo and drawing edges accurately:
Picture I'm trying to work with:
I’m looking to detect the ellipses of an eye in a side view image but one problem is that when I run the canny function and draw the edges it can only draw edges on the eyelashes and make some sort of ellipse there. This noise is also causing problems because in my hough transform ellipse function I am thresholding for all values higher than .9 (and lower than .7) and these values on the eyelashes have the maximum pixel intensity values so they are taken into account.
Is there a way to remove the noise (eyelashes)? I am using skimage from sci-kit image for all of this. This is for a side view of the eye.

How to polygonize or create triangles in surface nets isosurface creation algorithm

I am implementing a naive surface net algorithm and have a question related to creating triangles. I think I am unable to understand how triangulation works in surface nets.
So I have voxels where the surface intersects. I also have a center of a surface node (for now its just a center of the cube). Now I am ready to create triangles between 6 possible neighbor for each surface net cube. I created 12 possible triangles for each node but am looking for ways to reduce the number of triangles since there are duplicates.
In the figure below, I am considering building triangles only for a single quadrant. In this case cubes A,B,C and D which is also left, center, back and bottom. If all 4 surface nodes have intersection I currently create face 1,2 and 3 and also the remaining faces 4,5,6 of the box. Something doesn't seem right. I am wondering if I am in the right direction or if there is another way to do create triangles in surface nets.
Image source.
There is another way of doing this, and a bit of code is shown here:
Basic Dual Contouring Theory
(under the line #construct faces)
you can also negate the "dirs" (then it would be (-1,0,0),(0,-1,0),(0,0,-1)) variable and do it in the same loop as you are doing your sampling, this increases performance a little bit
I hope this helped

View frustum culling for animated meshes

I implemented frustum culling in my system, it tests the frustum planes on every object's bounding sphere, and it works great. (I find the PlaneVsAabb check unneeded)
However, the bounding sphere of the mesh is adjusted for its bind pose, so when the mesh starts moving (e.g the player attacks with his sword) some vertices could go out of the sphere.
This often results in a mesh getting culled, although there are some vertices that should be rendered (e.g the player's sword that went out of the sphere).
I could think of two possible solutions for this:
For every mesh in every frame, calculate its new bounding sphere based on bone changes. (I have no idea how to start with this...) Could this be too inefficient?
Add a fixed offset for every sphere radius (based on the entire mesh size maybe?), so there could be no chance of the mesh getting culled even when animated.
(1) would be inefficient in real-time yes. However you can do a mixture of both, by computing the largest possible bounding sphere statically i.e. when you load it. Using that in (2) would guarantee a better result than some arbitrary offset you make up.
(1) You can add locators to key elements (e.g. dummy bone on the tip of the sword) and transform their origin while animating. You can done it on CPU on each update and then calculate bounding box or bounding sphere. Or you can precompute bounding volumes for each frame of animation offline. Doom3 uses second approach.

Undistorting concentric circles in opencv

I have an image consisting of concentric circles. I'm trying to undistort the image so that the circles are equal spacing apart around the edges, as if the camera is parallel to the plane. (Some circles will appear closer to the next which is fine, I just want equal spacing all around the edges between the two adjacent circles)
I've tried to estimate a rigid transform by specifying points of the outer circle, but it distorts the inner circles too much, and I've tried a findhomography by specifying points of all the circles, and comparing with points of circles of where they should be.
From what I see the outer circles are 'squished' vertically, so need to be smushed up horizontally, but the inner circles are more circular. What can I do to undistort this image?
https://code.google.com/p/ipwithopencv/source/browse/trunk/ThinPlateSpline/ThinPlateSpline/?r=4
Using this implementation of Thin Plate Spline, I was able to input a set of points representing all the distorted circles, and another set of points which represent where they should be, to get the desired output. It isn't absolutely perfect, but it's more than good enough!

What collision detection method to use with hand drawn surface?

I have a lunar lander type game. I don't use any physics engines.
My lander keeps falling if you do not use thruster and eventually lands on the ground. Ground is hand drawn, it is not a line, more like curve, and the land can be of any configuration or color.
How do I properly use collision detection and its results?
Well it depends on what you want to do. I would recommend one of the following:
Use physics engines. They are there for something. You could create different shapes what was drawn. You could mix in a rectangle if theres a straight line, or a lot of circles for curves, etc.
Use your own custom circle collision detector. You represent the lander with a bounding box sized circle. Then, for each of the handdrawn lines, create a bunch of adjacent circles representing the line. When you check your lander position, you are just basically looping through the circles representing the lines and checking for collisions. Incoming pseudocode
for (CollisionCircle* circle in collisions)
{
if (circle.collidesWith(lander.collisionCircle))
{
// 1. Calculate edge distance from lander to circle (position + radius distance)
// 2. Remove distance from lander position to fix position.
}
}