Jump to content
• Advertisement  # JustJim

Member

39

132 Neutral

## About JustJim

• Rank
Member
1. Hey guys! Me again! I solved several problems now (including weird effects when culling etc). Now I want to tune up the performance a little.   As I stated, the vertex/indexBuffer gets loaded every update, meaning the recursive methode goes through the nodes and looks if it needs to get deeper to get the subdivisionlevel needed.   This means If I got a high amount of steps to do every update-cycle.   I've come up with an Idea to reduce this.   As I calculate the angle between the CamToLookAt-Vector and CamToPoint-Vector for reducing the amount of Nodes that has to go down all the way, I can change the Angle at which things will be just staying at MinimumDepth. If I now set the Projection-Matrix to have only a View-Field of, lets say, 25, things will look much bigger. This, of course, requires a little higher MinimumDepth (but not that much, as at a depth of 3 the Sphere already looks kinda round), but gives me the oppertunity to clip at a very smaller angle and thus reducing the amount of polygons to be calculate every step. How do you think of it?
2. Okay My Motivation is, that I want to build procedural planets with LOD. For that reason I searched the web and found, that using a Cube or Icosahedron and morph it into a sphere is a good way because of the forms and because it is easy to subdivide. But I run into a lot of problems... First of all I got managed to create the Quad-Tree with the Icosahedron/Cube which goes to a depth I desire.  Then I got managed to load the nodes into a list and give them an Index.  Then i got managed to differ between distances and thus load deeper nodes when getting nearer to the triangles/quads, so a part of it gets a higher subdivide level.   My Problem is this freaking frustum culling which won't work. I tried to calculate the angle between Cam-CenterOfSphere and Cam-Point and see if it is in 45° range, but it gives me crazy results. Then I recently used BoundingSpheres and BoundingFrustum which is also giving me crazy results as it clips away part of the sphere which are in the Frustum while it keeps parts of the Sphere which are outside.   I defently don't get this to work.
3. Yeah well could be I wronte a zero too much, either way it has a difference, which is pretty annoying when it comes up to scaling.   I rewrote my whole Quad-Tree-Logic to use Triangles instead of Quads and building a Icosahedron as a Base-Figure. The problem seems to gets really small, as my Triangles won't get different sizes at all. All triangles have the exact same size.   One problem now is the massive grow of data using 20 faces and 12 vertices as a base instead of 12 faces  (Quad from 2 Triangles) and 8 vertices though it seems more efficient. The Sphere looks more detailed at lower levels. But having 20 Trees doesn't make things fast haha.
4. How could I generate a Sphere where all vertices have the same distance to the center? Because thats my problem. My Sphere seems to have the distance 1.0f for most of the time. But when It comes to the vertices which are at the positions of the originally Edges and Corners of the Cube they have the length of 1.0000012f which will get bigger when scaling.
5. I am generating a Sphere from a cube right at the moment, meaning I have the coordinates for a cube at the beginning and then let the Quad-Tree beein built which subdivides the Quads and normalizes its vertives. This means at the end there is a sphere, which I can work with. So I am procedurally generating a sphere atm.   Problem is with this sphere that the lengthes at the former edges are a little longer than the others, though they all got normalized.
6. Mh as noone seems to answer, I'd like to rephrase my question: Could this problem be solved when using something with more resolution to begin with? Like a Icosahedron? As every part of it has the same size when subdividing and normalizing and won't get stretched as a cube, I think it COULD be better. Is my assumption correct?
7. Hey there. I've got a general Question about Morphing a Cube to a Sphere. As stated in my other Threads, I am working with a Quad-Tree ( but that doesn't really mean anything) which stores the coordinates for each vertex.   My problem is, when morphing the cube into a sphere, (realized with normalization) not every length is 1. This goes for the Vertices at edges and corners. It seems as I could almost see the Quads edges and corners.   This, at the first look, does not seem like a big problem. My problem is, that I am going deeper the Quadtree, the nearer I am to the Sphere. This means at a certain distance a small area of the sphere is more detailed. But when the sphere or the Cam rotates and as it comes to the edges, the area gets wider as the edges are a little longer.   How can I solve that? I mean I am scaling those Spheres a huge time to model planets and this means a small irregularity results in a big one.
8. I'll do a freaking dumb workaround for the moment. so if anyone read this, please give me a hint how I could fix this to work properly.. My Workaround does it like that: I already calculated the Back-Face-Culling where every Point in the Angle between Vector Cam To Middle and Middle To Point is greater than 90°. I'll change this to include the distance in calculation, so that the Angle at which it starts to clip will decrease... This seems a fast way to do this... But it's only a play with values to get the correct relations.   If someone give me also a trick to make sure that width is clipped much slower than hight. Because the X Value of the sphere which is the width at starting the game can change so its the hight or the depth when changing the cam.
9. Alright. I get close to the problem... At a certain distance and rotation-angle of the sphere (in my tests it was createRotationY(20f)) every, really EVERY Angle (Cam To Vertex , Cam To LookAt) over 90°. Thats kinda... sad lol. I do not know why it is that way.
10. Well I double-checked with principe of excluding. I just commented out the return of my inFrustum-Methode. Result: The whole sphere is seen the whole time. It gives me headache. I got everything so fine haha. It has a nice Quadtree, It transforms the tree into Vertexbuffer in realtime, It subdivides when getting closer. The only thing I need now is this Culling-Feature.   I just noticed somthing other. The Vertices of the spheres are all around 1.0 and 1.0000000012. But this can't have such an effect as my distance of Camera to Object is 200000f (the Sphere itself has the size of 1000000f and the camera is at 1200000f) But as it rotates in the Grid-visualiation it looks like the orgignal boarders are slightly bigger than the size of each other vector..
11. private bool checkForClipping(Quad currentQuad, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4) { Vector3 currentPos = Vector3.Transform(new Vector3(0, 0, 0), world); Vector3 relativeCamPos = currentPos - camPos; Vector3 rP1 = currentPos - p1; Vector3 rP2 = currentPos - p2; Vector3 rP3 = currentPos - p3; Vector3 rP4 = currentPos - p4; if(!inFrustum(rP1,relativeCamPos) && !inFrustum(rP2,relativeCamPos) && !inFrustum(rP3,relativeCamPos) && !inFrustum(rP4,relativeCamPos)) { return true; } rP1.Normalize(); rP2.Normalize(); rP3.Normalize(); rP4.Normalize(); relativeCamPos.Normalize(); float angle1 = MathHelper.ToDegrees(Math.Abs((float)Math.Acos(Vector3.Dot(relativeCamPos, rP1)))); float angle2 = MathHelper.ToDegrees(Math.Abs((float)Math.Acos(Vector3.Dot(relativeCamPos, rP2)))); float angle3 = MathHelper.ToDegrees(Math.Abs((float)Math.Acos(Vector3.Dot(relativeCamPos, rP3)))); float angle4 = MathHelper.ToDegrees(Math.Abs((float)Math.Acos(Vector3.Dot(relativeCamPos, rP4)))); if (angle1 > 95 && angle2 > 95 && angle3 > 95 && angle4 > 95) { return true; } return false; } bool inFrustum(Vector3 point, Vector3 relativeCam) { Vector3 camToPoint = camPos - point; camToPoint.Normalize(); lookAt -= camPos; lookAt.Normalize(); float angle = MathHelper.ToDegrees(Math.Abs((float)Math.Acos(Vector3.Dot(lookAt,camPos)))); if (angle > 80f / 2) return false; else return true; } This is the code ATM
12. Well it is really confusing when, if the sphere stands still, everything works and it won't disappear compleatly but when the planet is rotating at some angles it disappear. Thats whats going wrong.  I checked the length of each vertex and they are all almost 1 (because of normalisation) so there can't be an intersection with the nearplane. I stay the same distance from the sphere but as it rotates it disappears at some angles.   Everything else is finde. At non-Movement it clipps all vertices out that I don't need. (Well it does go for it in a weird way. Somehow..)   Edit: That I tried to. But there is a problem then. It shows nothing. The Point is a relative-Point, meaning it is relative to its center. Maybe this is another error
13. I did pause whenever it blacked out for a moment. And when this happens all the angles are bigger than 50/2
14. If I would check 4 Points of the Frustum Plane, I have another Problem :/ , What if the Cam changes? Z Won't be the Depth anymore and X the Width.
15. Ah yeah. It was a rather simple approach. As my Farplane and Near-Plane are really long / short (0.01f to 10000000f as it is in Space) i do not care about them. I have a function, testing if a point is behind another (Z-Buffering) so only half the sphere will be drawn.   The aspect-Ratio is also not that important as I give the Degree of the biggest size ( the width) so the height won't clip that much away but that's okay.   My Problem is, that if the sphere rotates and I am and a close distance, at some degree, the whole sphere disappears and pops up again after rotating on.
• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!