Planetside Software Forums

General => Terragen Discussion => Topic started by: WAS on May 11, 2020, 09:04:43 PM

Title: Terragen Crater Generator
Post by: WAS on May 11, 2020, 09:04:43 PM
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:

Title: Re: Terragen Crater Generator
Post by: Kadri on May 12, 2020, 12:44:59 AM
Cool! Thanks Jordan.
Title: Re: Terragen Crater Generator
Post by: Dune on May 12, 2020, 01:40:35 AM
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.
Title: Re: Terragen Crater Generator
Post by: WAS on May 12, 2020, 02:55:01 AM
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.
Title: Re: Terragen Crater Generator
Post by: WAS on May 12, 2020, 03:19:38 AM
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. 
Title: Re: Terragen Crater Generator
Post by: Dune on May 12, 2020, 04:39:18 AM
When I attached the tgc, I didn't see any craters. Perhaps looked in the wrong locations though.
Title: Re: Terragen Crater Generator
Post by: WAS on May 12, 2020, 04:58:10 AM
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.
Title: Re: Terragen Crater Generator
Post by: Dune on May 12, 2020, 09:35:53 AM
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
Title: Re: Terragen Crater Generator
Post by: WAS on May 12, 2020, 01:42:21 PM
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.
Title: Re: Terragen Crater Generator
Post by: WAS on May 13, 2020, 01:09:31 AM
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.
Title: Re: Terragen Crater Generator
Post by: Dune on May 13, 2020, 01:49:44 AM
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.
Title: Re: Terragen Crater Generator
Post by: WAS on May 13, 2020, 02:22:23 AM
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.
Title: Re: Terragen Crater Generator
Post by: WAS on May 26, 2020, 07:45:47 PM
The Crater Generator has been moved to the Terragen Resource (https://nwdastore.com/resources/) section at NWDA.