Planetside Software Forums

General => Terragen Discussion => Topic started by: Goms on April 21, 2013, 05:24:51 AM

Title: script for populating light-sources
Post by: Goms on April 21, 2013, 05:24:51 AM
Hi folks

as a small input/output training with python I've written a script that populates a 3 dimensional Area with light-sources and returns a clip file.
it just randomizes a few parameter for each instance and writes it to the clip file.

usage: If you have python 3.3 installed, just double-click start.py
otherwise install python 3.3 :D

randomized values:
min/max X/Y/Z
min/max Strength

constant values:
Number of Stars, input for the amount of stars
Maximum Distance (default 1000000)
Casting Shadows (1 or 0)
Shadows in Atmosphere (1 or 0)

I've attached a test-image with additional color-variation - has anybody a good idea how to randomize the colors? Or better: how to ask for the scale of the variation and possibly the color-range?
The test-image is made of one very bright light-source in the center of a localized cloud and around 2500 smaller light-sources.


any Input very welcome!


Goms
Title: Re: script for populating light-sources
Post by: gregsandor on April 21, 2013, 06:24:12 AM
How about getting the colors from an rgb map?  I'd like to use something like this to place streetlights on a town grid from a map, can it do that?
Title: Re: script for populating light-sources
Post by: Goms on April 21, 2013, 06:38:37 AM
I'd have to look into reading image files, but it should be possible (technically). So I'll see what i can do.

now I'm trying to populate the light-sources on an Ellipsoid (as I thought about using the script to make a galaxy-thing).
Title: Re: script for populating light-sources
Post by: Goms on April 21, 2013, 04:38:13 PM
After playing with the idea of a image-shader the like input, I can say it's possible but a bit too much work for the time I have right now. Especially if you want the lights to be distributed more regular, you'll need some kind of pattern-matching function. If you could however mathematically define the street pattern, it's not a big thing.
Another approach would be to leave the light sources with "not visible" and just blend a cloud layer with the street pattern. This should work if you don't come too close I guess. I will try to try this tomorrow, if I can get on my desktop for a while. :D
Title: Re: script for populating light-sources
Post by: TheBadger on April 21, 2013, 08:06:28 PM
Sorry guys, im a little lost. What is this and how does it work? Some kind of stand alone python editor, or like the one in Maya?
Title: Re: script for populating light-sources
Post by: Goms on April 22, 2013, 01:40:44 AM
It should just be a little script that opens a command prompt. The only thing it does is making a clip file with a number of llight sources. if you dont have python installed as a programm to run from everywhere, you might need to specify the path to the python executable or indeed open the python console and run the script from there.
Title: Re: script for populating light-sources
Post by: Goms on April 22, 2013, 03:55:43 AM
another note on running this: if double clicking start.py does not open a command prompt, but opens a program called "Idle", just click "Run -> Run Module". Or right-click start.py and select "open with -> python launcher for windows"
Title: Re: script for populating light-sources
Post by: Goms on April 22, 2013, 05:56:09 AM
And a second version with ellipsoid distribution.
Input Options: rXZ (max radius of X and Z), rY (max radius of Y), min/max Strength, min/max Max Distance, cast Shadows, shadows of Atmosphere
Title: Re: script for populating light-sources
Post by: TheBadger on November 21, 2013, 07:02:32 AM
Hey, Goms!
You still around? Are you still playing with this script?
Title: Re: script for populating light-sources
Post by: lat 64 on November 23, 2013, 02:13:48 PM
Badger,
Thanks for bumping this thread. I'm fascinated by the possibilities.

Do you suppose a vortex Shader would do a galaxy-type distribution?

I'm also swooning from the idea of animating it. Think of the explosions! 8)
Title: Re: script for populating light-sources
Post by: TheBadger on November 23, 2013, 05:28:17 PM
QuoteDo you suppose a vortex Shader would do a galaxy-type distribution?
I was thinking about it too. I still have not had time to buy T3 yet. So haven't worked with the new stuff. I have the cash, and hope to finally get caught up a little tonight and sunday.
My guess is that the vortex shader will be a lot more direct then using a hurricane node system from T2. Or maybe using the new nodes to adapt node sets from the forum... Just don't really know yet.

But if we can animate a hurricane, and we can animate the vortex shader, then it stands to reason we can animate a galaxy. As far as I understand things, all of the stars and planets and all other mater in a galaxy rotate with the galaxy (some galaxies rotate, some don't) So the question for me is can I rotate the distribution of orbs/stars with the clouds?

Working out the mechanics of everything is step one I guess. I did find several shared node trees that will fill the center of the galaxy nicely, once the rest is working.
Title: Re: script for populating light-sources
Post by: Goms on November 26, 2013, 05:19:14 AM
Hi

not, at the moment I don't really have the time (though it would be a nice distraction to play around with it a little more).
I don't know about the new stuff in TG3 yet - can you populate light-sources etc now?

other than that, it shouldn't be too hard to create the objects and bind them to according animation files for the movement. A realistic calculation of a whole galaxy would of course be a lot of calculation, but simply rotating stars around a center sounds easy. It should also be possible to read a bitmap for density, though the 3 dimensional properties could make more difficult.



Maybe i can draw up something (for TG2) in the next days..
Title: Re: script for populating light-sources
Post by: TheBadger on November 26, 2013, 12:16:24 PM
Cool, Goms. Thanks. Have a play when you can and let us know what you think.
Title: Re: script for populating light-sources
Post by: Goms on November 28, 2013, 08:14:54 AM
a little update: so far i've manages to read 3 bitmaps (one for each side) and create a clip file with stars according to the mean density.
Also it shouldn't be a problem to rotate them, as the only thing you need is a few arguments in the clip file itself, to create a nice rotation.

BUT: I've way too much stars. Even if i set the highest number of stars for a white area in the bitmap to one, i still get too many to load it. with every tenth area in my 500 pixel wide bitmap i have 27735, which makes tg2 eat up 10GB of memory... And atm i've no idea how to solve this. Though it should be easy i think...

edit: and this is what it looks like now (without any effort no get it nice looking :D )

Title: Re: script for populating light-sources
Post by: Goms on November 29, 2013, 09:42:57 AM
next update.
I've changed the input to interpret the brightness of the image as density and use the color of the pixels to color the light-sources. (though it's possible that i'll change it to use two bitmaps; one for density and one for color)
The results are quite decent, imho. (~6000 stars, 30min rendertime on my 2600K)

Animation: thats actually quite nasty. It's not a problem to make the stars rotate. you only need a few coordinates (for a full circle 4 coordinates in each x and z are enough, and you don't even need an animation file, you can just write them into the clip file.) BUT: rotating all at the same speed makes no sense, as the stars in the center need a higher speed to maintain "altitude". So each star will have his own period (completely ignoring that each one will have his own speed depending on mass too). The problem with this is, that every coloring you set at the beginning will be lost after some time.
Another problem is that the movement in a galaxy is way more complex than this. I've looked at some ways to simulate n-body systems, and each are very time consuming. In order to simulate 5000 light-sources you have to ask google if you can borrow their servers for a week. (But it would be fun!) So i'm not sure where to go here...

But first I'll clean up the code, make up some kind of I/O to allow custom parameters and share the current state.

I've attached the tgd for the image below.