Advertisement

Evenly distributed point cloud for a grass renderer on a sphere

Started by September 20, 2018 11:40 PM
3 comments, last by JoeJ 6 years, 1 month ago

I'm trying to add some details like grass, rocks, trees, etc. to my little procedurally-generated planet. The meshes for the terrain are created from a spherified cube which is split in chunks (chunked LOD).

To do this I've wrote a geometry shader that takes a mesh as input and uses its vertex positions as locations where the patches of grass will be placed (as textured quads).

For an infinite flat world (not spherical) I'd use the terrain mesh as input to the geometry shader, but I've found that this won't work well on a sphere, since the vertex density is not homogeneous across the surface.

So the main question would be: How to create a point cloud for each terrain chunk whose points were equally distributed across the chunk?

Note: I've seen some examples where these points are calculated from intersecting a massive rain of totally random perpendicular rays from above... but I found this solution overkill, to say the least.

Another related question would be: Is there something better/faster than the geometry shader approach, maybe using compute shaders and instancing?

Advertisement

Have you tried (4pi squared)/HowMuchPoints you want.

That seams to be the simplest way of getting the points, just divide the surface by the amount you want. 

2 hours ago, trapazza said:

I'm trying to add some details like grass, rocks, trees, etc. to my little procedurally-generated planet. The meshes for the terrain are created from a spherified cube which is split in chunks (chunked LOD).

To do this I've wrote a geometry shader that takes a mesh as input and uses its vertex positions as locations where the patches of grass will be placed (as textured quads).

For an infinite flat world (not spherical) I'd use the terrain mesh as input to the geometry shader, but I've found that this won't work well on a sphere, since the vertex density is not homogeneous across the surface.

So the main question would be: How to create a point cloud for each terrain chunk whose points were equally distributed across the chunk?

Note: I've seen some examples where these points are calculated from intersecting a massive rain of totally random perpendicular rays from above... but I found this solution overkill, to say the least.

Another related question would be: Is there something better/faster than the geometry shader approach, maybe using compute shaders and instancing?

Well if you start with an icosahedron instead of a cube I think your vertexes would be lot more homogeneous and then maybe you could use them after all. They aren't perfect but you can look at my one entry blog to see if you think it's good enough for you.
 


Your terrain would be more homogeneous too.  The way I address stuff is by combining pairs of triangles together. So since we have twenty initial faces we have 10 groups and each one looks sort of like a diamond on the surface and you can think of this as as skewed square. So instead of 6 initial squares you have with the cube, you now have 10.

 

Some random stuff i've found after a quick search:

https://www.microsoft.com/en-us/research/video/parallel-poisson-disk-sampling-spectrum-analysis-surfaces/#!related_info

https://pdfs.semanticscholar.org/8902/d3e1bd3c521d7233dd0f02f649d7f5c63253.pdf

...but there's tons of research on this.

Beyond uniform random samples, for more interesting procedural generation also vector fields are a primary tool, e.g. https://www.cs.cmu.edu/~kmcrane/Projects/TrivialConnections/paper.pdf

 

Of course all this is lots of work and likely requires preprocessing, but simple random procedural stuff is usually too boring, so worth to consider / keep an eye on.

 

5 hours ago, trapazza said:

created from a spherified cube

Then you could use any procedural texturing approach by neighbour sampling like a cube map does. To counteract corners being more dense, you would need to use a ratio (texel <-> surface area) to adjust splatting density. Of course this breaks with cliffs / steep mountains but might be good enough.

This topic is closed to new replies.

Advertisement