Terragen Crater Generator

Started by WAS, May 11, 2020, 09:04:43 PM

Previous topic - Next topic

WAS

CraterGeneratorExample.jpg

I remember back in the day there was a cute little script that spit out a TGC of craters to use in your project. It was a great resource, and at that time we saw a lot of interesting uses with global craters. Those days seem over, and we're left placing crater shaders manually, or using depth maps or procedural shaders, and just don't see much space type stuff or moons.

Well, I decided to write a crater generator of my own. I'm not the best with math so it's in beta as I try to test stuff and refine it. Currently, it's maximum distance is the planet radius, which gives you a nice global coverage from what I can tell. This does mean craters are generated from the POO at the given distance limits. I haven't yet wrapped my head around offsetting the limits by a location (maybe someone can help with the math there). Anyways, I hope this comes in handy for people.


https://pnwnetwork.com/craters/

Notes:

  • Crater depth, height, and skirt are calculated by basic division proportionately with the default crater settings, ex. ( cradius / 10 ), ( cdepth / 100 ). Crater skirt is randomized between radius and half radius, ex. ( cradius / [1|2] )
  • Crater softness and tightness are randomized based on array input, otherwise will use crater defaults (0.125, and 4 respectively).
  • The crater generator packs your shaders into a Null Shader, and provides a Rim Shader Surface Layer plugged into all the crater shaders for easily modulation. Though, utilizing this shader will slow down rendering as it's calculated per crater I believe.
  • It's best to keep the Maximum Craters at or below 500, while you can go higher, it will start straining the framework, and your GPU will start to rev if it's not a powerhouse.
  • If you have ideas or suggestions, please let me know!


Dune

Interesting. Curious what the clip will look like. Usually offsetting from POO is by adding a constant vector, but I don't know how you set this up.

WAS

#3
Quote from: Dune on May 12, 2020, 01:40:35 AMInteresting. Curious what the clip will look like. Usually offsetting from POO is by adding a constant vector, but I don't know how you set this up.

Right now the maximum distance (XYZ) bounces between positive and negative. Of course those XYZ numbers are based on 0. I have some old mods for Minecraft involving vectors and velocities for my Minecraft Rocket Propelled Minecarts, I should probably look at what I I do for location based vectors for positions if I can find my source code. I tried Google for a few issues I had but man the terminology seems to bring up the most generic thing for pages. Don't know if Google is dumbing down or what.

Clip is just a giant loop of crater shaders with a null shader header and surface shader footer. If you open it in TG and resave it, it'll fix any formatting issues.

WAS

#4
I think I'm just overthinking it and I should just need to use addition/subtraction.

if POO is 5000, 5000, 5000 than the limits are -/+6378000.

Too late to test but something like this seems sane:

Code (php) Select
$nx = mt_rand( -abs( $poo['x'] - $max_distance_x ), $poo['x'] + $max_distance_x );
$ny = mt_rand( -abs( $poo['y'] - $max_distance_y ), $poo['y'] + $max_distance_y );
$nz = mt_rand( -abs( $poo['z'] - $max_distance_z ), $poo['z'] + $max_distance_z );

Wish I knew a more randomized pseudo random generator that wasn't clunky. Though maybe some generation time would be worth it for more entropy.

One thing that would be nice is to not have Y just be random junk, but aligned to the surface. 

Dune

When I attached the tgc, I didn't see any craters. Perhaps looked in the wrong locations though.

WAS

Quote from: Dune on May 12, 2020, 04:39:18 AMWhen I attached the tgc, I didn't see any craters. Perhaps looked in the wrong locations though.

Strange. It should always at least make a null shader called Packed Crater Shaders and a Rim Shader Surface Layer if the the logic somehow failed. Even though the TGC is for Terrain it keeps adding for me over in atmosphere or blank space.

Dune

The tgc had your row of 200 craters in it alright, so the final should be added as child, as it has the displacements already done. Perhaps the locations were way off somehow. I did see some locations with e+numbers, so they might be in outer space :P

WAS

Quote from: Dune on May 12, 2020, 09:35:53 AMThe tgc had your row of 200 craters in it alright, so the final should be added as child, as it has the displacements already done. Perhaps the locations were way off somehow. I did see some locations with e+numbers, so they might be in outer space :P

Yeah the Y isn't aware of the planet so just like the original it's just spitting out random Y coordinates. Which actually do help some effect by lifting and setting craters differently ontop of crater softness/tightness settings. But It would be nice to anchor to a planet but doesn't really matter with random placing. Also notice doubling radius of planet yields less craters as if radius is larger than the planet.

WAS

I have updated the crater generator. It now works based on planetoid radius and planetoid point of origin (planet/object center)  There is an experimental populator which currently has issues bunching too many craters at the North Pole, but if I can refine it, should be relative to the planet surface based on calculation of the planet and thus fair more accurate and random. But the normal (non experimental) version works off cuboid plotting, and checks if the crater is within radius tolerance, if not, redraws and hopes for a better chance. Despite the nested operation this is faster than the experimental version. Though my server is dedicated and workstation level so you may not even notice.

Dune

I realized that with 200 craters on a total earth it's no wonder I didn't see one right away. It's like the needle in the haystack. Unless they're huge and I might have sat in one. For a lot of users wanting to use your clip method, and who do not want a total global disperion it would be good to be able set some sort of restriction, say a 10,000k for more local POV's.

WAS

Right now it seems that the uniform distribution is best, despite clumping at the north pole. There seems to be an issue with the basic populator I'm trying to figure out. It wants to only populate half the planet.

Quote from: Dune on May 13, 2020, 01:49:44 AMFor a lot of users wanting to use your clip method, and who do not want a total global disperion it would be good to be able set some sort of restriction, say a 10,000k for more local POV's.

I haven't tested but using the POO as your location (like 0,0,0) with the radius being your max distance like (10000) should work. It will still be a spheroid plot, but many will intersect with the plane you're working with. When I figure out the other issues I'm having i'll see about maybe adding a switch to X/Z based plotting based on a loc.

WAS

The Crater Generator has been moved to the Terragen Resource section at NWDA.