Jump to content
  • Advertisement

Imprecision

Member
  • Content Count

    15
  • Joined

  • Last visited

Community Reputation

194 Neutral

About Imprecision

  • Rank
    Member
  1. Imprecision

    Vertex Normals In A QuadTree Terrain

    I think you assume, that I have a global heightmap. I forgot to say that I this is procedural terrain. The heightdata is generated per Node on the GPU, so no global heightmap data.   Someone might say "Then make the heightmap one pixel larger in every direction" - That dosen"t work either. When the node is on the edge of the cube, I would have to make a 3D heightmap, what would require to know the different side while creating the heightmap and increases the memory consumption by at least 3 times.
  2. I finally managed it to get my terrain stitching working on a globe with six quadtrees. I used a index system similiar to this one http://img406.imageshack.us/img406/2153/screen4ya3.png. Everything looks fine so far (no cracks, no shifted heightdata), except for the lighting. The vertex normals on the edges are sh*t.   See the image below:   Is there any way how to calculate/interpolate the edges, so they have the same normal? One of the problems that I cant "fix in my head" are the differences between LODs I cant just copy the vertices of my neighbor because maybe its larger or smaller than me: Node (1) needs the vertex data (red and green slice) from node (2), (3) and (4)  to calculate correct normals. This means data from these nodes must be extracted (slice) and some of it must be skipped (because node (1) has a lower resolution) by the difference of the specific neighbor depth. This is complicated, but not that much.   The other way around is giving me headache. Node (2) needs the border vertex slice from (1) (the blue one). The problem is, that it just needs a specific "range" of the slice, so it needs to determine what exact position it (2) has compared to the border of the node (1) and calculate the index of the first vertex to extract. WTF?!     Next problem with this is, the 3D aspect. I have different behavior when my neighbors are on other sides of the node:   For Node (4) I need three slices to get correct normals for the north and west edge. One from (5) one from (6) and the last vertex for the corner from Node (1). When I have the same situation with the neighbors beeing on anthoder side, i just have 2 slices, because I don't have a corner at all.    -   Even if i would have a super algorithm that calculates how much shifted a smaller node to a bigger node is handling different sides of the cube... there must be another way. I found 1000 topics of neighbor finding and crack fixing problems for quadtrees. But not a single one who has problems with vertex normals.   This makes me suspicious that I make something fundamentally wrong.   Btw. here is the code how I calc the normals: private static Vector3d[] create(Vector3d[] vertices, int[] indices) { // Prefilling result int vertLength = vertices.Length; Vector3d[] result = new Vector3d[vertLength]; for (int i = 0; i < vertLength; i++) { result[i] = Vector3d.Zero; } // Calculating normals int length = (int)(indices.Length / 3); for (int i = 0; i < length; i++) { Vector3d v1 = vertices[indices[i * 3]]; Vector3d v2 = vertices[indices[i * 3 + 1]]; Vector3d v3 = vertices[indices[i * 3 + 2]]; Vector3d ab = v1 - v2; Vector3d ac = v1 - v3; Vector3d vCross; Vector3d.Cross(ref ab, ref ac, out vCross); result[indices[i * 3]] += vCross; result[indices[i * 3 + 1]] += vCross; result[indices[i * 3 + 2]] += vCross; } // Normalize for (int i = 0; i < vertLength; i++) { result[i].Normalize(); } return result; }
  3. Imprecision

    GLFW 3 GetCursorPos() only zero

    I already suspected this when I saw the doc example using doubles and I am using int. Yes the "out" Parameters are call-by-reference in C#.   Thanks for your help  I will open a issue on Pencil.Gaming
  4. Hey, I'm using GLFW on C# with Pencil.Gaming   My problem is that GetCursorPos only returns 0 (i and j).     My code: static void Main(string[] args) { if (!Glfw.Init()) { Console.WriteLine("ERROR"); return; } GlfwMonitorPtr monitor = Glfw.GetPrimaryMonitor(); GlfwWindowPtr window = Glfw.CreateWindow(1280, 720, "SharpFloat", GlfwMonitorPtr.Null, GlfwWindowPtr.Null); Glfw.MakeContextCurrent(window); int i; int j; while (!Glfw.WindowShouldClose(window)) { GL.Clear(ClearBufferMask.ColorBufferBit); Glfw.GetCursorPos(window, out i, out j); Console.WriteLine(i + " " + j); Glfw.SwapBuffers(window); Glfw.PollEvents(); } Glfw.Terminate(); } Do I read it wrong? Or do I have to do something before I can read it?
  5. Imprecision

    Slowdowns / 'Anti-Hotspot'

    Can I avoid this problem by creating nodes in a new thread? Mh... I don't think this is what I need. It's not that I don't understand which parts of code lines are slow, I don't know why the are getting slow by random.
  6. Hi, I'm working on my Quad-Tree for a while now, to generate the landcape. I optimized it pretty nicely so its able to produce new quads in 1 - 2ms. The problem is that C# slows down when there wasn't create a new quad for a while (while means starting from 500ms). Here an example: Node gen; total 106ms noise 69 vert 11 rest Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 2ms noise 0 vert 0 rest 1 Node gen; total 2ms noise 0 vert 0 rest 1 Node gen; total 3ms noise 0 vert 0 rest 2 Node gen; total 4ms noise 2 vert 0 rest 1 Node gen; total 7ms noise 1 vert 0 rest 6 Node gen; total 4ms noise 2 vert 0 rest 2 Node gen; total 37ms noise 1 vert 0 rest 35 Node gen; total 3ms noise 1 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 18ms noise 17 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 22ms noise 16 vert 0 rest 4 Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 18ms noise 17 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 18ms noise 15 vert 0 rest 2 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 18ms noise 17 vert 0 rest 1 Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 18ms noise 16 vert 0 rest 1 Node gen; total 2ms noise 1 vert 0 rest 1 Node gen; total 19ms noise 17 vert 0 rest 1 Node gen; total 2ms noise 0 vert 0 rest 1 Node gen; total 2ms noise 1 vert 0 rest 1 As you can see the time for the generation CAN be very fast, but it slows down for no reason The difficulty of the data to create dosen't change at all. I know that C# / .NET optimizes parts of code that are 'in heavy use'like the hotspot technology in JVM. Is there any way to enable it manually? How do you handle it?
  7. Hi there, I asking myself for a while how to design correctly. Let me get an example: (C#) [source lang="csharp"]class SimpleClass { private int a = 0; private int b = 0; private int c = 0; public SimpleClass(int a, int b) { this.a = a; this.b = b; CalcC(); // CALL DESIGN A this.c = CalcC(this.a, this.b); // CALL DESIGN B } //METHOD DESIGN A private void CalcC() { c = a + b; } //METHOD DESIGN B private int CalcC(int first, int second) { return first + second; } }[/source] I always used variant A when working with private methods. But then I realised that I can't put my methods in unit tests, because they are working with the class properties and don't return any values. I working like variant A since years, and it would be nice if somebody can tell me something about this and the dos and don'ts of this. Thanks.
  8. Imprecision

    Initialize variables out of a loop?

    I don't count on that since I've read that this: int length = List.Count for (int i = 0; i < length; i++ { //Run through list } is several times faster than for (int i = 0; i < List.Count; i++ { //Run through list } One line of code optimization. It generates a planet chunk with curvature, trianglelist, heighmap and textures coordinates at once. Yes I need that many variables But thanks for all your answers. Now I'm able to clean up my code a bit
  9. Hey, I have some lopps that repeat more than 1000 times. In these loops, I use alot of new variables like so for (int i = 0; i > 500; i++) { for (int j = 0; j > 500; j++) { int foo = 0; int bar = 2; double a; double b; double c; double x; double y; double z; // Do Something } } that means to me, that I allocate new memory everytime I run trough the loop. When done something like this: int foo = 0; int bar = 2; double a; double b; double c; double x; double y; double z; for (int i = 0; i > 500; i++) { for (int j = 0; j > 500; j++) { // Do Something } } isn't that pretty much faster? Because I use the same memory for every loop, instead of allocate evertime new one?
  10. Imprecision

    Texture artifacts

    No, its definatly not z-fighting caused by two chunks. It seems that the texture wrapping runs out of precision. The values on the screenshot are the near /far- planes of the chunks. I calculate it on how close I'm to the surface, because the accuracy gets lost when i take 0.0000001 to 10000. The closer I get to the surface the smaller are the values for the planes.
  11. Imprecision

    Texture artifacts

    Hi, I get some artifacts on my texture when it's applied on a small chunk: (Normally there would be a sharp edge between blue and brown) Does someone know why this happens and how to solve it ?
  12. Imprecision

    LOD with Perlin Noise "zoom"

    Hi swiftcoder. Thanks for the keywords "fractal brownian motion" and "ridged multifractal" thats exactly what I was looking for! Now I got tons of new material [color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]NEW Question:[/font] [color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]Is the only way to get a seamless cubemap for terrain, to generate 3D noise? Or is there an algorithm to map 2D data seamless on a cube? [/font]
  13. Hi guys, I'm using my Perlin Noise algorithm as a height map (I don't store as a texture, I use the values directly on my vertices). Representing an earth scale planet I need a height map for at least 510 million km². My problem is now, that I don't know how to make a "more detailed" noise on higher LOD. There must be another way than making an array of 32000*32000 random numbers for perlin noise to get acceptable terrain on highest LOD. Are there any techniques to get this done?
  14. Imprecision

    Imprecision problem on planet

    Earth has 510,000,000km², one side is one 6th: 85,000,000km² divided by 4[sup]18[/sup] is 0,0012km² or 1,237m² with a edge length of 35m Still huge in my opinion. That's a subdivision size of about 24 metres, on the earth. Do you need to get that close in? [/quote] The 24m (or 35m) could be enough, (better would be a depth of 22 divisions) but i get imperfections already on depth of 14 which is definitely to big for me I already use double precision. All calculations are one the CPU made with double precision. When I send the vertices to the vertexbuffer the're converted to 32bit float. Matrice transformations are on 32bit too. Limiting factor is the graphicscard is working with 32bit float I tried that out (putting the top surface to (0,0,0), but it didn't helped. I already got the highest precision in range of -1 to 1.
  15. Hello, because sometimes it's hard to follow an explanation only in mind I added a few pictures to this post. Sorry for those which have a slow internet connection. First of all, I'm programming a planet renderer. Im using the cube to sphere algorithm from mathproofs: http://mathproofs.bl...-to-sphere.html My problem is that it running into the common floation point error because the algorithm forces me into a specific range (imho), and I don't know how to getting arround it. The algo morphes all 6 sides of a cube in to a sphere. One side look like this after morphing: Using the algo on all 6 sides I get a sphere inbetween -1 and 1 (scale 1): That LOD is implemented as an quadtree. When coming closer the chunk is seperated in 4 smaller chunks each with the same amount of vertices as the old chunk. These chunks can be seperated too, so I get a smooth surface even if im extremly close to the planet (in theory). This is how it look like if I create a really deep tree and zoom out: Here comes the trouble. On the tiny chunks the curvature is extrem small. Its so small that I run into floating point imprecision and the result is that: As you can see the surface is not flat and when I change the angle of the camera everything is "wobbeling". The quadtree depth is at 18 that means that the smallest chunk is one 262144th of the original chunk in sidelength. Visualising this on 2D it looks like this: What can I do to solve this problem? I already fixed my camera to Vector3.Zero and just move the world around me to get highest precision near to my camera, but I still got the problem. I appreciate every comment. Thanks.
  • 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!